Discussion:
[Scons-users] MSVC linker always relink with shared library?
Daniel Moody
2018-08-14 04:59:05 UTC
Permalink
Anyone else seeing this with latest release (3.0.1)? It doesn't re-link
with Program when building an executable.

Here is my SConstruct:

env = Environment()
env.SharedLibrary('test', 'test1.c')

Here is test1.c:

int foo(){ return 0; }

When I run this the first time this is my output:

C:\Users\Daniel\workspace>scons -f SConstruct.py
scons: Reading SConscript files ...
scons: done reading SConscript files.
scons: Building targets ...
cl /Fotest1.obj /c test1.c /nologo
test1.c
link /nologo /dll /out:test.dll /implib:test.lib test1.obj
scons: done building targets.

If I run the same command again without changing anything, I get the link
again:

C:\Users\Daniel\workspace>scons -f SConstruct.py
scons: Reading SConscript files ...
scons: done reading SConscript files.
scons: Building targets ...
link /nologo /dll /out:test.dll /implib:test.lib test1.obj
scons: done building targets.

Subsequent runs of the command produce the link again.

I have Visual Studio 2015 installed.

Scons and Python:
C:\Users\Daniel\workspace>scons -v
SCons by Steven Knight et al.:
script: v3.0.1.74b2c53bc42290e911b334a6b44f187da698a668, 2017/11/14
13:16:53, by bdbaddog on hpmicrodog
engine: v3.0.1.74b2c53bc42290e911b334a6b44f187da698a668, 2017/11/14
13:16:53, by bdbaddog on hpmicrodog
engine path:
['c:\\python36\\lib\\site-packages\\scons-3.0.1\\SCons']
Copyright (c) 2001 - 2017 The SCons Foundation

C:\Users\Daniel\workspace>python --version
Python 3.6.5
Gary Oberbrunner
2018-08-14 11:11:34 UTC
Permalink
Hi Daniel; can you try with 'scons --debug=explain' ? That might show why
it thinks it needs to be rebuilt.
Post by Daniel Moody
Anyone else seeing this with latest release (3.0.1)? It doesn't re-link
with Program when building an executable.
env = Environment()
env.SharedLibrary('test', 'test1.c')
int foo(){ return 0; }
C:\Users\Daniel\workspace>scons -f SConstruct.py
scons: Reading SConscript files ...
scons: done reading SConscript files.
scons: Building targets ...
cl /Fotest1.obj /c test1.c /nologo
test1.c
link /nologo /dll /out:test.dll /implib:test.lib test1.obj
scons: done building targets.
If I run the same command again without changing anything, I get the link
C:\Users\Daniel\workspace>scons -f SConstruct.py
scons: Reading SConscript files ...
scons: done reading SConscript files.
scons: Building targets ...
link /nologo /dll /out:test.dll /implib:test.lib test1.obj
scons: done building targets.
Subsequent runs of the command produce the link again.
I have Visual Studio 2015 installed.
C:\Users\Daniel\workspace>scons -v
script: v3.0.1.74b2c53bc42290e911b334a6b44f187da698a668,
2017/11/14 13:16:53, by bdbaddog on hpmicrodog
engine: v3.0.1.74b2c53bc42290e911b334a6b44f187da698a668,
2017/11/14 13:16:53, by bdbaddog on hpmicrodog
['c:\\python36\\lib\\site-packages\\scons-3.0.1\\SCons']
Copyright (c) 2001 - 2017 The SCons Foundation
C:\Users\Daniel\workspace>python --version
Python 3.6.5
_______________________________________________
Scons-users mailing list
https://pairlist4.pair.net/mailman/listinfo/scons-users
--
Gary
Daniel Moody
2018-08-14 13:54:58 UTC
Permalink
Thanks, scons told me it wasn't building the import lib, this was because I
wasn't exporting any symbols with my example. Should scons know about this
case?
Post by Gary Oberbrunner
Hi Daniel; can you try with 'scons --debug=explain' ? That might show why
it thinks it needs to be rebuilt.
Post by Daniel Moody
Anyone else seeing this with latest release (3.0.1)? It doesn't re-link
with Program when building an executable.
env = Environment()
env.SharedLibrary('test', 'test1.c')
int foo(){ return 0; }
C:\Users\Daniel\workspace>scons -f SConstruct.py
scons: Reading SConscript files ...
scons: done reading SConscript files.
scons: Building targets ...
cl /Fotest1.obj /c test1.c /nologo
test1.c
link /nologo /dll /out:test.dll /implib:test.lib test1.obj
scons: done building targets.
If I run the same command again without changing anything, I get the link
C:\Users\Daniel\workspace>scons -f SConstruct.py
scons: Reading SConscript files ...
scons: done reading SConscript files.
scons: Building targets ...
link /nologo /dll /out:test.dll /implib:test.lib test1.obj
scons: done building targets.
Subsequent runs of the command produce the link again.
I have Visual Studio 2015 installed.
C:\Users\Daniel\workspace>scons -v
script: v3.0.1.74b2c53bc42290e911b334a6b44f187da698a668,
2017/11/14 13:16:53, by bdbaddog on hpmicrodog
engine: v3.0.1.74b2c53bc42290e911b334a6b44f187da698a668,
2017/11/14 13:16:53, by bdbaddog on hpmicrodog
['c:\\python36\\lib\\site-packages\\scons-3.0.1\\SCons']
Copyright (c) 2001 - 2017 The SCons Foundation
C:\Users\Daniel\workspace>python --version
Python 3.6.5
_______________________________________________
Scons-users mailing list
https://pairlist4.pair.net/mailman/listinfo/scons-users
--
Gary
_______________________________________________
Scons-users mailing list
https://pairlist4.pair.net/mailman/listinfo/scons-users
Bill Deegan
2018-08-14 14:08:20 UTC
Permalink
Also please try to reproduce with Python 2.7.x
Post by Daniel Moody
Thanks, scons told me it wasn't building the import lib, this was because
I wasn't exporting any symbols with my example. Should scons know about
this case?
Post by Gary Oberbrunner
Hi Daniel; can you try with 'scons --debug=explain' ? That might show why
it thinks it needs to be rebuilt.
Post by Daniel Moody
Anyone else seeing this with latest release (3.0.1)? It doesn't re-link
with Program when building an executable.
env = Environment()
env.SharedLibrary('test', 'test1.c')
int foo(){ return 0; }
C:\Users\Daniel\workspace>scons -f SConstruct.py
scons: Reading SConscript files ...
scons: done reading SConscript files.
scons: Building targets ...
cl /Fotest1.obj /c test1.c /nologo
test1.c
link /nologo /dll /out:test.dll /implib:test.lib test1.obj
scons: done building targets.
If I run the same command again without changing anything, I get the
C:\Users\Daniel\workspace>scons -f SConstruct.py
scons: Reading SConscript files ...
scons: done reading SConscript files.
scons: Building targets ...
link /nologo /dll /out:test.dll /implib:test.lib test1.obj
scons: done building targets.
Subsequent runs of the command produce the link again.
I have Visual Studio 2015 installed.
C:\Users\Daniel\workspace>scons -v
script: v3.0.1.74b2c53bc42290e911b334a6b44f187da698a668,
2017/11/14 13:16:53, by bdbaddog on hpmicrodog
engine: v3.0.1.74b2c53bc42290e911b334a6b44f187da698a668,
2017/11/14 13:16:53, by bdbaddog on hpmicrodog
engine path: ['c:\\python36\\lib\\site-
packages\\scons-3.0.1\\SCons']
Copyright (c) 2001 - 2017 The SCons Foundation
C:\Users\Daniel\workspace>python --version
Python 3.6.5
_______________________________________________
Scons-users mailing list
https://pairlist4.pair.net/mailman/listinfo/scons-users
--
Gary
_______________________________________________
Scons-users mailing list
https://pairlist4.pair.net/mailman/listinfo/scons-users
_______________________________________________
Scons-users mailing list
https://pairlist4.pair.net/mailman/listinfo/scons-users
Daniel Moody
2018-08-14 14:14:01 UTC
Permalink
Yeah I reproduced it with python 2.7, same results.
Post by Bill Deegan
Also please try to reproduce with Python 2.7.x
Post by Daniel Moody
Thanks, scons told me it wasn't building the import lib, this was because
I wasn't exporting any symbols with my example. Should scons know about
this case?
Post by Gary Oberbrunner
Hi Daniel; can you try with 'scons --debug=explain' ? That might show
why it thinks it needs to be rebuilt.
Post by Daniel Moody
Anyone else seeing this with latest release (3.0.1)? It doesn't re-link
with Program when building an executable.
env = Environment()
env.SharedLibrary('test', 'test1.c')
int foo(){ return 0; }
C:\Users\Daniel\workspace>scons -f SConstruct.py
scons: Reading SConscript files ...
scons: done reading SConscript files.
scons: Building targets ...
cl /Fotest1.obj /c test1.c /nologo
test1.c
link /nologo /dll /out:test.dll /implib:test.lib test1.obj
scons: done building targets.
If I run the same command again without changing anything, I get the
C:\Users\Daniel\workspace>scons -f SConstruct.py
scons: Reading SConscript files ...
scons: done reading SConscript files.
scons: Building targets ...
link /nologo /dll /out:test.dll /implib:test.lib test1.obj
scons: done building targets.
Subsequent runs of the command produce the link again.
I have Visual Studio 2015 installed.
C:\Users\Daniel\workspace>scons -v
script: v3.0.1.74b2c53bc42290e911b334a6b44f187da698a668,
2017/11/14 13:16:53, by bdbaddog on hpmicrodog
engine: v3.0.1.74b2c53bc42290e911b334a6b44f187da698a668,
2017/11/14 13:16:53, by bdbaddog on hpmicrodog
['c:\\python36\\lib\\site-packages\\scons-3.0.1\\SCons']
Copyright (c) 2001 - 2017 The SCons Foundation
C:\Users\Daniel\workspace>python --version
Python 3.6.5
_______________________________________________
Scons-users mailing list
https://pairlist4.pair.net/mailman/listinfo/scons-users
--
Gary
_______________________________________________
Scons-users mailing list
https://pairlist4.pair.net/mailman/listinfo/scons-users
_______________________________________________
Scons-users mailing list
https://pairlist4.pair.net/mailman/listinfo/scons-users
_______________________________________________
Scons-users mailing list
https://pairlist4.pair.net/mailman/listinfo/scons-users
Thomas Berg
2018-08-14 14:23:04 UTC
Permalink
SCons does not parse your code and check whether you are exporting any
symbols. But there is a flag you can set to tell scons not to expect a .lib
file to be generated:

env['no_import_lib'] = 1

I think this stops the rebuilding in your case.

Hope this helps,
Thomas
Post by Daniel Moody
Thanks, scons told me it wasn't building the import lib, this was because
I wasn't exporting any symbols with my example. Should scons know about
this case?
Post by Gary Oberbrunner
Hi Daniel; can you try with 'scons --debug=explain' ? That might show why
it thinks it needs to be rebuilt.
Post by Daniel Moody
Anyone else seeing this with latest release (3.0.1)? It doesn't re-link
with Program when building an executable.
env = Environment()
env.SharedLibrary('test', 'test1.c')
int foo(){ return 0; }
C:\Users\Daniel\workspace>scons -f SConstruct.py
scons: Reading SConscript files ...
scons: done reading SConscript files.
scons: Building targets ...
cl /Fotest1.obj /c test1.c /nologo
test1.c
link /nologo /dll /out:test.dll /implib:test.lib test1.obj
scons: done building targets.
If I run the same command again without changing anything, I get the
C:\Users\Daniel\workspace>scons -f SConstruct.py
scons: Reading SConscript files ...
scons: done reading SConscript files.
scons: Building targets ...
link /nologo /dll /out:test.dll /implib:test.lib test1.obj
scons: done building targets.
Subsequent runs of the command produce the link again.
I have Visual Studio 2015 installed.
C:\Users\Daniel\workspace>scons -v
script: v3.0.1.74b2c53bc42290e911b334a6b44f187da698a668,
2017/11/14 13:16:53, by bdbaddog on hpmicrodog
engine: v3.0.1.74b2c53bc42290e911b334a6b44f187da698a668,
2017/11/14 13:16:53, by bdbaddog on hpmicrodog
['c:\\python36\\lib\\site-packages\\scons-3.0.1\\SCons']
Copyright (c) 2001 - 2017 The SCons Foundation
C:\Users\Daniel\workspace>python --version
Python 3.6.5
_______________________________________________
Scons-users mailing list
https://pairlist4.pair.net/mailman/listinfo/scons-users
--
Gary
_______________________________________________
Scons-users mailing list
https://pairlist4.pair.net/mailman/listinfo/scons-users
_______________________________________________
Scons-users mailing list
https://pairlist4.pair.net/mailman/listinfo/scons-users
Daniel Moody
2018-08-14 14:35:44 UTC
Permalink
Thanks Thomas, that flag should be fine.
Post by Thomas Berg
SCons does not parse your code and check whether you are exporting any
symbols. But there is a flag you can set to tell scons not to expect a .lib
env['no_import_lib'] = 1
I think this stops the rebuilding in your case.
Hope this helps,
Thomas
Post by Daniel Moody
Thanks, scons told me it wasn't building the import lib, this was because
I wasn't exporting any symbols with my example. Should scons know about
this case?
Post by Gary Oberbrunner
Hi Daniel; can you try with 'scons --debug=explain' ? That might show
why it thinks it needs to be rebuilt.
Post by Daniel Moody
Anyone else seeing this with latest release (3.0.1)? It doesn't re-link
with Program when building an executable.
env = Environment()
env.SharedLibrary('test', 'test1.c')
int foo(){ return 0; }
C:\Users\Daniel\workspace>scons -f SConstruct.py
scons: Reading SConscript files ...
scons: done reading SConscript files.
scons: Building targets ...
cl /Fotest1.obj /c test1.c /nologo
test1.c
link /nologo /dll /out:test.dll /implib:test.lib test1.obj
scons: done building targets.
If I run the same command again without changing anything, I get the
C:\Users\Daniel\workspace>scons -f SConstruct.py
scons: Reading SConscript files ...
scons: done reading SConscript files.
scons: Building targets ...
link /nologo /dll /out:test.dll /implib:test.lib test1.obj
scons: done building targets.
Subsequent runs of the command produce the link again.
I have Visual Studio 2015 installed.
C:\Users\Daniel\workspace>scons -v
script: v3.0.1.74b2c53bc42290e911b334a6b44f187da698a668,
2017/11/14 13:16:53, by bdbaddog on hpmicrodog
engine: v3.0.1.74b2c53bc42290e911b334a6b44f187da698a668,
2017/11/14 13:16:53, by bdbaddog on hpmicrodog
['c:\\python36\\lib\\site-packages\\scons-3.0.1\\SCons']
Copyright (c) 2001 - 2017 The SCons Foundation
C:\Users\Daniel\workspace>python --version
Python 3.6.5
_______________________________________________
Scons-users mailing list
https://pairlist4.pair.net/mailman/listinfo/scons-users
--
Gary
_______________________________________________
Scons-users mailing list
https://pairlist4.pair.net/mailman/listinfo/scons-users
_______________________________________________
Scons-users mailing list
https://pairlist4.pair.net/mailman/listinfo/scons-users
_______________________________________________
Scons-users mailing list
https://pairlist4.pair.net/mailman/listinfo/scons-users
Bill Deegan
2018-08-14 14:38:42 UTC
Permalink
You can also do this:

env.SharedLibrary('test', 'test1.c', no_import_lib=1)
Post by Daniel Moody
Thanks Thomas, that flag should be fine.
Post by Thomas Berg
SCons does not parse your code and check whether you are exporting any
symbols. But there is a flag you can set to tell scons not to expect a .lib
env['no_import_lib'] = 1
I think this stops the rebuilding in your case.
Hope this helps,
Thomas
Post by Daniel Moody
Thanks, scons told me it wasn't building the import lib, this was
because I wasn't exporting any symbols with my example. Should scons know
about this case?
Post by Gary Oberbrunner
Hi Daniel; can you try with 'scons --debug=explain' ? That might show
why it thinks it needs to be rebuilt.
Post by Daniel Moody
Anyone else seeing this with latest release (3.0.1)? It doesn't
re-link with Program when building an executable.
env = Environment()
env.SharedLibrary('test', 'test1.c')
int foo(){ return 0; }
C:\Users\Daniel\workspace>scons -f SConstruct.py
scons: Reading SConscript files ...
scons: done reading SConscript files.
scons: Building targets ...
cl /Fotest1.obj /c test1.c /nologo
test1.c
link /nologo /dll /out:test.dll /implib:test.lib test1.obj
scons: done building targets.
If I run the same command again without changing anything, I get the
C:\Users\Daniel\workspace>scons -f SConstruct.py
scons: Reading SConscript files ...
scons: done reading SConscript files.
scons: Building targets ...
link /nologo /dll /out:test.dll /implib:test.lib test1.obj
scons: done building targets.
Subsequent runs of the command produce the link again.
I have Visual Studio 2015 installed.
C:\Users\Daniel\workspace>scons -v
script: v3.0.1.74b2c53bc42290e911b334a6b44f187da698a668,
2017/11/14 13:16:53, by bdbaddog on hpmicrodog
engine: v3.0.1.74b2c53bc42290e911b334a6b44f187da698a668,
2017/11/14 13:16:53, by bdbaddog on hpmicrodog
engine path: ['c:\\python36\\lib\\site-
packages\\scons-3.0.1\\SCons']
Copyright (c) 2001 - 2017 The SCons Foundation
C:\Users\Daniel\workspace>python --version
Python 3.6.5
_______________________________________________
Scons-users mailing list
https://pairlist4.pair.net/mailman/listinfo/scons-users
--
Gary
_______________________________________________
Scons-users mailing list
https://pairlist4.pair.net/mailman/listinfo/scons-users
_______________________________________________
Scons-users mailing list
https://pairlist4.pair.net/mailman/listinfo/scons-users
_______________________________________________
Scons-users mailing list
https://pairlist4.pair.net/mailman/listinfo/scons-users
_______________________________________________
Scons-users mailing list
https://pairlist4.pair.net/mailman/listinfo/scons-users
Loading...