[Scons-users] .def file generation issue with SCons

Mats Wichmann mats at wichmann.us
Fri Jul 9 11:04:48 EDT 2021


On 7/8/21 9:13 PM, Sumit Kothari wrote:
> Hi,
> 
> I am facing an issue while generating .def file using SCons. I created 
> simple f1.c file and Sconstruct file as mentioned below.
> 
> f1.c
> 
> ===
> 
> int fun()
> {
>      int i=10;
>      i++;
> 
>      return i;
> }
> 
> Sconstruct
> 
> =======
> 
> env = Environment()
> 
> 
> env['WIN32_INSERT_DEF']=1
> 
> env['WINDOWS_INSERT_DEF']=1
> 
> env.SharedLibrary('f1', source = ['f1.c'], 
> WINDOWS_INSERT_DEF=1,WIN32_INSERT_DEF=1)
> 
> Error message
> 
> =========
>   
> scons: *** [f1.dll] Source `f1.def' not found, needed by target `f1.dll'.
> 
> As per scons doc, it should create .def file but I am getting error. Can 
> you please give some hints on this.


Took a look, best I can tell in the code this isn't intended to 
*generate* the .def file, but rather to add a .def file based on the dll 
name to the list of sources so you don't have to specify it manually 
(which would be a pain for portable builds expected to work on 
non-Windows as well, where module-definition files of this type are not 
used).  The manpage entry says what you mention, but seems (to my look 
at least) to be wrong.


=== internal details, feel free to ignore:

Only the windows-native and the mingw linkers touch this, the former 
does only this:

         extrasources.append(
             env.ReplaceIxes(dll,
                             '%sPREFIX' % paramtp, '%sSUFFIX' % paramtp,
                             "WINDOWSDEFPREFIX", "WINDOWSDEFSUFFIX"))

later, the mslink tool scans the sources and if it finds what looks like 
a .def file it then adds the proper syntax to the actual link line with 
/def:xxx

while the mingw one just adds it directly to the cmdline options using 
the proper syntax.


More information about the Scons-users mailing list