Lord Windy
Lord Windy

Reputation: 792

How to stop Scons adding lib infront of a shared library

I've been playing around with Scons on OSX and I'm trying to make a Shared Library (.dll, .so, .dylib).

It's all worked perfectly except for one thing that is really annoying me, it adds 'lib' in front of the library name. For example, I choose the name WL and it becomes libWL.dylib. I cannot work out why Scons does this and it is driving me mad.

enter image description here

The code I am using is:

# -*- coding: utf-8 -*-
import os
SourceList = ['Window.cpp']
env = Environment(ENV = os.environ)

#Libraries we are using
Targets = 'WL'
libraries = ['SDL2']

#Paths to the libraries and include paths
Paths = ['/usr/local/lib', '/usr/local/include']

Export('SourceList env libraries Paths Targets')
SConscript('src/SConscript', variant_dir='bin', duplicate=0)

and

Import('SourceList env libraries Paths Targets')
SharedLibrary(target = Targets,source = SourceList,LIBS = libraries, LIBPATH=Paths)

I'm not super knowledgeable about how shared libraries work so I don't know if I could just change the name after it's compiled. But I would like it to just not add in letters

Upvotes: 4

Views: 1269

Answers (1)

dirkbaechle
dirkbaechle

Reputation: 4052

In each environment, SCons uses variables to specify the prefixes and suffixes of things like libraries and programs. These variables get initialized, based on the detected platform that it's currently running on...but you can simply overwrite this setting after the call of the Environment() constructor:

env = Environment()
env['SHLIBPREFIX'] = ''

For "darwin"-like systems, SCons calls the standard "posix" initialization first...that's where the default "lib" prefix comes from.

Tip: You can treat an Environment very much like a dictionary (hash map), and set its values how you need them to be. For displaying its current contents you can use the Dump() method:

print env.Dump()

in a SConstruct/SConscript which gives you a full listing of the defined variables. You can find a list of standard variables in the MAN page ( http://scons.org/doc/production/HTML/scons-man.html ) and the UserGuide ( http://scons.org/doc/production/HTML/scons-user.html ).

Upvotes: 9

Related Questions