LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   C++ linking? (https://www.linuxquestions.org/questions/programming-9/c-linking-20768/)

ugenn 05-12-2002 07:48 AM

C++ linking?
 
How do I link a C++ program properly? gcc complains of a lot of unresolved symbols when I use just gcc foo.cpp. Is there some library I have to link against.?

tda 05-13-2002 03:12 AM

You definitely have to link your program with some libraries. But which librarires you should link is depends of your program. See also -L -l and -I options for gcc.

gui10 05-13-2002 03:59 AM

i believe the command to compile a C++ program is using g++ instead of gcc. maybe you could try that first?

ugenn 05-13-2002 06:33 AM

I highly doubt it. gcc is supposedly able to handle c, c++, and asm and linking of obj code. Besides, my code uses c++ keywords, which would cause syntax errors ona regular c compiler which it didn't. The errors only appeared during linking.

llama_meme 05-13-2002 06:35 AM

you should listen to gui :) only g++ automatically links in the required c++ libraries, gcc will give linker errors for c++ programs

ugenn 05-14-2002 01:33 AM

Quote:

Originally posted by llama_meme
you should listen to gui :) only g++ automatically links in the required c++ libraries, gcc will give linker errors for c++ programs
g++ worked. i stand corrected.


All times are GMT -5. The time now is 03:25 PM.