x64 Link Issues - Can someone please help?

Trey Brisbane tbrisbane at hotmail.com
Thu Apr 18 17:24:25 PDT 2013


Hey all,

I'm currently using D for a hook-based project that requires me 
to build both a 32bit and 64bit DLL. Naturally, the 32bit DLL 
builds fine, however I'm encountering linking issues for the 
64bit.
I followed the instructions at 
http://wiki.dlang.org/Installing_DMD_on_64-bit_Windows_7_(COFF-compatible) 
for setting up 64bit building (albeit I didn't use his 
environment variables - I just put the paths into sc.ini 
directly), so if there's a problem with my setup, I don't see it.

Here is my build output (I'm using Xamarin Studio with Mono-D, if 
that means anything):

---------------------------------------------------------------------------

Building: HookLib (Debug|x64)

Performing main compilation...

Current dictionary: 
C:\Development\Projects\EyefinityMaximizer\HookLib

dmd.exe -debug -gc "main.d" 
"C:\Development\Projects\EyefinityMaximizer\EyefinityMaximizer\eyemax\WinAPI.d" 
"HookLib.def" "user32.lib" 
"-IC:\Development\Compilers\D\dmd2\src\phobos" 
"-IC:\Development\Compilers\D\dmd2\src\druntime\src" 
"-L/IMPLIB:C:\Development\Projects\EyefinityMaximizer\bin\Debug\HookLib.x64.lib" 
"-odobj\Debug" 
"-ofC:\Development\Projects\EyefinityMaximizer\bin\Debug\HookLib.x64.dll" 
-m64

HookLib.def(1) : warning LNK4017: EXETYPE statement not supported 
for the target platform; ignored

HookLib.def(2) : warning LNK4017: SUBSYSTEM statement not 
supported for the target platform; ignored

HookLib.x64.obj : warning LNK4197: export 'CallWndProc' specified 
multiple times; using first specification

    Creating library 
C:\Development\Projects\EyefinityMaximizer\bin\Debug\HookLib.x64.lib 
and object 
C:\Development\Projects\EyefinityMaximizer\bin\Debug\HookLib.x64.exp

phobos64.lib(dmain2_4ac_1a5.obj) : error LNK2019: unresolved 
external symbol _Dmain referenced in function main

C:\Development\Projects\EyefinityMaximizer\bin\Debug\HookLib.x64.dll 
: fatal error LNK1120: 1 unresolved externals

--- errorlevel 1120

Exit code 1120

Build complete -- 1 error, 0 warnings

---------------------------------------------------------------------------

As you can see, there appears to be an issue with my usage of 
WinMain() as opposed to just main(). For 32bit building, the 
documentation states that the compiler recognizes WinMain and 
works accordingly - is this also the case for 64bit building?

Here is my WinMain function, in case I'm doing something wrong 
with it:

---------------------------------------------------------------------------

extern(Windows) int WinMain(HINSTANCE hInstance, HINSTANCE 
hPrevInstance, LPSTR lpCmdLine, int iCmdShow) {
	int result;
	void exceptionHandler(Throwable e) { throw e; }

	// Init the D runtime
	try {
		Runtime.initialize(&exceptionHandler);
		result = myWinMain(hInstance, hPrevInstance, lpCmdLine, 
iCmdShow);
		Runtime.terminate(&exceptionHandler);
	} catch (Throwable e) {
		MessageBoxA(null, e.toString().toStringz, "Error", MB_OK | 
MB_ICONEXCLAMATION);
		result = 0;
	}
	
	return result;
}

---------------------------------------------------------------------------

Any assistance would be appreciated, as this project is stalled 
until I can build 64bit binaries.

Thanks and regards,
Trey


More information about the Digitalmars-d mailing list