www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - dmd linker and compiler

reply "Frustrated" <c1514843 drdrb.com> writes:
I had an old dmd2 setup that worked perfectly. I recently 
installed VS2013, SDK 8, DMD 2.064.2, and VS 3.37 on a fresh 
system.

I copied the project to the HD, updated the sc.ini files and 
tried to compile. Basic projects would compile but my old 
projects would give errors either:

user32.lib not found when trying to use optilink. I spend about 2 
hours trying various ways to get it to find the user32.lib file. 
It will only look in the project dir. I setup `LIB=` in 
environment in sc.ini with no luck.

In x64 mode, the linker gives an error that dmd.obj could not be 
found. There is no such thing as dmd.obj and I have no idea why 
it is finding this. It could be an issue with visual.d but I see 
no where that it says anything about dmd.obj.

I can't get my old projects to compile. Not that it matters, but 
here is my sc.ini file.

The project seems to compile file but simply won't link because 
of the above 2 issues.


[Version]
version=7.51 Build 020


; environment for both 32/64 bit
[Environment]
WindowsSdkDir=C:\Program Files (x86)\Windows Kits\8.1\Lib\win8\um
VCINSTALLDIR=D:\Apps\Technical\VS2013\VC\
DFLAGS=-L/nologo "-I% P%\..\..\src\phobos" 
"-I% P%\..\..\src\druntime\import" "-ID:\DLang\Lib"
LIB="% P%\..\lib"

[Environment32]
LIB="%WindowsSdkDir%\x86"
; LIB="% P%\..\lib"
PATH=%PATH%;%VCINSTALLDIR%\bin\x86;%VCINSTALLDIR%\..\Common7\IDE;"%WindowsSdkDir%\x86";
LINKCMD=% P%\link.exe


[Environment64]
DFLAGS=%DFLAGS% -L/OPT:NOICF
LIB="%WindowsSdkDir%\x64";"% P%\..\lib64"
PATH=%PATH%;%VCINSTALLDIR%\bin\amd64;%VCINSTALLDIR%\..\Common7\IDE;"%WindowsSdkDir%\x64";
LINKCMD=%VCINSTALLDIR%\bin\amd64\link.exe
Nov 25 2013
next sibling parent reply "Jeremy DeHaan" <dehaan.jeremiah gmail.com> writes:
On Monday, 25 November 2013 at 13:49:58 UTC, Frustrated wrote:
 I had an old dmd2 setup that worked perfectly. I recently 
 installed VS2013, SDK 8, DMD 2.064.2, and VS 3.37 on a fresh 
 system.

 I copied the project to the HD, updated the sc.ini files and 
 tried to compile. Basic projects would compile but my old 
 projects would give errors either:

 user32.lib not found when trying to use optilink. I spend about 
 2 hours trying various ways to get it to find the user32.lib 
 file. It will only look in the project dir. I setup `LIB=` in 
 environment in sc.ini with no luck.

 In x64 mode, the linker gives an error that dmd.obj could not 
 be found. There is no such thing as dmd.obj and I have no idea 
 why it is finding this. It could be an issue with visual.d but 
 I see no where that it says anything about dmd.obj.

 I can't get my old projects to compile. Not that it matters, 
 but here is my sc.ini file.

 The project seems to compile file but simply won't link because 
 of the above 2 issues.


 [Version]
 version=7.51 Build 020


 ; environment for both 32/64 bit
 [Environment]
 WindowsSdkDir=C:\Program Files (x86)\Windows 
 Kits\8.1\Lib\win8\um
 VCINSTALLDIR=D:\Apps\Technical\VS2013\VC\
 DFLAGS=-L/nologo "-I% P%\..\..\src\phobos" 
 "-I% P%\..\..\src\druntime\import" "-ID:\DLang\Lib"
 LIB="% P%\..\lib"

 [Environment32]
 LIB="%WindowsSdkDir%\x86"
 ; LIB="% P%\..\lib"
 PATH=%PATH%;%VCINSTALLDIR%\bin\x86;%VCINSTALLDIR%\..\Common7\IDE;"%WindowsSdkDir%\x86";
 LINKCMD=% P%\link.exe


 [Environment64]
 DFLAGS=%DFLAGS% -L/OPT:NOICF
 LIB="%WindowsSdkDir%\x64";"% P%\..\lib64"
 PATH=%PATH%;%VCINSTALLDIR%\bin\amd64;%VCINSTALLDIR%\..\Common7\IDE;"%WindowsSdkDir%\x64";
 LINKCMD=%VCINSTALLDIR%\bin\amd64\link.exe
I have yet to use DMD64 on Windows, but I can tell you that user32.lib should be in the DMC lib directory. In my Environment settings, the LIB line looks like this: LIB="% P%\..\lib";\dm\lib Maybe try that and see if it works?
Nov 25 2013
parent reply "Frustrated" <c1514843 drdrb.com> writes:
On Monday, 25 November 2013 at 17:44:43 UTC, Jeremy DeHaan wrote:
 On Monday, 25 November 2013 at 13:49:58 UTC, Frustrated wrote:
 I had an old dmd2 setup that worked perfectly. I recently 
 installed VS2013, SDK 8, DMD 2.064.2, and VS 3.37 on a fresh 
 system.

 I copied the project to the HD, updated the sc.ini files and 
 tried to compile. Basic projects would compile but my old 
 projects would give errors either:

 user32.lib not found when trying to use optilink. I spend 
 about 2 hours trying various ways to get it to find the 
 user32.lib file. It will only look in the project dir. I setup 
 `LIB=` in environment in sc.ini with no luck.

 In x64 mode, the linker gives an error that dmd.obj could not 
 be found. There is no such thing as dmd.obj and I have no idea 
 why it is finding this. It could be an issue with visual.d but 
 I see no where that it says anything about dmd.obj.

 I can't get my old projects to compile. Not that it matters, 
 but here is my sc.ini file.

 The project seems to compile file but simply won't link 
 because of the above 2 issues.


 [Version]
 version=7.51 Build 020


 ; environment for both 32/64 bit
 [Environment]
 WindowsSdkDir=C:\Program Files (x86)\Windows 
 Kits\8.1\Lib\win8\um
 VCINSTALLDIR=D:\Apps\Technical\VS2013\VC\
 DFLAGS=-L/nologo "-I% P%\..\..\src\phobos" 
 "-I% P%\..\..\src\druntime\import" "-ID:\DLang\Lib"
 LIB="% P%\..\lib"

 [Environment32]
 LIB="%WindowsSdkDir%\x86"
 ; LIB="% P%\..\lib"
 PATH=%PATH%;%VCINSTALLDIR%\bin\x86;%VCINSTALLDIR%\..\Common7\IDE;"%WindowsSdkDir%\x86";
 LINKCMD=% P%\link.exe


 [Environment64]
 DFLAGS=%DFLAGS% -L/OPT:NOICF
 LIB="%WindowsSdkDir%\x64";"% P%\..\lib64"
 PATH=%PATH%;%VCINSTALLDIR%\bin\amd64;%VCINSTALLDIR%\..\Common7\IDE;"%WindowsSdkDir%\x64";
 LINKCMD=%VCINSTALLDIR%\bin\amd64\link.exe
I have yet to use DMD64 on Windows, but I can tell you that user32.lib should be in the DMC lib directory. In my Environment settings, the LIB line looks like this: LIB="% P%\..\lib";\dm\lib Maybe try that and see if it works?
Nope. In any case that was one of the original ways and it didn't work, even when I put it as the hard path. Optilink doesn't even look for the lib in dm\lib. I've used process monitor to see what it's doing and it only looks for the lib in the project dir regardless of where I tell it to in sc.ini.
Nov 25 2013
next sibling parent "Frustrated" <c1514843 drdrb.com> writes:
I think I remember when setting up Visual D I went in and had to 
add some path to the library folders or something. Maybe that has 
to do with it?

The issue only happens when I import the library I've created 
into the project so it probably is a configuration issue within 
Visual D.

e.g., Create a new console project hello world. Builds fine. Drag 
and drop my library into the project for editing, link error 
can't fine user32.lib/dmd.obj.

These are the exact errors I get

OPTLINK : Warning 183: Extension not .RES : 
Win32\RTest1.build.lnkarg
user32.lib(0) : Error 2: File Not Found user32.lib

Looking at the build log the best I can tell is Visual D is for 
some reason inserting user32.lib and other wrong things into the 
command line for some reason.

Invalid path below and user32.lib linked without qualified path. 
Why or who is creating it like this is beyond me. There is 
nothing in the visual studio/D configuration properties of the 
project that has anything but the defaults set as far as I can 
tell.


set PATH=D:\Dlang\dmd2\windows\\bin;C:\Program Files 
(x86)\Microsoft SDKs\Windows\v7.0A\\\bin;%PATH%

set LIB="C:\Program Files (x86)\Windows Kits\8.1\Lib\win8\um\x86"
echo. > D:\DLang\Projects\Tests\RTest1\RTest1\Debug DMD 
Win32\RTest1.build.lnkarg
echo "Debug DMD Win32\RTest1.obj","Debug DMD 
Win32\RTest1.exe_cv","Debug DMD Win32\RTest1.map",user32.lib+ >> 
D:\DLang\Projects\Tests\RTest1\RTest1\Debug DMD 
Win32\RTest1.build.lnkarg
echo kernel32.lib/NOMAP/CO/NOI /nologo >> 
D:\DLang\Projects\Tests\RTest1\RTest1\Debug DMD 
Win32\RTest1.build.lnkarg
Nov 25 2013
prev sibling next sibling parent reply "Frustrated" <c1514843 drdrb.com> writes:
I think I remember when setting up Visual D I went in and had to 
add some path to the library folders or something. Maybe that has 
to do with it?

The issue only happens when I import the library I've created 
into the project so it probably is a configuration issue within 
Visual D.

e.g., Create a new console project hello world. Builds fine. Drag 
and drop my library into the project for editing, link error 
can't fine user32.lib/dmd.obj.

These are the exact errors I get

OPTLINK : Warning 183: Extension not .RES : 
Win32\RTest1.build.lnkarg
user32.lib(0) : Error 2: File Not Found user32.lib

Looking at the build log the best I can tell is Visual D is for 
some reason inserting user32.lib and other wrong things into the 
command line for some reason.

Invalid path below and user32.lib linked without qualified path. 
Why or who is creating it like this is beyond me. There is 
nothing in the visual studio/D configuration properties of the 
project that has anything but the defaults set as far as I can 
tell.


set PATH=D:\Dlang\dmd2\windows\\bin;C:\Program Files 
(x86)\Microsoft SDKs\Windows\v7.0A\\\bin;%PATH%

set LIB="C:\Program Files (x86)\Windows Kits\8.1\Lib\win8\um\x86"
echo. > D:\DLang\Projects\Tests\RTest1\RTest1\Debug DMD 
Win32\RTest1.build.lnkarg
echo "Debug DMD Win32\RTest1.obj","Debug DMD 
Win32\RTest1.exe_cv","Debug DMD Win32\RTest1.map",user32.lib+ >> 
D:\DLang\Projects\Tests\RTest1\RTest1\Debug DMD 
Win32\RTest1.build.lnkarg
echo kernel32.lib/NOMAP/CO/NOI /nologo >> 
D:\DLang\Projects\Tests\RTest1\RTest1\Debug DMD 
Win32\RTest1.build.lnkarg


It seems to be some issue with visual d because pipedmd also has 
problems. It looks like some stuff is hard coded, left out, or is 
simply wrong in the build script.

What a pain in the ass...  The only real difference between the 
two is that I'm using the latest dmd, visual D, and visual studio.
Nov 25 2013
parent Rainer Schuetze <r.sagitario gmx.de> writes:
On 25.11.2013 22:01, Frustrated wrote:
 set PATH=D:\Dlang\dmd2\windows\\bin;C:\Program Files (x86)\Microsoft
 SDKs\Windows\v7.0A\\\bin;%PATH%

 set LIB="C:\Program Files (x86)\Windows Kits\8.1\Lib\win8\um\x86"
 echo. > D:\DLang\Projects\Tests\RTest1\RTest1\Debug DMD
 Win32\RTest1.build.lnkarg
 echo "Debug DMD Win32\RTest1.obj","Debug DMD Win32\RTest1.exe_cv","Debug
 DMD Win32\RTest1.map",user32.lib+ >>
 D:\DLang\Projects\Tests\RTest1\RTest1\Debug DMD Win32\RTest1.build.lnkarg
 echo kernel32.lib/NOMAP/CO/NOI /nologo >>
 D:\DLang\Projects\Tests\RTest1\RTest1\Debug DMD Win32\RTest1.build.lnkarg
There seem to be quotes missing around the lnkarg file, it contains spaces in the configuration name.
Nov 25 2013
prev sibling parent reply "Frustrated" <c1514843 drdrb.com> writes:
On Monday, 25 November 2013 at 20:09:20 UTC, Frustrated wrote:
 On Monday, 25 November 2013 at 17:44:43 UTC, Jeremy DeHaan 
 wrote:
 On Monday, 25 November 2013 at 13:49:58 UTC, Frustrated wrote:
 I had an old dmd2 setup that worked perfectly. I recently 
 installed VS2013, SDK 8, DMD 2.064.2, and VS 3.37 on a fresh 
 system.

 I copied the project to the HD, updated the sc.ini files and 
 tried to compile. Basic projects would compile but my old 
 projects would give errors either:

 user32.lib not found when trying to use optilink. I spend 
 about 2 hours trying various ways to get it to find the 
 user32.lib file. It will only look in the project dir. I 
 setup `LIB=` in environment in sc.ini with no luck.

 In x64 mode, the linker gives an error that dmd.obj could not 
 be found. There is no such thing as dmd.obj and I have no 
 idea why it is finding this. It could be an issue with 
 visual.d but I see no where that it says anything about 
 dmd.obj.

 I can't get my old projects to compile. Not that it matters, 
 but here is my sc.ini file.

 The project seems to compile file but simply won't link 
 because of the above 2 issues.


 [Version]
 version=7.51 Build 020


 ; environment for both 32/64 bit
 [Environment]
 WindowsSdkDir=C:\Program Files (x86)\Windows 
 Kits\8.1\Lib\win8\um
 VCINSTALLDIR=D:\Apps\Technical\VS2013\VC\
 DFLAGS=-L/nologo "-I% P%\..\..\src\phobos" 
 "-I% P%\..\..\src\druntime\import" "-ID:\DLang\Lib"
 LIB="% P%\..\lib"

 [Environment32]
 LIB="%WindowsSdkDir%\x86"
 ; LIB="% P%\..\lib"
 PATH=%PATH%;%VCINSTALLDIR%\bin\x86;%VCINSTALLDIR%\..\Common7\IDE;"%WindowsSdkDir%\x86";
 LINKCMD=% P%\link.exe


 [Environment64]
 DFLAGS=%DFLAGS% -L/OPT:NOICF
 LIB="%WindowsSdkDir%\x64";"% P%\..\lib64"
 PATH=%PATH%;%VCINSTALLDIR%\bin\amd64;%VCINSTALLDIR%\..\Common7\IDE;"%WindowsSdkDir%\x64";
 LINKCMD=%VCINSTALLDIR%\bin\amd64\link.exe
I have yet to use DMD64 on Windows, but I can tell you that user32.lib should be in the DMC lib directory. In my Environment settings, the LIB line looks like this: LIB="% P%\..\lib";\dm\lib Maybe try that and see if it works?
Nope. In any case that was one of the original ways and it didn't work, even when I put it as the hard path. Optilink doesn't even look for the lib in dm\lib. I've used process monitor to see what it's doing and it only looks for the lib in the project dir regardless of where I tell it to in sc.ini.
I was able to solve the x86 issue as it seems
 WindowsSdkDir=C:\Program Files (x86)\Windows 
 Kits\8.1\Lib\win8\um
should have been 8.0 as the path is different for 8.1. I still get the same issue for x64 though. Not sure where it is getting dmd.obj at(not sure if it's the obj file for the project or something else).
Nov 25 2013
parent Rainer Schuetze <r.sagitario gmx.de> writes:
On 26.11.2013 01:24, Frustrated wrote:
 WindowsSdkDir=C:\Program Files (x86)\Windows Kits\8.1\Lib\win8\um
should have been 8.0 as the path is different for 8.1.
Unfortunately the D installer and the latest Visual D were not tested against the 8.1 SDK, and Microsoft changed their mind again about how folders are named.
 I still get the same issue for x64 though. Not sure where it is getting
 dmd.obj at(not sure if it's the obj file for the project or some
I noticed that there are also problems with spaces for the library settings on the "DMD directories" page, but the default is set to the expanded SDK library path. Please try replacing it with $(WindowsSdkDir)\lib\win8\um.
Nov 26 2013
prev sibling parent Rainer Schuetze <r.sagitario gmx.de> writes:
On 25.11.2013 14:49, Frustrated wrote:
 I had an old dmd2 setup that worked perfectly. I recently installed
 VS2013, SDK 8, DMD 2.064.2, and VS 3.37 on a fresh system.

 I copied the project to the HD, updated the sc.ini files and tried to
 compile. Basic projects would compile but my old projects would give
 errors either:

 user32.lib not found when trying to use optilink. I spend about 2 hours
 trying various ways to get it to find the user32.lib file. It will only
 look in the project dir. I setup `LIB=` in environment in sc.ini with no
 luck.

 In x64 mode, the linker gives an error that dmd.obj could not be found.
 There is no such thing as dmd.obj and I have no idea why it is finding
 this. It could be an issue with visual.d but I see no where that it says
 anything about dmd.obj.
Please check the output in the build log, it contains the actually executed command line.
 I can't get my old projects to compile. Not that it matters, but here is
 my sc.ini file.

 The project seems to compile file but simply won't link because of the
 above 2 issues.
Please also check the settings in Visual Studio under "Tools->Options->Project and solutions->Visual D->DMD Directories". Depending on the settings there, sc.ini might get ignored.
 [Version]
 version=7.51 Build 020


 ; environment for both 32/64 bit
 [Environment]
 WindowsSdkDir=C:\Program Files (x86)\Windows Kits\8.1\Lib\win8\um
 VCINSTALLDIR=D:\Apps\Technical\VS2013\VC\
 DFLAGS=-L/nologo "-I% P%\..\..\src\phobos"
 "-I% P%\..\..\src\druntime\import" "-ID:\DLang\Lib"
 LIB="% P%\..\lib"

 [Environment32]
 LIB="%WindowsSdkDir%\x86"
 ; LIB="% P%\..\lib"
You must use the LIB="% P%\..\lib" line, the lib folder also contains user32.lib in the format appropriate for optlink. The Windows SDK contains libraries in COFF format that optlink does not understand. (Search for coffimplib to find a converter tool.)
 PATH=%PATH%;%VCINSTALLDIR%\bin\x86;%VCINSTALLDIR%\..\Common7\IDE;"%WindowsSdkDir%\x86";

 LINKCMD=% P%\link.exe


 [Environment64]
 DFLAGS=%DFLAGS% -L/OPT:NOICF
 LIB="%WindowsSdkDir%\x64";"% P%\..\lib64"
 PATH=%PATH%;%VCINSTALLDIR%\bin\amd64;%VCINSTALLDIR%\..\Common7\IDE;"%WindowsSdkDir%\x64";

 LINKCMD=%VCINSTALLDIR%\bin\amd64\link.exe
Nov 25 2013