www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Link error 42 (WinApi)

reply ref2401 <refactor24 gmail.com> writes:
import core.sys.windows.windows;

void main(string[] args) {
	// I'm aware it would not work properly.
	int formatIndex = ChoosePixelFormat(null, null);
}

When I compile the code above I'm getting the following link 
error:

OPTLINK (R) for Win32  Release 8.00.17
Copyright (C) Digital Mars 1989-2013  All rights reserved.
http://www.digitalmars.com/ctg/optlink.html
console-app.obj(console-app)
  Error 42: Symbol Undefined _ChoosePixelFormat 8

OS: Win 8.1 Pro
DMD: v2.070.0

Maybe I have to install something. Any thoughts?
Thank you.
Feb 15 2016
parent reply Rikki Cattermole <alphaglosined gmail.com> writes:
On 16/02/16 6:36 PM, ref2401 wrote:
 import core.sys.windows.windows;

 void main(string[] args) {
      // I'm aware it would not work properly.
      int formatIndex = ChoosePixelFormat(null, null);
 }

 When I compile the code above I'm getting the following link error:

 OPTLINK (R) for Win32  Release 8.00.17
 Copyright (C) Digital Mars 1989-2013  All rights reserved.
 http://www.digitalmars.com/ctg/optlink.html
 console-app.obj(console-app)
   Error 42: Symbol Undefined _ChoosePixelFormat 8

 OS: Win 8.1 Pro
 DMD: v2.070.0

 Maybe I have to install something. Any thoughts?
 Thank you.
Try compiling with 64bit. If it works, its just the import libs not containing the symbol.
Feb 15 2016
parent reply ref2401 <refactor24 gmail.com> writes:
On Tuesday, 16 February 2016 at 05:39:26 UTC, Rikki Cattermole 
wrote:
 Try compiling with 64bit.
 If it works, its just the import libs not containing the symbol.
dmd main.d -ofconsole-app.exe -debug -unittest -wi -m64 That's what I'm getting now: console-app.obj : error LNK2019: unresolved external symbol ChoosePixelFormat referenced in function _Dmain console-app.exe : fatal error LNK1120: 1 unresolved externals
Feb 15 2016
parent reply Rikki Cattermole <alphaglosined gmail.com> writes:
On 16/02/16 7:13 PM, ref2401 wrote:
 On Tuesday, 16 February 2016 at 05:39:26 UTC, Rikki Cattermole wrote:
 Try compiling with 64bit.
 If it works, its just the import libs not containing the symbol.
dmd main.d -ofconsole-app.exe -debug -unittest -wi -m64 That's what I'm getting now: console-app.obj : error LNK2019: unresolved external symbol ChoosePixelFormat referenced in function _Dmain console-app.exe : fatal error LNK1120: 1 unresolved externals
Found the problem, you haven't linked against gdi.
Feb 15 2016
parent ref2401 <refactor24 gmail.com> writes:
On Tuesday, 16 February 2016 at 06:22:33 UTC, Rikki Cattermole 
wrote:
 Found the problem, you haven't linked against gdi.
Thank you It works. I should have done this: set filesToUse=main.d gdi32.lib dmd filesToUse -ofconsole-app.exe -debug -unittest -wi
Feb 15 2016