Jump to page: 1 2
Thread overview
Windows 64
Oct 07, 2013
Casper Færgemand
Oct 07, 2013
Rainer Schuetze
Oct 07, 2013
Casper Færgemand
Oct 07, 2013
Rainer Schuetze
Oct 07, 2013
Casper Færgemand
Oct 07, 2013
Casper Færgemand
Oct 07, 2013
Casper Færgemand
Oct 07, 2013
Casper Færgemand
Oct 07, 2013
Casper Færgemand
Oct 07, 2013
Casper Færgemand
Oct 08, 2013
Rainer Schuetze
October 07, 2013
Hey, I've been trying for a while to compile 64 bit programs on a Windows 7 platform. The setup is the following:

Version: 2.063.2
OS: Windows 7 64
Linked: VS 11 64 bit linker

sc.ini:

[Version]
version=7.51 Build 020

[Environment]
LIB="%@P%\..\lib";\dm\lib
DFLAGS="-I%@P%\..\..\src\phobos" "-I%@P%\..\..\src\druntime\import"
LINKCMD=%@P%\link.exe
LINKCMD64=%VCINSTALLDIR%\bin\amd64\link.exe
VCINSTALLDIR=%VCINSTALLDIR%
WindowsSdkDir=%WindowsSdkDir%


Environment variables are as follows:

VCINSTALLDIR: C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\
WindowsSdkDir: C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\

(I had initially forgot a \ at the end of the environment variables)

On compiling the program "void main() {}" with -m64 -v in Eclipse with DDT (same result for command line), I get this thrown back:


--------  Build Commands:  --------
-od"bin"
-of"bin\temp.exe"

-I"src"

"src\temp.d"

-m64 -v

binary    C:\D\Tools\dmd2\windows\bin\dmd.exe
version   v2.063.2
config    C:\D\Tools\dmd2\windows\bin\sc.ini
parse     temp
importall temp
import    object	(C:\D\Tools\dmd2\windows\bin\..\..\src\druntime\import\object.di)
semantic  temp
entry     main      	src\temp.d
semantic2 temp
semantic3 temp
code      temp
function  D main
C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\bin\amd64\link.exe /NOLOGO "bin\temp" /OUT:"bin\temp.exe"  "/LIBPATH:C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\lib\amd64" "/LIBPATH:C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\lib\x64"
C:\D\Tools\dmd2\windows\bin\..\lib\shell32.lib : warning LNK4003: invalid library format; library ignored
C:\D\Tools\dmd2\windows\bin\..\lib\kernel32.lib : warning LNK4003: invalid library format; library ignored
C:\D\Tools\dmd2\windows\bin\..\lib\shell32.lib : warning LNK4003: invalid library format; library ignored
C:\D\Tools\dmd2\windows\bin\..\lib\kernel32.lib : warning LNK4003: invalid library format; library ignored
phobos64.lib(dmain2_480_47b.obj) : error LNK2019: unresolved external symbol IsDebuggerPresent referenced in function _d_run_main
LIBCMT.lib(a_map.obj) : error LNK2001: unresolved external symbol __imp_WideCharToMultiByte

...

bin\temp.exe : fatal error LNK1120: 103 unresolved externals
--- errorlevel 1120


I took the liberty of removing the mid section, since everything was LIBCMT.lib and phobos64.lib things that were unresolved. Any heads up on what I need to tinker with?
October 07, 2013

On 07.10.2013 03:31, "Casper Færgemand" <shorttail@hotmail.com>" wrote:
> Hey, I've been trying for a while to compile 64 bit programs on a
> Windows 7 platform. The setup is the following:
>
> Version: 2.063.2
> OS: Windows 7 64
> Linked: VS 11 64 bit linker
>
> sc.ini:
>
> [Version]
> version=7.51 Build 020
>
> [Environment]
> LIB="%@P%\..\lib";\dm\lib
> DFLAGS="-I%@P%\..\..\src\phobos" "-I%@P%\..\..\src\druntime\import"
> LINKCMD=%@P%\link.exe
> LINKCMD64=%VCINSTALLDIR%\bin\amd64\link.exe
> VCINSTALLDIR=%VCINSTALLDIR%
> WindowsSdkDir=%WindowsSdkDir%
>
>
> Environment variables are as follows:
>
> VCINSTALLDIR: C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\
> WindowsSdkDir: C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\
>
> (I had initially forgot a \ at the end of the environment variables)
>
> On compiling the program "void main() {}" with -m64 -v in Eclipse with
> DDT (same result for command line), I get this thrown back:
>
>
> --------  Build Commands:  --------
> -od"bin"
> -of"bin\temp.exe"
>
> -I"src"
>
> "src\temp.d"
>
> -m64 -v
>
> binary    C:\D\Tools\dmd2\windows\bin\dmd.exe
> version   v2.063.2
> config    C:\D\Tools\dmd2\windows\bin\sc.ini
> parse     temp
> importall temp
> import object
> (C:\D\Tools\dmd2\windows\bin\..\..\src\druntime\import\object.di)
> semantic  temp
> entry     main          src\temp.d
> semantic2 temp
> semantic3 temp
> code      temp
> function  D main
> C:\Program Files (x86)\Microsoft Visual Studio
> 11.0\VC\bin\amd64\link.exe /NOLOGO "bin\temp" /OUT:"bin\temp.exe"
>   "/LIBPATH:C:\Program Files (x86)\Microsoft Visual Studio
> 11.0\VC\lib\amd64" "/LIBPATH:C:\Program Files (x86)\Microsoft
> SDKs\Windows\v7.0A\lib\x64"
> C:\D\Tools\dmd2\windows\bin\..\lib\shell32.lib : warning LNK4003:
> invalid library format; library ignored
> C:\D\Tools\dmd2\windows\bin\..\lib\kernel32.lib : warning LNK4003:
> invalid library format; library ignored
> C:\D\Tools\dmd2\windows\bin\..\lib\shell32.lib : warning LNK4003:
> invalid library format; library ignored
> C:\D\Tools\dmd2\windows\bin\..\lib\kernel32.lib : warning LNK4003:
> invalid library format; library ignored
> phobos64.lib(dmain2_480_47b.obj) : error LNK2019: unresolved external
> symbol IsDebuggerPresent referenced in function _d_run_main
> LIBCMT.lib(a_map.obj) : error LNK2001: unresolved external symbol
> __imp_WideCharToMultiByte
>
> ...
>
> bin\temp.exe : fatal error LNK1120: 103 unresolved externals
> --- errorlevel 1120
>
>
> I took the liberty of removing the mid section, since everything was
> LIBCMT.lib and phobos64.lib things that were unresolved. Any heads up on
> what I need to tinker with?

The linker does not find the import libraries from the Windows SDK, so it hits the 32-bit libraries that come with dmd.

The released sc.ini does not work with VS2012+ or a Windows SDK 8, you should add the following lines to it:

[Environment64]
LIB=%@P%\..\lib;%VCINSTALLDIR%\lib\amd64;%WindowsSdkDir%\Lib\win8\um\x64
;; for some additional improvements
PATH=%PATH%;%VCINSTALLDIR%\bin\x86_amd64;%VCINSTALLDIR%\..\Common7\IDE
DFLAGS=%DFLAGS% -L/OPT:NOICF

October 07, 2013
On Monday, 7 October 2013 at 07:03:39 UTC, Rainer Schuetze wrote:
> The linker does not find the import libraries from the Windows SDK, so it hits the 32-bit libraries that come with dmd.
>
> The released sc.ini does not work with VS2012+ or a Windows SDK 8, you should add the following lines to it:
>
> [Environment64]
> LIB=%@P%\..\lib;%VCINSTALLDIR%\lib\amd64;%WindowsSdkDir%\Lib\win8\um\x64
> ;; for some additional improvements
> PATH=%PATH%;%VCINSTALLDIR%\bin\x86_amd64;%VCINSTALLDIR%\..\Common7\IDE
> DFLAGS=%DFLAGS% -L/OPT:NOICF

Thank you. I added the lines and I'm still getting the same 103 unresolved externals. Commenting out stuff in the file makes dmd throws other errors, so I'm sure I'm editing the correct sc.ini.
Where are the correct libraries supposed to be exactly?
October 07, 2013

On 07.10.2013 12:21, "Casper Færgemand" <shorttail@hotmail.com>" wrote:
> On Monday, 7 October 2013 at 07:03:39 UTC, Rainer Schuetze wrote:
>> The linker does not find the import libraries from the Windows SDK, so
>> it hits the 32-bit libraries that come with dmd.
>>
>> The released sc.ini does not work with VS2012+ or a Windows SDK 8, you
>> should add the following lines to it:
>>
>> [Environment64]
>> LIB=%@P%\..\lib;%VCINSTALLDIR%\lib\amd64;%WindowsSdkDir%\Lib\win8\um\x64
>> ;; for some additional improvements
>> PATH=%PATH%;%VCINSTALLDIR%\bin\x86_amd64;%VCINSTALLDIR%\..\Common7\IDE
>> DFLAGS=%DFLAGS% -L/OPT:NOICF
>
> Thank you. I added the lines and I'm still getting the same 103
> unresolved externals. Commenting out stuff in the file makes dmd throws
> other errors, so I'm sure I'm editing the correct sc.ini.
> Where are the correct libraries supposed to be exactly?

Maybe the WindowsSdkDir environment variable is not set in your console. For the Windows 8 SDK, the standard location of the x64 libraries is

"c:\Program Files (x86)\Windows Kits\8.0\Lib\win8\um\x64"

for the Windows 7 SDK or previous (replace the version):

"c:\Program Files (x86)\Microsoft SDKs\Windows\v7.1A\Lib\x64"

so the entry with expanded environment variables on my system using VS 2012 and Windows SDK 8 is:

LIB=%@P%\..\lib;"c:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\lib\amd64";"c:\Program Files (x86)\Windows Kits\8.0\Lib\win8\um\x64"

I don't think the quotes are necessary, but the original sc.ini has them, too.
October 07, 2013
On Monday, 7 October 2013 at 17:48:13 UTC, Rainer Schuetze wrote:
> Maybe the WindowsSdkDir environment variable is not set in your console. For the Windows 8 SDK, the standard location of the x64 libraries is
>
> "c:\Program Files (x86)\Windows Kits\8.0\Lib\win8\um\x64"
>
> for the Windows 7 SDK or previous (replace the version):
>
> "c:\Program Files (x86)\Microsoft SDKs\Windows\v7.1A\Lib\x64"
>
> so the entry with expanded environment variables on my system using VS 2012 and Windows SDK 8 is:
>
> LIB=%@P%\..\lib;"c:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\lib\amd64";"c:\Program Files (x86)\Windows Kits\8.0\Lib\win8\um\x64"
>
> I don't think the quotes are necessary, but the original sc.ini has them, too.
When I run %WindowsSdkDir% from the start menu I end up in the v7.0A folder, so the path seems correct.

I have v7.0A, but there is no x64 folder in the Lib folder.
In fact, I get the same 103 unresolved dependencies even if I change the name of the Lib folder to Lib2, so presumably I never get that far in the linking that it reaches the directory?
What exactly does it need from WinSDK to link? Does it need anything if the program is simply void main() {}?
October 07, 2013
I have four folders in the SDK folder: v7.0A, v7.1, v8.0 and v8.0A. The latter three contain nothing but a few files, presumably installed by VS 11 or something else. I'm currently trying to install v7.1.
October 07, 2013
A lot of deleted posts and a lot of stupid later, v7.1 SDK is apparently installed in Program Files and not Program Files (x86). Kinda obvious given the names of said folders, but whatever. x.x

The x64 version does indeed have an x64 folder in the Lib folder. However, all that aside, still the same 103 unresolved externals.
October 07, 2013
More searching suggests all the unresolved external symbols are found in the lib files in v7.1\Lib\x64\
I'm guessing the linker doesn't know this. Any easy way to tell it where to look? Does the linker have an include folder? I tried with -LPATH"%WindowsSdkDir%\Lib\x64" as well as -L+"C:\Program Files\Microsoft SDKs\Windows\v7.1\Lib\x64\ShLwApi" (one of the files mentioned in a search result), however they failed since D doesn't recognize spaces in paths. "cannot open file '+C:\Program.obj"

Any clue on what I'm doing wrong? Any correct way to tell the linker where it can find stuff?
October 07, 2013
Okay, it's definitely a problem with dmd passing something bad to link. I was able to link it manually and the program was working fine.

import std.stdio;

void main() {
	writeln("Hello Linker!");
}

I ran "dmd -m64 test.d". The usual errors were dumped in the terminal. I then ran "link test.obj @lala.txt", with lala.txt containing the following:

C:\D\Tools\dmd2\windows\lib\phobos64.lib
"C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\lib\amd64\LIBCMT.lib"
"C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\lib\amd64\oldnames.lib"
"C:\Program Files\Microsoft SDKs\Windows\v7.1\Lib\x64\shell32.lib"
"C:\Program Files\Microsoft SDKs\Windows\v7.1\Lib\x64\kernel32.lib"

After adding the five lines one by one, the linking succeeded and test.exe outputted "Hello Linker!".


So, how do I not link it manually? It's sorta acceptable for small things, but I want DDT and Eclipse to do it automatically.
October 07, 2013
And I'm done. The problem was this:
LIB=%@P%\..\lib;%VCINSTALLDIR%\lib\amd64;%WindowsSdkDir%\Lib\x64
The lib folder linked first contains kernel32.lib and shell32.lib. Removing both made -m64 possible, but killed -m32. Changing it to this:
LIB=%VCINSTALLDIR%\lib\amd64;%WindowsSdkDir%\Lib\x64;%@P%\..\lib
solved everything. Now the dmd lib is checked last, when the real kernel32 and shell32 have already been found.

Well that only took half a year. ~~ Thanks for the help.
« First   ‹ Prev
1 2