Author Topic: compiling two differnt targets that have a main function  (Read 4296 times)

Offline mak

  • Single posting newcomer
  • *
  • Posts: 3
compiling two differnt targets that have a main function
« 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???


Online stahta01

  • Lives here!
  • ****
  • Posts: 7788
    • My Best Post
Re: compiling two differnt targets that have a main function
« Reply #1 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.

C Programmer working to learn more about C++ and Git.
On Windows 10 64 bit and Windows 11 64 bit.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline mak

  • Single posting newcomer
  • *
  • Posts: 3
Re: compiling two differnt targets that have a main function
« Reply #2 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?

Offline Jenna

  • Administrator
  • Lives here!
  • *****
  • Posts: 7252
Re: compiling two differnt targets that have a main function
« Reply #3 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.