[Scons-users] modify linker command

Kraus Philipp philipp.kraus at flashpixx.de
Tue Jun 19 15:09:50 EDT 2012




Am 19.06.2012 um 18:00 schrieb Managan, Rob:


> I guess I don't understand your problem. I have a Mac and since I don't

> have administrator privileges I have many libraries installed at

> $HOME/local/lib. I regularly use my linux Scons setup to find those

> libraries. Some of them are shared libraries but some I build are static,

> libxxx.a.

>

>

> Generally I have used the call CheckLibWithHeader. This was set up long

> enough ago I don't recall if I use that because I could not get other

> Check routines to work as I wanted or if I just wanted to specify the

> header.

>

> Let me also say that this stuff dates back to SCons versions before 1.0

> and there may be a better way to do this now.

>


I'm using Scons 2.1.0



> For example:

>

> if env["x11"] == 1:

> # print 'Checking X11 library ',len(env['LIBS'])

>

> ret=CheckLibHeaderwPaths(env,conf,'X11',['X11/Xlib.h','X11/Xutil.h'],env['x

> 11_inc'],'XLIB',

> env['x11_lib'],language='C',

> call='char display_name[32] = "" ;Display *display =

> XOpenDisplay(display_name);')

> if ret != None:

> env['x11'] = 0

>

>


This uses on my system the *.dylib. I check eg for boost_iostream. If I run the CheckLib (described here http://scons.org/wiki/SconsAutoconf )
Scons create the g++ flag -lboost_iostream
The forced option is, to use dynamic linking (see g++ FAQ). You can test it with "otool -L your_executable"
If it uses the static build the library is not listed, on dynamic build the library is shown with its soname.
Also if I run g++ .... - lboost_iostream on CLI the linker uses the dynamic library on default.


If you use the binutils eg from the MacPorts you can switch the linker, which can work with other options, but I use the Apple gcc bundel only.





> I attached my routine CheckLibHeaderwPaths as a text file to preserve

> indentation.

> I have a similar routine that adds a TryRun to make sure I can execute a

> test program with the library...

>

>

>

> On 6/19/12 7:04 AM, "Kraus Philipp" <philipp.kraus at flashpixx.de> wrote:

>

>>

>> Am 19.06.2012 um 14:44 schrieb Gary Oberbrunner:

>>

>>> On Tue, Jun 19, 2012 at 8:25 AM, F. Heitkamp <heitkamp at ameritech.net>

>>> wrote:

>>>> I second this. I have a rather unusual Linux system with libraries in

>>>> certain directories. I need to specify these (LDFLAGS,LIBS,etc).

>>>> Scons

>>>> doesn't seem to allow an easy way to do this. Not trying to create a

>>>> flame

>>>> war but this is very easy with autotools. Doesn't anyone have any

>>>> hints?

>>>> I've tried just about everything I can think of, without actually

>>>> modifying

>>>> Scons scripts.

>>>

>>> That is not the problem, I think you missunderstood something:

>>

>> How can I detect with the Scons autotools a static library? The CheckLib

>> / CheckLibWithHeader Command find only dynamic libraries, not static, so

>> I can modify the build string command, but I need the full qualified path

>> of the static library. On different systems the pathes are different and

>> Autotools should be find the correct installed library. Autoconf works

>> only with dynamic libraries not with static. I have tried to use

>> CheckLib("libmylib.a") but the command returns always false. If I run

>> CheckLib("mylib") autotools finds only the dynamic.

>>

>> On binutils linker I use -Bstatic -l<library> -Wl for building static

>> linked code, so with the issue of Autoconf I use Autotool for searching

>> the dynamic libs and than I modify the LINKCOM string for adding -bstatic

>> and -Wl around the -l flags, but OSX does not support the -bstatic flag,

>> so the linker command breaks, so I can link on OSX only static if I know

>> the fulled qualified path to my static library. This is a chicken or the

>> egg causality dilemma

>>

>> So the main problems is: How I can use static libraries with the Scons

>> Autoconf?

>>

>>

>

>

>

> *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-

> Rob Managan email managan at llnl.gov

> LLNL phone: 925-423-0903

> P.O. Box 808, L-095 FAX: 925-422-3389

> Livermore, CA 94551-0808

>

>

>

>>

>

> <checklibheader.py>_______________________________________________

> Scons-users mailing list

> Scons-users at scons.org

> http://four.pairlist.net/mailman/listinfo/scons-users




More information about the Scons-users mailing list