简体   繁体   English

XDispatch C ++未解决的外部

[英]XDispatch C++ Unresolved Externals

I'm work with GCD in C++ with xdisptach, libdispatch in Visual Studio 2012 on Windows 7. 我正在Windows 7的Visual Studio 2012中使用xdisptach,libdispatch在C ++中使用GCD。

I am declaring a class with a global variable that is a dispatch queue. 我声明一个带有全局变量的类,该全局变量是调度队列。 Other functions in the class call the queue's function. 该类中的其他函数调用队列的函数。 Everything compiles fine, except when i instantiate the queue in the constructor. 一切编译正常,除非我在构造函数中实例化队列。

xdispatch::queue* dispatch_queue;
AsyncNode()
{
    dispatch_queue = new xdispatch::queue(Name);
}

When dispatch_queue = new xdispatch::queue(Name); 当dispatch_queue = new xdispatch :: queue(Name); is commented out, it all compiles fine. 被注释掉,一切编译正常。 Otherwise i get the following errors. 否则我得到以下错误。

Error   50  error LNK2019: unresolved external symbol "__declspec(dllimport) public: virtual __thiscall xdispatch::queue::~queue(void)" (__imp_??1queue@xdispatch@@UAE@XZ) referenced in function "public: virtual void * __thiscall xdispatch::queue::`scalar deleting destructor'(unsigned int)" (??_Gqueue@xdispatch@@UAEPAXI@Z)

Error   49  error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall xdispatch::queue::queue(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (__imp_??0queue@xdispatch@@QAE@ABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z) referenced in function "public: __thiscall AsyncNode::AsyncNode(void)" (??0AsyncNode@@QAE@XZ)  

Error   53  error LNK2001: unresolved external symbol "public: virtual void __thiscall xdispatch::object::resume(void)" (?resume@object@xdispatch@@UAEXXZ)  

Error   51  error LNK2001: unresolved external symbol "public: virtual void * __thiscall xdispatch::queue::native(void)const " (?native@queue@xdispatch@@UBEPAXXZ)  

Error   52  error LNK2001: unresolved external symbol "public: virtual struct dispatch_queue_s * __thiscall xdispatch::queue::native_queue(void)const " (?native_queue@queue@xdispatch@@UBEPAUdispatch_queue_s@@XZ) 

This is the main site for xdispatch, but i can't find anything in terms of a forum or help with xdispatch in particular. 这是xdispatch的主要网站,但是我在论坛或xdispatch方面都找不到任何帮助。 There are many for objective-c.... :/ 有很多目标-....:/

http://opensource.mlba-team.de/xdispatch/docs/current/index.html http://opensource.mlba-team.de/xdispatch/docs/current/index.html

First of all, the behavior regarding deleting the "problematic" line is normal - when you're defining a pointer you're not invoking any function, and that is the reason you are not getting the "unresolved external errors". 首先,有关删除“问题”行的行为是正常的-当您定义指针时,您没有调用任何函数,这就是您没有得到“未解决的外部错误”的原因。

When you're initializing the variable by calling the constructor, you then run into problems because you're trying to call a function which is not available at link time. 当通过调用构造函数初始化变量时,您会遇到问题,因为您试图调用链接时不可用的函数。

When working with external libraries using DLLs, you must link to the appropriate import libraries, usually supplied as "lib" files. 使用DLL处理外部库时,必须链接到适当的导入库,通常以“ lib”文件的形式提供。 In your case, there is a folder named "lib" in the zip package. 在您的情况下,zip包中有一个名为“ lib”的文件夹。 Also, the DLLs must availble at run-time - by putting them in the folder of the executable, or adding them to the PATH environment variable. 而且,DLL必须在运行时可用-通过将它们放在可执行文件的文件夹中,或者将它们添加到PATH环境变量中。

In order to link to a library, follow these steps (taken from MSDN ): 为了链接到库,请按照下列步骤操作(从MSDN中获取 ):

  1. Open the project's Property Pages dialog box. 打开项目的“属性页”对话框。 For details, see Setting Visual C++ Project Properties. 有关详细信息,请参见设置Visual C ++项目属性。
  2. Click the Linker folder. 单击链接器文件夹。
  3. Click the Input property page. 单击输入属性页面。
  4. Modify the Additional Dependencies property. 修改其他依赖项属性。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM