Code::Blocks Forums

User forums => General (but related to Code::Blocks) => Topic started by: mak on March 24, 2011, 11:37:36 pm

Title: compiling two differnt targets that have a main function
Post by: mak on March 24, 2011, 11:37:36 pm
Hello

I searched all over this site and google to find an answer to this, but still no luck.

Basically I have two files I want to compile osmain.cc and kbrd.cc:

osmain.cc has the int main(){} function  and

kbrd.cc has the main(){} function

they are both assigned to different targets, but are suppose to work together
they are both infinite while loops until ctrl-c is typed on the keyboard

When I build each target like osmain.cc, it complains about functions in kbrd.cc.

How can I compile/build these functions so it works???

Title: Re: compiling two differnt targets that have a main function
Post by: stahta01 on March 25, 2011, 12:03:13 am
Do NOT have them in each other targets.

If you turn on FULL compiler logging; I will bet they are both in both targets or you are linking them together.
http://wiki.codeblocks.org/index.php?title=FAQ#Q:_How_do_I_troubleshoot_an_compiler_problem.3F

Tim S.

Title: Re: compiling two differnt targets that have a main function
Post by: mak on March 25, 2011, 09:11:25 am
Basically this piece of code doesn't execute in Code::Block

Code
in_pid = fork();  <--------- doesn't work
if (in_pid == 0) // is this the child process ?
{
execl("keyboard", "keyboard", childarg, 0);  <---------- doesn't execute the other main in keyboard.cc

//getchar();
// should never reach here
fprintf(stderr,"osmain: can't exec keyboard, errno %d\n",errno);

//getchar();
cleanup();

//getchar();

exit(1);
}

the second target assigned to keyboard.cc is keyboard, so why can't this main call the child process?
Title: Re: compiling two differnt targets that have a main function
Post by: Jenna on March 25, 2011, 09:47:36 am
Please explain, why you think this problem is C::B related !

Don't forget, that C::B is an IDE, not a compiler !!

If it is not related to C::B, your post violates our forum rules and should be asked in a general programming forum, not in our forum / on our site.