Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C++ Irrlicht Program doesn't link: "undefined reference to `__imp_createDevice'"

Tags:

c++

3d

irrlicht

My Irrlicht program doesn't link. The compiler I use is g++.

Code:

#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();
}

Linker output:

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

Command line:

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

The linker founds the library file. What's wrong?

Edit: I made little experimenting. The result was, that when I comment createDevice()-line out, no linker errors will come. So that means, that linker founds all the other functions, i.e. IrrlichtDevice::run().

like image 207
Elias Kosunen Avatar asked Feb 04 '26 00:02

Elias Kosunen


1 Answers

__imp_createDevice refers to a .lib file that is built for dynamic linking to an .so or .dll. See this post and answer.

Find the .lib that is built for static linking, or alternatively check if you have to specify a pre-compiler definition such as _IRR_STATIC_LIB_, IRRLICHT_STATIC or IRRLICHT_EXPORTS to have correct linkage.

like image 97
StarShine Avatar answered Feb 06 '26 13:02

StarShine



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!