[Scons-users] Problem with DLL dependencies on Windows
Dirk Bächle
tshortik at gmx.de
Sat May 25 05:49:01 EDT 2013
Dmitry,
I finally found some time to look into your example, and I think I know
what's going on now.
On 24.05.2013 10:41, Dmitry Mikhin wrote:
> Hello Dirk,
>
>> [...]
>> The *.a file and the *.dll file should both appear in the list of targets
>> for your DLL. You can test this by printing them to stdout:
>>
>> t = env.SharedLibrary(...)
>> print "My targets:", map(str, t)
> Yes, they do:
> My targets: ['utils.dll', 'libutils.a']
The fact that both libraries appear as output targets, proves that the
MinGW toolchain is doing its job just fine. Also the 'lib/SConscript'
directly uses the created target nodes for the LIBS variable, such that
SCons finds them and they get properly registered as dependencies for
the final executable.
But in the 'prog/SConscript' you declare the LIBS variable as
libs = ['utils']
only. This means that SCons then tries to find a library with the name
stem 'utils' in the set of defined Nodes, and it uses the Environment
variables 'LIBPREFIXES' and 'LIBSUFFIXES' for this. Under Windows, these
two get initialized to
LIBPREFIXES = ['$LIBPREFIX'] # meaning 'lib'
LIBSUFFIXES = ['$LIBSUFFIX'] # meaning '.a'
, respectively.
This is why only the 'libutils.a' gets found for your second program.
You can confirm this with the '--debug=findlibs' option, as suggested by
Jason Kenny.
I currently have the following two solutions for this:
1.) Either you propagate the target nodes for the 'utils' lib from one
SConscript to the other as
# in lib\SConscript
utils = ...
Export('utils')
# in prog\SConscript
Import('utils')
libs = utils
2.) or, you allow the library finder to search for .DLL files as well,
by adding
env.Append(LIBPREFIXES = ['$SHLIBPREFIX'])
env.Append(LIBSUFFIXES = ['$SHLIBSUFFIX'])
while constructing the main Environment in your top-level SConstruct.
Best regards,
Dirk
More information about the Scons-users
mailing list