各位,
我刚刚创建了我的第一个 C++/CLI 项目 (Visual Studio 2008),它是一个允许我的 C# 应用程序访问销售点理货打印机的库。
我的库构建良好,从 C# exe 调用时,一些简单的函数也能正常工作。
然而,一旦我包含一个 WinGDI 调用(在本例中为 DeleteObject),链接器就会提示“未解析的 token ”错误。
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
在过去的 4 年里,我没有真正使用过 C++,而且我对 MS C++ 编译器的经验也很少,因此我不知道我在链接器设置中寻找什么。
我们将不胜感激任何帮助。
谢谢
最佳答案
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.
检查链接器命令行中是否存在 Gdi32.lib(属性 > 链接器 > 命令行)。
(好了——你已经成功地吸引了我自私的、寻求代表的灵魂部分;))
关于.net - C++/命令行界面 : linker gives "unresolved token" for win32 function,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/739952/