PDA

View Full Version : Undefined reference when compiling in linux


nonoykevin
July 4th, 2007, 09:53 PM
when i compile my program in linux (ubuntu) there is no error but it shows "undefined reference to a specified function, i use thid command when i compile (g++ LoaderControl.cpp -o LoaderControl). But if i'm goin to compile using gcc -c LoaderControl.cpp, there is no error... can anybody explain me why? any answer to this question pls....thanks

slavik
July 5th, 2007, 12:14 AM
without seeing exact errors and source code, we can't really help you ...

geraldm
July 5th, 2007, 01:12 AM
>compile using gcc -c LoaderControl.cpp
There is no error, because the error comes when the source is linked,
and linking was not done. BTW: use g++ to compile *.cpp source, not
gcc.

nonoykevin
July 5th, 2007, 01:12 AM
here's the sample result when i compile my source code in g++...

file.cpp: (.text + 0xc50): undefined reference to 'Cfile::Open()'
....
....

thanks...

nonoykevin
July 5th, 2007, 01:20 AM
that's why when i used the g++ then the result comes undefined reference..but when i compile in gcc there's no error...

slavik
July 5th, 2007, 01:22 AM
did you include the proper files, did you link the proper libraries?

nonoykevin
July 6th, 2007, 09:24 PM
i already check my source code and all include files were linked together...the only problem was that the classes of one of my linked source was undefined reference to the one i compiled...