Elias Kosunen
Elias Kosunen

Reputation: 433

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

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().

Upvotes: 3

Views: 2262

Answers (1)

StarShine
StarShine

Reputation: 2050

__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.

Upvotes: 1

Related Questions