x64 Link Issues - Can someone please help?

Trey Brisbane tbrisbane at hotmail.com
Thu Apr 18 23:05:23 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
DLLMain() as opposed to just main(). For 32bit building, the
documentation states that the compiler recognizes DLLMain and
works accordingly - is this also the case for 64bit building?

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

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

extern (Windows) BOOL DllMain(HINSTANCE hInstance, ULONG
ulReason, LPVOID pvReserved) {
	// Main DLL switch
	switch (ulReason) {
		case DLL_PROCESS_ATTACH:
			g_hInst = hInstance;
			dll_process_attach( hInstance, true );
			break;
		case DLL_PROCESS_DETACH:
			dll_process_detach( hInstance, true );
			break;
		case DLL_THREAD_ATTACH:
			dll_thread_attach( true, true );
			break;
		case DLL_THREAD_DETACH:
			dll_thread_detach( true, true );
			break;
		default:
			break;
	}
	return true;
}

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

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-learn mailing list