[Scons-users] modify linker command

Kraus Philipp philipp.kraus at flashpixx.de
Sun Jun 24 08:37:36 EDT 2012



Am 23.06.2012 um 22:14 schrieb William Deegan:


> Kraus,

>

> On Jun 19, 2012, at 10:42 PM, Kraus Philipp wrote:

>

>>

>> Am 19.06.2012 um 22:12 schrieb gabor papp:

>>

>>>> This uses on my system the *.dylib. I check eg for boost_iostream. If I run the CheckLib

>>>> Scons create the g++ flag -lboost_iostream

>>>> The forced option is, to use dynamic linking (see g++ FAQ).

>>>

>>> you can use CheckLib with autoadd=0, and add boost to the libs manually.

>>> something like this should work:

>>> env.Append(LIBS = [File('/usr/lib/libboost_iostream.a')])

>>>

>>> or if you use autoadd you can remove the lib first like this:

>>> env['LIBS'].remove('boost_iostream')

>>> then append the static one as above.

>>>

>>> if you don't know the path for the lib, i believe you can search for

>>> it like this:

>>> path = FindFile('libboost_iostream.a', env['LIBPATH'])

>>

>> If I link static, I can not use autoconf, because no function can search the static library, so I must

>> write my own CheckStaticLibrary / CheckStaticLibraryWithHeaders

>> Is there any option to add a function to the scons general branch that checks also the static libs?

>

> New code is always welcome.

> Keep in mind that SCons has a long standing policy of not adding/changing code without an accompanying test which should fail before the code change and pass afterwards. (There are some exceptions to this, but in general we require tests). If you can provide the code change, preferrably with test and doc changes that would simplify getting your changes into SCons.



I check for static libs with this code:

for i in staticlinklist :
lcLib = conf.env["LIBPREFIX"] + i + conf.env["LIBSUFFIX"]
lxPath = conf.env.FindFile(lcLib, conf.env["LIBPATH"])

if lxPath == None :
print "Checking for static C library " + lcLib + "... no"
sys.exit(1)
else :
conf.env.Append(LINKFLAGS = str(lxPath))
print "Checking for static C/C++ library " + lcLib + "... yes (found in " + os.path.dirname(str(lxPath)) + ")"

staticlinklist is a list with items like "boost_iostream" etc, the same named items like the LIBS within the env. I think a changing of the code base is not nessessary, only 2 new functions like CheckStaticLib and CheckStaticLibWithHeaders can do the work, but in this case am idea for linking is a "fallback method", so I can run CheckLib, but if CheckLib does not find any library the CheckStaticLib is used and if only CheckStaticLib returns false, the Check returns also false.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://four.pairlist.net/pipermail/scons-users/attachments/20120624/b8abad6e/attachment.htm>


More information about the Scons-users mailing list