Re: Linking a program with a directory??

Bram Moolenaar <[email protected]> Fri, 23 Jul 2004 13:06:43 +0200
Newsgroups gmane.comp.tools.aap.user
Message-ID <[email protected]>
Magnus Therning wrote:

> I am feeling really stupid here, but I simply can't get it to work!
> 
> Files:
> 
>  foo.c
>  foo.h
>  main.c
> 
> main.aap:
> 
>  :dll foo : foo.c
> 
>  :program bar { add_LIBS = -lfoo } : main.c
> 
> Result:
> 
> Aap:  cc       -MM foo.c > build-Linux2_6_7_1_k7/foo.c.aap
> Aap: cc    -O2  -fPIC -c -o build-Linux2_6_7_1_k7/foo.sho foo.c
> Aap: ld  -shared -o libfoo.so build-Linux2_6_7_1_k7/foo.sho
> Aap:  cc       -MM main.c > build-Linux2_6_7_1_k7/main.c.aap
> Aap: cc    -O2  -c -o build-Linux2_6_7_1_k7/main.o main.c
> Aap: cc  -O2 -o bar build-Linux2_6_7_1_k7/main.o -lfoo
> /usr/bin/ld: cannot find -lfoo
> collect2: ld returned 1 exit status
> Aap: Error in recipe "/home/magnus/prog/tst/aap_03/main.aap" line 3: Error executing commands for build default: Error in recipe "/usr/lib/aap/default.aap" line 414: Shell command returned 1
> 
> I'd really like to get a '-L.' onto that last command, but how?

Using add_LDFLAGS should work:

    :program bar {add_LDFLAGS = -L. }{ add_LIBS = -lfoo } : main.c

Putting -L. in add_LIBS will also work.  I'm not sure what is "cleaner".

Another mechanism is to refer to the library directly instead of with
"-l":

    :program bar { add_LIBS = $(DLLPRE)foo$DLLSUF } : main.c

That can also be used when the library is in another directory or
produced by a child recipe.

-- 
Q: Should I clean my house or work on Vim?
A: Whatever contains more bugs.

 /// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net   \\\
///        Sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\              Project leader for A-A-P -- http://www.A-A-P.org        ///
 \\\  Buy at Amazon and help AIDS victims -- http://ICCF.nl/click1.html ///


-------------------------------------------------------
This SF.Net email is sponsored by BEA Weblogic Workshop
FREE Java Enterprise J2EE developer tools!
Get your free copy of BEA WebLogic Workshop 8.1 today.
http://ads.osdn.com/?ad_id=4721&alloc_id=10040&op=click