www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - D on Windows - linker question

reply "Erik van Velzen" <erik evanv.nl> writes:
Hello,
I have set up my enviroment according to these instructions:
http://wiki.dlang.org/Installing_DMD_on_64-bit_Windows_7_%28COFF-compatible%29

When I compile a small tutorial program I get this error:
error LNK2019: unresolved external symbol MessageBoxW referenced 
in function WinMain

I have to manually specify "User32.Lib" to dmd when I want to 
compile my program (or move User32.Lib to my project directory).

Is this normal?

Below is my sc.ini.

[Environment]
LIB="%DIR_WINSDK%\Lib\x64";"%DIR_MSVC%\lib\amd64";"% P%\..\lib"
DFLAGS="-I% P%\..\..\src\phobos" 
"-I% P%\..\..\src\druntime\import" "-m64"
LINKCMD=% P%\link.exe
LINKCMD64=%DIR_MSVC%\bin\amd64\link.exe

Obviously User32.Lib resides in "%DIR_WINSDK%\Lib\x64". This 
directory resolves correctly in windows explorer to "C:\Program 
Files\Microsoft SDKs\Windows\v7.1\Lib\x64"
Oct 18 2013
parent reply Benjamin Thaut <code benjamin-thaut.de> writes:
Am 18.10.2013 18:40, schrieb Erik van Velzen:
 Hello,
 I have set up my enviroment according to these instructions:
 http://wiki.dlang.org/Installing_DMD_on_64-bit_Windows_7_%28COFF-compatible%29


 When I compile a small tutorial program I get this error:
 error LNK2019: unresolved external symbol MessageBoxW referenced in
 function WinMain

 I have to manually specify "User32.Lib" to dmd when I want to compile my
 program (or move User32.Lib to my project directory).

 Is this normal?

 Below is my sc.ini.

 [Environment]
 LIB="%DIR_WINSDK%\Lib\x64";"%DIR_MSVC%\lib\amd64";"% P%\..\lib"
 DFLAGS="-I% P%\..\..\src\phobos" "-I% P%\..\..\src\druntime\import" "-m64"
 LINKCMD=% P%\link.exe
 LINKCMD64=%DIR_MSVC%\bin\amd64\link.exe

 Obviously User32.Lib resides in "%DIR_WINSDK%\Lib\x64". This directory
 resolves correctly in windows explorer to "C:\Program Files\Microsoft
 SDKs\Windows\v7.1\Lib\x64"
Yes. It is normal that you have to manually specify User32.lib when compiling. At least for x64. I recommend you use visualD which sets up a propper windows project for you. Kind Regards Benjamin Thaut
Oct 18 2013
parent reply "evilrat" <evilrat666 gmail.com> writes:
On Friday, 18 October 2013 at 16:52:01 UTC, Benjamin Thaut wrote:
 Am 18.10.2013 18:40, schrieb Erik van Velzen:
 Hello,
 I have set up my enviroment according to these instructions:
 http://wiki.dlang.org/Installing_DMD_on_64-bit_Windows_7_%28COFF-compatible%29


 When I compile a small tutorial program I get this error:
 error LNK2019: unresolved external symbol MessageBoxW 
 referenced in
 function WinMain

 I have to manually specify "User32.Lib" to dmd when I want to 
 compile my
 program (or move User32.Lib to my project directory).

 Is this normal?

 Below is my sc.ini.

 [Environment]
 LIB="%DIR_WINSDK%\Lib\x64";"%DIR_MSVC%\lib\amd64";"% P%\..\lib"
 DFLAGS="-I% P%\..\..\src\phobos" 
 "-I% P%\..\..\src\druntime\import" "-m64"
 LINKCMD=% P%\link.exe
 LINKCMD64=%DIR_MSVC%\bin\amd64\link.exe

 Obviously User32.Lib resides in "%DIR_WINSDK%\Lib\x64". This 
 directory
 resolves correctly in windows explorer to "C:\Program 
 Files\Microsoft
 SDKs\Windows\v7.1\Lib\x64"
Yes. It is normal that you have to manually specify User32.lib when compiling. At least for x64. I recommend you use visualD which sets up a propper windows project for you. Kind Regards Benjamin Thaut
and i recommend to use dub, which then can generate projects for visuald or whatever.
Oct 19 2013
parent reply "Erik van Velzen" <erik evanv.nl> writes:
My goal was to learn D and Direct3D at the same time.

I've tried to set up DMD to do this, but I keep running into 
issues that the available DirectX11 and win32 headers are 
incomplete, or won't compile (tried both dmd 2.063 and 2.064, 
they halt on different type errors), or won't link.

To be fair, these are only a few errors, but when the linker 
spews out some obfuscated function name I really don't know what 
to do.

Will I have more luck with GDC? Or should I try to make headers 
on my own incrementally? (or take the easy route and use C++?)
Oct 20 2013
parent reply "evilrat" <evilrat666 gmail.com> writes:
On Sunday, 20 October 2013 at 21:47:53 UTC, Erik van Velzen wrote:
 My goal was to learn D and Direct3D at the same time.

 I've tried to set up DMD to do this, but I keep running into 
 issues that the available DirectX11 and win32 headers are 
 incomplete, or won't compile (tried both dmd 2.063 and 2.064, 
 they halt on different type errors), or won't link.

 To be fair, these are only a few errors, but when the linker 
 spews out some obfuscated function name I really don't know 
 what to do.

 Will I have more luck with GDC? Or should I try to make headers 
 on my own incrementally? (or take the easy route and use C++?)
i'm currently trying to get up DirectX(d3d10(x),d3d11(x),xaudio2,x3daudio,d3dmath) up and running in free time, but i constantly encounter serious problems on my way. now i have some weird problems with COM(no COM - no DirectX). so i don't recommend anyone even try it(DirectX) now, unless one is truly skilled with C++ p.s. for working win32 with dmd 2.063.2 go there(don't forget to convert .lib's to OMF, use coffimplib from digitalmars ftp) - https://github.com/AndrejMitrovic/DWinProgramming/tree/master/WindowsAPI
Oct 20 2013
next sibling parent reply "Andrew" <diehertz gmail.com> writes:
On Monday, 21 October 2013 at 04:38:05 UTC, evilrat wrote:
 On Sunday, 20 October 2013 at 21:47:53 UTC, Erik van Velzen 
 wrote:
 My goal was to learn D and Direct3D at the same time.

 I've tried to set up DMD to do this, but I keep running into 
 issues that the available DirectX11 and win32 headers are 
 incomplete, or won't compile (tried both dmd 2.063 and 2.064, 
 they halt on different type errors), or won't link.

 To be fair, these are only a few errors, but when the linker 
 spews out some obfuscated function name I really don't know 
 what to do.

 Will I have more luck with GDC? Or should I try to make 
 headers on my own incrementally? (or take the easy route and 
 use C++?)
i'm currently trying to get up DirectX(d3d10(x),d3d11(x),xaudio2,x3daudio,d3dmath) up and running in free time, but i constantly encounter serious problems on my way. now i have some weird problems with COM(no COM - no DirectX). so i don't recommend anyone even try it(DirectX) now, unless one is truly skilled with C++ p.s. for working win32 with dmd 2.063.2 go there(don't forget to convert .lib's to OMF, use coffimplib from digitalmars ftp) - https://github.com/AndrejMitrovic/DWinProgramming/tree/master/WindowsAPI
What it has to do with C++?
Oct 21 2013
parent reply "evilrat" <evilrat666 gmail.com> writes:
On Monday, 21 October 2013 at 07:46:41 UTC, Andrew wrote:
 On Monday, 21 October 2013 at 04:38:05 UTC, evilrat wrote:
 On Sunday, 20 October 2013 at 21:47:53 UTC, Erik van Velzen 
 wrote:
 My goal was to learn D and Direct3D at the same time.

 I've tried to set up DMD to do this, but I keep running into 
 issues that the available DirectX11 and win32 headers are 
 incomplete, or won't compile (tried both dmd 2.063 and 2.064, 
 they halt on different type errors), or won't link.

 To be fair, these are only a few errors, but when the linker 
 spews out some obfuscated function name I really don't know 
 what to do.

 Will I have more luck with GDC? Or should I try to make 
 headers on my own incrementally? (or take the easy route and 
 use C++?)
i'm currently trying to get up DirectX(d3d10(x),d3d11(x),xaudio2,x3daudio,d3dmath) up and running in free time, but i constantly encounter serious problems on my way. now i have some weird problems with COM(no COM - no DirectX). so i don't recommend anyone even try it(DirectX) now, unless one is truly skilled with C++ p.s. for working win32 with dmd 2.063.2 go there(don't forget to convert .lib's to OMF, use coffimplib from digitalmars ftp) - https://github.com/AndrejMitrovic/DWinProgramming/tree/master/WindowsAPI
What it has to do with C++?
nothing. but whole win32/DirectX is either C or C++ with COM. learning them will require thinking that way, while D offers higher level abstraction you won't learn D with this, just D'ish C/C++. it also would require basic understanding of ABI interop between C/D and so on, so experience with win32/C++ would help a lot if any problem encountered.
Oct 21 2013
parent reply "Andrew" <diehertz gmail.com> writes:
On Monday, 21 October 2013 at 07:56:49 UTC, evilrat wrote:
 On Monday, 21 October 2013 at 07:46:41 UTC, Andrew wrote:
 On Monday, 21 October 2013 at 04:38:05 UTC, evilrat wrote:
 On Sunday, 20 October 2013 at 21:47:53 UTC, Erik van Velzen 
 wrote:
 My goal was to learn D and Direct3D at the same time.

 I've tried to set up DMD to do this, but I keep running into 
 issues that the available DirectX11 and win32 headers are 
 incomplete, or won't compile (tried both dmd 2.063 and 
 2.064, they halt on different type errors), or won't link.

 To be fair, these are only a few errors, but when the linker 
 spews out some obfuscated function name I really don't know 
 what to do.

 Will I have more luck with GDC? Or should I try to make 
 headers on my own incrementally? (or take the easy route and 
 use C++?)
i'm currently trying to get up DirectX(d3d10(x),d3d11(x),xaudio2,x3daudio,d3dmath) up and running in free time, but i constantly encounter serious problems on my way. now i have some weird problems with COM(no COM - no DirectX). so i don't recommend anyone even try it(DirectX) now, unless one is truly skilled with C++ p.s. for working win32 with dmd 2.063.2 go there(don't forget to convert .lib's to OMF, use coffimplib from digitalmars ftp) - https://github.com/AndrejMitrovic/DWinProgramming/tree/master/WindowsAPI
What it has to do with C++?
nothing. but whole win32/DirectX is either C or C++ with COM. learning them will require thinking that way, while D offers higher level abstraction you won't learn D with this, just D'ish C/C++. it also would require basic understanding of ABI interop between C/D and so on, so experience with win32/C++ would help a lot if any problem encountered.
If you want to offer Direct3D in D as is (I prefer this option instead of wrapper-libraries), you'll have to make it COM'ish and C'ish :-) I actually consider looking into this problem, I'm skilled C++ graphics programmer.
Oct 21 2013
parent "evilrat" <evilrat666 gmail.com> writes:
On Monday, 21 October 2013 at 08:12:49 UTC, Andrew wrote:
 If you want to offer Direct3D in D as is (I prefer this option 
 instead of wrapper-libraries), you'll have to make it COM'ish 
 and C'ish :-)
 I actually consider looking into this problem, I'm skilled C++ 
 graphics programmer.
i think about both "raw" and D'ish(wrapper) bindings.
Oct 21 2013
prev sibling parent reply "Erik van Velzen" <erik evanv.nl> writes:
On Monday, 21 October 2013 at 04:38:05 UTC, evilrat wrote:
 i'm currently trying to get up 
 DirectX(d3d10(x),d3d11(x),xaudio2,x3daudio,d3dmath) up and 
 running in free time, but i constantly encounter serious 
 problems on my way. now i have some weird problems with COM(no 
 COM - no DirectX).

 so i don't recommend anyone even try it(DirectX) now, unless 
 one is truly skilled with C++
Thanks for your advice, I suspected as much. I will hack some more and see if I'm progressing or learning anything. And decide in a few days if I continue with D3D in D, or stick to C++. I do have experience in C++, though with server apps on Linux without native GUIs.
 p.s. for working win32 with dmd 2.063.2 go there(don't forget 
 to convert .lib's to OMF, use coffimplib from digitalmars ftp) 
 - 
 https://github.com/AndrejMitrovic/DWinProgramming/tree/master/WindowsAPI
I'm using COFF with the visual studio linker, so I don't need to convert. I do get a few compiler errors with DMD in these win32.* modules about incorrect typecasts. I will make a new topic if these persist or file a bug report with the author.
Oct 21 2013
parent "evilrat" <evilrat666 gmail.com> writes:
On Tuesday, 22 October 2013 at 01:07:48 UTC, Erik van Velzen 
wrote:
 I do get a few compiler errors with DMD in these win32.* modules
 about incorrect typecasts. I will make a new topic if these
 persist or file a bug report with the author.
if you use x64 build then i must disappoint you, it only converted and works for 32 bit, i have my own "fixed" version of these, but it is hacked to just works. and i don't remember wrong casts in there. do you mixing std.c.windows with this win32? if so, this just because of ambiguity, compiler can't distinguish on itself if multiple definitions exists in one scope. either use alias to specify which symbol to use alias (like this "alias MessageBoxA = std.c.windows.windows;") or static import one of the modules.
Oct 21 2013