[Scons-users] modify linker command

Kraus Philipp philipp.kraus at flashpixx.de
Tue Jun 19 10:04:08 EDT 2012



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


More information about the Scons-users mailing list