This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: Link error - getting undefined symbols when using stl
"Ryan Cuprak"<cuprakr@earthlink.net> writes:
> Hello,
> I am having trouble with linking together a simple project which uses stl
> (string,list, and vector). I am using Apple's gcc (3.1). The undefined symbol
> errors are below the makefile. Any suggestions?
Link with g++, *not* with gcc. gcc does not link in the standard
c++ library (libstdc++) or the c++ runtime library. g++ will link
these in automagicly.
> BTW: My project does compile and run perfectly inside of ProjectBuilder so I
> am guessing it has something to do with my linking/compiler directives. I have
> been hunting through the gcc manual and doing goodle searches all day. I am
> guessing that it has someting to do with templates but I am not terribly sure.
>
> Thanks,
> Ryan Cuprak
>
>
> build : attribute.o element.o parser.o
> gcc -c main.cpp -o obj/main.o
> gcc -o test.out obj/Attribute.o obj/Element.o obj/Parser.o obj/main.o
> attribute.o :
> gcc -c xml/model/Attribute.cpp -o obj/Attribute.o
> element.o : attribute.o
> gcc -c xml/model/Element.cpp -o obj/Element.o
> parser.o : attribute.o element.o
> gcc -c xml/parsers/Parser.cpp -o obj/Parser.o
build : attribute.o element.o parser.o
g++ -c main.cpp -o obj/main.o
g++ -o test.out obj/Attribute.o obj/Element.o obj/Parser.o obj/main.o
attribute.o :
g++ -c xml/model/Attribute.cpp -o obj/Attribute.o
element.o : attribute.o
g++ -c xml/model/Element.cpp -o obj/Element.o
parser.o : attribute.o element.o
g++ -c xml/parsers/Parser.cpp -o obj/Parser.o