开发者

How to use/link gdLibrary (libgd) with MS Visual C++ (e.g. 2008 Express Edition)? Getting LNK2019 errors

I have to use the gdLibrary (http://www.libgd.org) in a C++ App on MS Windows XP Prof. SP3 32bit - and I'm trying and googleing for two days now without success. Does anyone of you use libgd with MS VC++ 200x EE?

My problem: It has to to compile with MS Visual C++ (e.g. the 2008 Express Edition - fixed 3rd party condition)... but currently the linker crashes, with 11 of the following LNK2019 errors:

Linking... codereate.obj : error LNK2019: An undefined external symbol "_gdImageDestroy" was found in "public: virtual __thiscall CodeCreate::~CodeCreate(void)"

The other smybols are _gdImageColorExact, _gdImageCopyResized and some other gd-functions. It seems that the VC++ linker does not work correctly with the bgd.lib provided by the package I downloaded from http://www.libgd.org/releases/gd-latest-win32.zip.

What I did/tried:

  1. Extracted gd-latest-win32.zip to c:\users\johndoe\cpp\libgd.
  2. Defined c:\users\johndoe\cpp\libgd\lib als additional library dir (global VC++ setting)
  3. Defined c:\users\johndoe\cpp\libgd\include as additional includes dir (global VC++ setting)
  4. Defined c:\users\johndoe\cpp\libgd\include\lib\bgd.lib as additional linker\input dependency (project setting)
  5. I even added #pragma comment(lib, "libgd.lib") into my codecreate.h to be on the save side.

Any suggestions? What am I doing wrong (e.g. have I forget to install something)? Is there any "trick" to get a VC++ 2008 compatible bgd.lib?

Additional notes:

  1. Running on Linux/g++, everything works fine, no warnings with -pedantic -ansi -wAll. The program does its job an generates some barcodes.
  2. It works when using DevC++ for Win32. Therefore it is no Windows issue, "just" a VC++ issue. For DevC++ I did:
    • I just downloaded http://www.libgd.org/releases/gd-latest-win32.zip,
    • extracted it to c:\users\johndoe\cpp\libgd
    • added c:\users\johndoe\cpp\libgd\lib\bgd.lib as additional obbject in the linker-projects settings.
    • defined c:\users\johndoe\cpp\libgd\lib als additional library dir,
    • defined c:\users\johndoe\cpp\libgd\include as additional includes dir
    • happy about some barcode s开发者_如何学运维tuff
  3. If I can't get It working, I'm really in trouble... becoming really desperate right now :-(


Did you put NODLL definition in your project? If you did that, you should use bgd_a.lib instead. And you also need to make sure you have defined WIN32.

I tried to create a simple project with latest release and it does linked success. If I add NODLL without changing tot bgd_a then I get the same error message.


Check if you have defined preprocessor macro BGDWIN32 as it is required by libgd in order to compile client code with Visual C++.

Go to project properties, then C/C++ -> Preprocessor -> Preprocessor Definitions

and add BGDWIN32

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜