views:

944

answers:

2

Folks,

I just created my first C++/CLI project (Visual Studio 2008), it's a Library to allow my C# app access an point of sale tally printer.

My library builds well and trivial functions work when called from a C# exe.

However as soon as I include a WinGDI call (DeleteObject in this case), the linker complains with “unresolved token” errors.

Error 2 error LNK2028: unresolved token (0A000088) "extern "C" int __stdcall DeleteObject(void *)" (?DeleteObject@@$$J14YGHPAX@Z) referenced in function "private: __clrcall ReceiptPrinter::Epson::~Epson(void)" (??1Epson@ReceiptPrinter@@$$FA$AAM@XZ) ReceiptPrinter.obj ReceiptPrinter

I haven't done any serious C++ in the last 4 years, and I have precious little experience of MS C++ compilers, as such I don’t know what I’m looking for in the linker settings.

Any help will be greatfully received.

Thanks

+2  A: 

You should link your dll with Gdi32.lib.

You can either do it with a #pragma comment(lib, "gdi32.lib") or in your project's settings under Linker.

Idan K
+1  A: 

Additional dependancies was "NoInherit", when I looked "under" the setting, there was a list of libs, gdi32.lib was in the list. I checked "Inherit from parent project" and it now works. Dirk, if you add all that as an answer I'll select it and give you the rep.

Check if Gdi32.lib is there in the linker commandline(Properties > Linker > CommandLine).

(There you go -- you have successfully appealed to the my selfish, rep seeking part of soul ;) )

dirkgently
I tend not to think well of rep hoors, but I reckon you deserved this bit of rep . . . this time :)
Binary Worrier
P.S. Thanks again mate
Binary Worrier
@Binary Worrier: Hm. Straighten me up when you think I don't deserve one.
dirkgently
No fear. IMO really rep hoors tend to have a high ratio of questions to answers, I think your rep "reputation" is safe with a ratio of 4:683 :) Late dude,
Binary Worrier