Author Topic: DLLs the Dynamic Way  (Read 2706 times)

0 Members and 1 Guest are viewing this topic.

Offline Patrice Terrier

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2003
    • www.zapsolution.com
DLLs the Dynamic Way
« on: May 08, 2013, 07:01:00 PM »
While searching for a solution to ease the use of my new C/C++ GDImage.dll without using .lib file, i found this MSDN article that describes a macro class that simplifies and automates the dynamic linking of DLLs.

http://msdn.microsoft.com/en-us/library/ms810279.aspx#dlldynamic_pdllclass
Patrice Terrier
GDImage (advanced graphic addon)
http://www.zapsolution.com

Offline James C. Fuller

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 674
Re: DLLs the Dynamic Way
« Reply #1 on: May 08, 2013, 08:09:03 PM »
Patrice,
  This works for me with zTrace:
#define C_IMPORT EXTERN_C __declspec(dllimport)
C_IMPORT long __stdcall zTrace (WCHAR*);
#pragma comment(lib,"zTrace.lib")


James
« Last Edit: May 08, 2013, 08:10:51 PM by James C. Fuller »

Offline Patrice Terrier

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2003
    • www.zapsolution.com
Re: DLLs the Dynamic Way
« Reply #2 on: May 08, 2013, 08:38:22 PM »
That never work by me

It always fails with:
fatal error LNK1104: unable to open the file 'zTrace.lib'

zTrace.lib and zTrace.dll are of course Inside the same folder.

Added:
In order to let it work, i am forced to specify the full path to the .lib file.
There must be an easier way, to just tell the compiler that it should use the same folder than the resulting EXE, or something similar.
When it works it is still a pain, because of course you can't use the same .lib file for 32 and 64-bit, then you have to use some kind of #def, to first select the correct target.

« Last Edit: May 08, 2013, 09:34:34 PM by Patrice Terrier »
Patrice Terrier
GDImage (advanced graphic addon)
http://www.zapsolution.com