How to specify libraries for the linker

ceklund@mail.student.oulu.fi ceklund@mail.student.oulu.fi
Thu Dec 4 15:08:00 GMT 2003


Hi,

I`m trying to link my Test.o file to exe file, but the linker 
can`t find any libraries. I think it want`s the standard library.

1. I compiled my Test.cpp file -> OK
2. in the same directory I tried the following:
   gcc -o Test.exe Test.o

-> output:

------
..
Test.o(.text+0xf):Test.cpp: undefined reference to `operator new(unsigned
long)'
Test.o(.text+0x2e):Test.cpp: undefined reference to `operator delete(void*)'
Testi.o(.text+0x5e):Test.cpp: undefined reference to
`std::ios_base::Init::Init()'
Test.o(.text+0xbc):Test.cpp: undefined reference to
`std::ios_base::Init::~Init()'
Test.o(.gnu.linkonce.t._ZN5Testi7printEv+0xf):Test.cpp: undefined reference to
`std::cout'
..
------


I tried to use the -l and -L flags but I dont know what to put after that,
because I dont`t know what libraries I need and where do they reside (\lib
??).

Could somebody be so kind to help me. I`d need to know how to
do the job and tell me what libraries I need for standard C++ programs.

regards,

-mark



More information about the Gcc-help mailing list