help-gplusplus
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Cannot link against my own library due to undefined symbols???


From: Pep
Subject: Re: Cannot link against my own library due to undefined symbols???
Date: Wed, 6 Feb 2008 01:20:16 -0800 (PST)
User-agent: G2/1.0


Larry Smith wrote:

<snip>

> Here is the "makefile" I used to build your example:
>
> ----------
>
> # GNU Make makefile
>
> # how to make a '.o' from a '.cc'.
> # make will use this rule to build main.o, file1.o, and file2.o
> %.o: %.cc
>       g++ -c -o $@ -I. $<
>
> # how to make 'test-main'
> # the pre-reqs libtest.a and main.o will be built first
> test-main : libtest.a main.o
>       g++ -o $@ main.o -L. -ltest
>
> # how to make libtest.a
> # the pre-reqs file1.o and file2.o will be built first
> libtest.a : file1.o file2.o
>       ar -rvs $@ $^
>
> # clean up the files created by 'make'
> clean :
>       -rm main.o file1.o file2.o libtest.a test-main
>
> ------------
>
> Here is the output from the command "make":
>
> ~/x/pep> make
> g++ -c -o file1.o -I. file1.cc
> g++ -c -o file2.o -I. file2.cc
> ar -rvs libtest.a file1.o file2.o
> ar: creating libtest.a
> a - file1.o
> a - file2.o
> g++ -c -o main.o -I. main.cc
> g++ -o test-main main.o -L. -ltest
>
>
> Here is the output from executing "test-main":
>
> ~/x/pep> ./test-main
> ns1::base_class::base_class()
> ns1::derived_class::derived_class()
> ns1::derived_class::~derived_class()
> ns1::base_class::~base_class()
>
> So, it works for me (openSUSE 10.3, g++ v4.2.1)

Yay, thanks very much for pointing out the painfully obvious :)

We do not have the luxury of using autoconf and the like with this
project, instead using some horrible hand crafted jam files where we
have to work out the dependencies ourselves, so coming out in to a
cleaner environment I should have thought of that straight away.

Guess it's a case of can't see the wood for the tree ;)

Thanks so much, I shall slap myself for being so lame.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]