[Scons-users] modify linker command

Joanne Bogart jrb at slac.stanford.edu
Tue Jun 19 21:12:56 EDT 2012


On 06/19/2012 07:04 AM, Kraus Philipp 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.

>> Not sure why this is an issue. This should be trivial; we do it all

>> the time. You can modify LINKCOM, SHLINKCOM, LDFLAGS, and many other

>> vars -- see the man page. You can do it per-OS if you like:

>>

>> env=Environment()

>> if sys.platform == 'linux2':

>> env.Append(LIBS=['xyz', 'pdq')

>> env.Append(LDFLAGS=' $EXTRA_LDFLAGS')

>> env['EXTRA_LDFLAGS'] = '-whatever'

>> if sys.platform == 'darwin':

>> env[LINKCOM] = '$LINK $MYSPECIALDARWINLINKFLAGS -o $TARGET

>> $LINKFLAGS $__RPATH $SOURCES $_LIBDIRFLAGS $_LIBFLAGS $_FRAMEWORKPATH

>> $_FRAMEWORKS $FRAMEWORKSFLAGS'

>>

>> etc. Here's a tip to print all the variables in a construction environment:

>> env=Environment()

>> print env.Dump()

> 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,

I *think* I understand your problem, and that has not been my
experience. Our code uses CheckLib to successfully detect static as
well as dynamic libraries for a collection of "externals" (3rd party
stuff, not built by us). It goes something like this:

LIBPATH for the construction environment confEnv gets path entries as
needed for all the libraries to be checked (as will also be the case for
construction environments used in the actual build).

We do it with lines like this:

confEnv.AppendUnique(LIBPATH = [configuredExternal['lib-path']])

where configuredExternal is a dict including, among other things, path
to library or libraries for that external

Then

conf = convEnv.Configure( )

and for each library name myName (excluding platform-specific prefix
and suffix as well as directory path) do
conf.CheckLib(myName, language='C++') # or whatever other
options are appropriate


We use this code on Linux, Mac (snowleopard) and Windows with SCons 2.1.0

best,
Joanne





> 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?

>

> Phil

> _______________________________________________

> 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