Under what conditions will you get unresolved external symbol for __declspec(dllimport)?

℡╲_俬逩灬. 提交于 2019-12-11 07:37:51

问题


I am converting an application to use .dlls and I'm riddled with linker errors stating

unersolved external symbol"__declspec(dllimport) public: void __thiscall Rail::SetNextrail(class Rail *)"

There is more gibberish at the end of this error message. Why should this happen and how do you fix it? __declspec(dllimport) is being placed with a macro defined as:

#ifdef LUDOAI_EXPORT
#define DECLSPECAI __declspec(dllexport)
#else
#define DECLSPECAI __declspec(dllimport)
#endif

回答1:


I believe what you need to do is specify the Rails "import library" to the linker. Using the GUI, this is on the linker tab of project settings, under "additional libraries."

The "import library" is a .LIB file which contains symbols that resolve to the imports of the corresponding library. In the symbols from the .LIB file is an unconditional jump to the imports table's corresponding address for the import. When your code calls an import, it really calls this stub in the import library, which jumps to the import.




回答2:


I would just like to add, if you are using Qt Creator, this error means you need to add the appropriate import library to your project (.pro) file.

For example:
LIBS += $$quote(C:/Qt/4.7.3/lib/QtXml4.lib) for debug and release versions.



来源:https://stackoverflow.com/questions/1568298/under-what-conditions-will-you-get-unresolved-external-symbol-for-declspecdll

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!