[no bug] Irrlicht 1.8.1 & VS2012

You discovered a bug in the engine, and you are sure that it is not a problem of your code? Just post it in here. Please read the bug posting guidelines first.
Post Reply
polylux
Posts: 267
Joined: Thu Aug 27, 2009 12:39 pm
Location: EU

[no bug] Irrlicht 1.8.1 & VS2012

Post by polylux »

Hey everyone!

Background to this issue: I need to port an application over to Windows 7. I'm facing linker issues using VS2012 that I haven't had with VS2010. Due to my obsession with Linux, my Windows knowledge is not the best so I already apologize if my problem is caused by my lack of "wisdom". ;)

Steps I took so far:

1, Compile Irrlicht 1.8.1 (Release, DLL) in VS2012. The only modification I made was to disable the compilation of the DX9 driver. Everything else is left to "factory settings".
2, Create an empty project that only renders a couple of 3D lines. Makes use of the .lib for linkage and the .dll during runtime.
3, When attempting to link to the .lib, the externally declared "IdentityMatrix" causes the linker to report an unresolved external symbol, like so:

Code: Select all

1>pHApplication.obj : error LNK2001: unresolved external symbol "class irr::core::CMatrix4<float> const irr::core::IdentityMatrix" (?IdentityMatrix@core@irr@@3V?$CMatrix4@M@12@B)
For convenience, I post the matrix' declaration

Code: Select all

IRRLICHT_API extern const matrix4 IdentityMatrix; (matrix4.h)
and definition

Code: Select all

const matrix4 IdentityMatrix(matrix4::EM4CONST_IDENTITY); (Irrlicht.cpp)
Bothering a Win friend of mine, he suggested using "dumpbin" to investigate the symbols provided by the .lib. Here's the first couple of lines from its output:

Code: Select all

490 public symbols
 
     76F0 __IMPORT_DESCRIPTOR_Irrlicht
     791E __NULL_IMPORT_DESCRIPTOR
     7A56 Irrlicht_NULL_THUNK_DATA
     7BAA __imp_?IdentityMaterial@video@irr@@3VSMaterial@12@A
     7CC2 __imp_?LOCALE_DECIMAL_POINTS@core@irr@@3V?$string@DV?$irrAllocator@D@core@irr@@@12@A
     7C36 __imp_?IdentityMatrix@core@irr@@3V?$CMatrix4@M@12@B
     84B8 __imp__createDeviceEx
     84B8 _createDeviceEx
     844C __imp__createDevice
     844C _createDevice
     8526 __imp__png_access_version_number
     8526 _png_access_version_number
     BAAE __imp__png_reset_zstream
     BAAE _png_reset_zstream
     B266 __imp__png_handle_as_unknown
     B266 _png_handle_as_unknown
     99BC __imp__png_get_header_version
     99BC _png_get_header_version
     994A __imp__png_get_header_ver
     994A _png_get_header_ver
As you can see, every provided symbol has the __imp_<x> and the following definition of it in the next line - except for "IdentityMaterial", "LOCALE_..." and "IdentityMatrix". My guess is hence that they are missing from the lib/dll.

Maybe I'm just missing a preproc directive, a compiler/linker setting or it's all caused by my despisement of VisualStudio. Maybe it's really a bug in the end.

Thanks in advance,
p.
Last edited by polylux on Tue Mar 25, 2014 10:55 am, edited 1 time in total.
beer->setMotivationCallback(this);
CuteAlien
Admin
Posts: 9643
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: Irrlicht 1.8.1 & VS2012

Post by CuteAlien »

That problem is usually caused when people accidentally use _IRR_STATIC_LIB_ in the project while linking to the dll - or the other way round - using _IRR_STATIC_LIB_ in the library while linking to an application expecting the dll. Maybe check if you really used release dll - maybe you hit release static accidentally.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
polylux
Posts: 267
Joined: Thu Aug 27, 2009 12:39 pm
Location: EU

Re: Irrlicht 1.8.1 & VS2012

Post by polylux »

Thanks for the quick reply, CuteAlien.
That was also my first guess so I already triple-checked that, neither Irrlicht nor my project has _IRR_STATIC_LIB_ defined. To further assure, I also explicitly replaced IRRLICHT_API with the respective __declspec(x), still the error occurs.
beer->setMotivationCallback(this);
CuteAlien
Admin
Posts: 9643
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: Irrlicht 1.8.1 & VS2012

Post by CuteAlien »

Phew - it's exactly the error I'm getting when I mix up static and dynamic libs. Just so you can check a 4th time - add some compile-errors (just anything that breaks the compile like bfkfkfjdf or so ^_^) in IrrCompileConfig.h.
When compiling Irrlicht add it in this line: #define IRRLICHT_API __declspec(dllexport)
When compiling pHApplication.cpp add it in that line: #define IRRLICHT_API __declspec(dllimport)
When one of them still compiles without error (or runs into the wrong one) then something is messed up there.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
polylux
Posts: 267
Joined: Thu Aug 27, 2009 12:39 pm
Location: EU

Re: Irrlicht 1.8.1 & VS2012

Post by polylux »

4th time check revealed that some old header file that's not part of the project anymore was still included somewhere which pulled in the _IRR_STATIC_LIB_ definition. Me hide in shames...
Thanks CuteAlien for insisting on the "quadrocheck". ;)
beer->setMotivationCallback(this);
CuteAlien
Admin
Posts: 9643
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: Irrlicht 1.8.1 & VS2012

Post by CuteAlien »

Hehe, can't check often enough :-) But it's a confusing error-message, I wonder if there's some way to get saner compiler errors for this.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Post Reply