Reputation: 19
I'm designing an operating system on unix. I have a main process which then uses fork() to create another 2 child processes. I used execl() to in the main process call the child processes so the 2 child processes can be put into separate .c files. Therefore, the 2 child processes have their own main()
I use gcc to compile, first I compiled the .o files for all the source files, then compile the executable using all the .o files.
This gives me an error which says there are multiple main()s in the file.
What is the correct way to compile this ?
Thanks a lot
Upvotes: 1
Views: 228
Reputation: 47762
The correct way is to link (let's say) child1/main.o
and all it needs into one executable and child2/main.o
and all it needs into another. Some object files may be present in both.
Upvotes: 1