Multiple module problems in Turbo C++

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
srg

Multiple module problems in Turbo C++

Post by srg »

Hi

I have a program in which my video routines are in a secndary module video.c, its prototypes are in video.h. My main function is in a module called main.c. My Main function at the moment calls just one of the video routines and it compiles fine but I get a linker error:

?Linker Error: Undefined symbol _Print_Char in module MAIN.C

I include the header file just fine and it compiles so what is going wrong?

Thanks
Tim

Re:Multiple module problems in Turbo C++

Post by Tim »

Are you actually linking both object files after compiling them? The header file just lets the compiler know the functions are available; it doesn't include them into the output. You need to specify the names of both object files on the linker command line.
User avatar
Pype.Clicker
Member
Member
Posts: 5964
Joined: Wed Oct 18, 2006 2:31 am
Location: In a galaxy, far, far away
Contact:

Re:Multiple module problems in Turbo C++

Post by Pype.Clicker »

did you give both video.o and main.o files to the linker ?
the trick is to compile your file separately ( *.c -> *.o) and then to give all .o files to the linker in order to produce a single .bin file
srg

Re:Multiple module problems in Turbo C++

Post by srg »

Pype.Clicker wrote: did you give both video.o and main.o files to the linker ?
the trick is to compile your file separately ( *.c -> *.o) and then to give all .o files to the linker in order to produce a single .bin file
I just went run in the run menu of the IDE
srg

Re:Multiple module problems in Turbo C++

Post by srg »

I just went run in the run menu of the IDE
hmm Interesting, it worked fine from the command line, is the IDE crap?? Shame if it is , as the Turbo Pascal one was great (for Pascal of course :))
User avatar
Pype.Clicker
Member
Member
Posts: 5964
Joined: Wed Oct 18, 2006 2:31 am
Location: In a galaxy, far, far away
Contact:

Re:Multiple module problems in Turbo C++

Post by Pype.Clicker »

you cannot just run if you have a multi-module project: you must build it first.... unlike pascal, C isn't interpretable...
Tim

Re:Multiple module problems in Turbo C++

Post by Tim »

Pype.Clicker means to say that, unlike Pascal, C doesn't take care of linking and dependencies for you. You have to compile each source file separately and link them into one executable; to do you, you probably need to create a project and add all your source files there.
User avatar
Pype.Clicker
Member
Member
Posts: 5964
Joined: Wed Oct 18, 2006 2:31 am
Location: In a galaxy, far, far away
Contact:

Re:Multiple module problems in Turbo C++

Post by Pype.Clicker »

hum, yes... tnx for the translation, Tim ... that was one-hand-only typed in a hurry ;)
Post Reply