gpt4 book ai didi

C++ Irrlicht 程序不链接 : "undefined reference to ` __imp_createDevice'"

转载 作者:太空狗 更新时间:2023-10-29 23:03:09 33 4
gpt4 key购买 nike

我的 Irrlicht 程序没有链接。我使用的编译器是 g++。

代码:

#include <irrlicht.h>

int main()
{
irr::IrrlichtDevice *device = irr::createDevice();
// And other init stuff
while(device->run())
{
driver->beginScene();
smgr->drawAll();
guienv->drawAll();
driver->endScene();
}
device->drop();
}

链接器输出:

...
(path)/main.cpp:28: undefined reference to `__imp_createDevice'
collect2.exe: error: ld returned 1 exit status

命令行:

g++.exe -o "(Path)\Test.exe" "(Path)\Test\main.o"
..\..\..\..\..\..\MinGW\lib\libIrrlicht.a

链接器创建库文件。怎么了?

编辑:我几乎没有做任何实验。结果是,当我注释掉 createDevice() 行时,不会出现链接器错误。所以这意味着,该链接器会创建所有其他函数,即 IrrlichtDevice::run()

最佳答案

__imp_createDevice 指的是为 动态 链接到 .so 或 .dll 而构建的 .lib 文件。 See this post and answer.

找到为静态链接构建的 .lib,或者检查您是否必须指定预编译器定义,例如 _IRR_STATIC_LIB_、IRRLICHT_STATIC 或 IRRLICHT_EXPORTS 以获得正确的链接。

关于C++ Irrlicht 程序不链接 : "undefined reference to ` __imp_createDevice'",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26660117/

33 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com