App that runs in the background or is console-based

(1) I am trying to find the source code for the system time shown in the Deskbar
since I am working on some app that should run in the background.

Anyone knows where this part of code is located in Haiku code tree?


(2)
#include <stdio.h>

int main()
{
printf(“Test!”);
return 0;
}

I got the following result:
/boot/develop/lib/x86/start_dyn.o: in function ‘_start’:
start_dyn.c:(.text + 0x57): undefined reference to 'main’
collect2: ld returned 1 exit status

If I want to output something to the stdout, what should I write? Does it mean
that any app on Haiku has to be GUI-based? By the way I use Paladin as my IDE.

I’m not running Haiku at the moment, but I’m 100% certain that a simple snippet like:

#include <stdio.h>

int main(){

printf(“Test!”);

return 0;
}

would work with a g++ main.cpp (or gcc main.c etc) and executing a.out from terminal would print out ‘Test!’

The code you’ve written should work just fine and will print something to stdout. The error you’re getting is a linker error, and considering you’ve written a main() function, I’m puzzled why you’re getting the error. Which project template did you use? Also, which revision and compiler build (gcc2, gcc4, hybrid) of Haiku are you using?

I tested that code and worked for me. I used Pe editor to write it.

My steps from terminal:
cd /boot/home, lpe simple.c, write the code in Pe & save, gcc simple.c, run a.out

No errors & works. Test that out to see if it works first. If yes, then you can try again with Paladin.

same problem but solved

same problem but solved