Static linking with a third (own) library in between

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
realmsinthemists
Posts: 28
Joined: Mon Mar 27, 2017 7:29 am

Static linking with a third (own) library in between

Post by realmsinthemists »

Am writing some extensions for Irrlicht in a library to link statically, just as Irrlicht will be linked.

So this gives me the solutions:
  • Irrlicht (static lib, x64) (compiled with preprossecor macro _IRR_STATIC_LIB_)
  • IrrlichtExtensions (static lib, x64)
  • Sailors (exe, x64)
Note those are three solutions.

When starting earlier today I made this mess within two hours. First I got this same error as below thus adding _IRR_STATIC_LIB_ and getting the expected _ITERATOR_DEBUG_LEVEL mismatch. The iterator error kept coming back. Had to do with how I included the header files. Since the code worked properly I decided to reorganise and put the extensions into its own static library, easy to publish when the time comes.

Thus expecting the next compiiler error but I am failing to solve this. So my problem is simple; What am I forgetting?
(Excluding the 'IrrlichtExtensions.lib' and its header doesn't do anything visible.)

Regards,
edit: fixed typos

Code: Select all

 
1>cSailors.obj : error LNK2019: unresolved external symbol __imp_createDevice referenced in function "public: int __cdecl cSailors::Initialise(void)" (?Initialise@cSailors@@QEAAHXZ)
 
Directories and files used, double and tripple checked for correct directories and typos:

Code: Select all

 
$(MY_LIBS_EXT)irrlicht\v1_8_4\lib\Win64-visualStudio\Irrlicht_static.lib 
$(MY_LIBS_EXT)irrlicht\v1_8_4\lib\Win64-visualStudio\Irrlicht_static_debug.lib
$(MY_LIBS_EXT)irrlicht\v1_8_4\include\*.h
 
My static library: IrrlichtExtensions
(compiles correctly in both, debug and release)
IrrlichtExtensions Property Pages

Code: Select all

 
//      General:
//          Output Directory:                           $(SolutionDir)output\
//          Intermediate:                               $(SolutionDir)intermediate\$(ProjectName)_$(Platform)_$(Configuration)\
//          Target name (_DEBUG):                       $(ProjectName)_$(Platform)_$(Configuration)
//          Target name:                                $(ProjectName)_$(Platform)
//      C/C++
//          General:
//              Additional include directories:         $(MY_LIBS_EXT)$(MY_IRRLICHT)$(MY_IRRLICHT_VERSION)$(MY_IRRLICHT_INC);
//                                                      $(MY_LIBS_EXT)$(MY_IRRLICHT)$(MY_IRRLICHT_VERSION)source\irrlicht\
//          Code generation:
//              Runtime library (_DEBUG):               Multi - threaded Debug( / MTd )
//              Runtime library:                        Multi - threaded Debug( / MT )
//      Linker
//          General
//              Additional library directories:         $(MY_LIBS_EXT)$(MY_IRRLICHT)$(MY_IRRLICHT_VERSION)$(MY_IRRLICHT_LIB);
 
File: IrrlichtExtensions.h

Code: Select all

 
#pragma once
 
//#undef _ITERATOR_DEBUG_LEVEL
//#define _ITERATOR_DEBUG_LEVEL 0
 
//#ifndef _IRR_STATIC_LIB_
#define _IRR_STATIC_LIB_
//#endif
 
#include <irrlicht.h>
 
#include "include\IExtendedGeometryCreator.h"
#include "include\ISphereTerrainSceneNode.h"
 
#include "source\CCapsuleSceneNode.h"
#include "source\CExtendedGeometryCreator.h"
#include "source\cIrrlichtExtensions.h"
#include "source\CSphereTerrainSceneNode.h"
 
#ifdef _DEBUG
#pragma comment(lib, "Irrlicht_static_debug.lib")
#else
#pragma comment(lib, "Irrlicht_static.lib")
#endif
 
My executable: Sailors
(gives the compiler error)
Sailors Property Pages:

Code: Select all

 
//      General:
//          Output Directory:                           $(SolutionDir)output\
//          Intermediate:                               $(SolutionDir)intermediate\$(ProjectName)_$(Platform)_$(Configuration)\
//          Target name (_DEBUG):                       $(ProjectName)_$(Platform)_$(Configuration)
//          Target name:                                $(ProjectName)_$(Platform)
//      C/C++
//          General:
//              Additional include directories:         $(MY_LIBS_EXT)$(MY_IRRLICHT)$(MY_IRRLICHT_VERSION)$(MY_IRRLICHT_INC);
//                                                      D:\dev\Projects\IrrlichtExtensions\IrrlichtExtensions\
//          Code generation:
//              Runtime library (_DEBUG):               Multi - threaded Debug( / MTd )
//              Runtime library:                        Multi - threaded Debug( / MT )
//      Linker
//          General
//              Additional library directories:         $(MY_LIBS_EXT)$(MY_IRRLICHT)$(MY_IRRLICHT_VERSION)$(MY_IRRLICHT_LIB);
//                                                      D:\dev\Projects\IrrlichtExtensions\output\
File: Sailors.h

Code: Select all

 
#pragma once
 
//#undef _ITERATOR_DEBUG_LEVEL
//#define _ITERATOR_DEBUG_LEVEL 0
 
//#ifndef _IRR_STATIC_LIB_
#define _IRR_STATIC_LIB_
//#endif
 
#include <irrlicht.h>
#include <IrrlichtExtensions.h>
 
#ifdef _DEBUG
#pragma comment(lib, "Irrlicht_static_debug.lib")
#pragma comment(lib, "IrrlichtExtensions_x64_Debug.lib")
#else
#pragma comment(lib, "Irrlicht_static.lib")
#pragma comment(lib, "IrrlichtExtensions_x64.lib")
#endif
 
Sailors.cpp

Code: Select all

 
#include "Sailors.h"
#include "cSailors.h"
 
int main()
{
 
    int result = 0;
    cSailors sailors;
    
    if( ( result = sailors.Initialise() ) )
        return result;
 
    if( ( result = sailors.HaveFun() ) )
        return result;
 
    return 0;
 
}
 
For my end result I am working on:
- Volume Voxel System
- Simple light weight physics engine
CuteAlien
Admin
Posts: 9628
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: Static linking with a third (own) library in between

Post by CuteAlien »

_ITERATOR_DEBUG_LEVEL is about mixing debug & release versions of STL. Note that you can get VS to enforce another one by setting stuff like _ITERATOR_DEBUG_LEVEL=0. Also that it shouldn't even matter to Irrlicht because we don't use STL (but try telling VS that...).
Also it's usually better doing the _IRR_STATIC_LIB_ defines in the project settings - that way it's ensured they are not missed in any files.
But in the end - can't tell much with this info. You don't link to Irrlicht for some reason - but don't know why.
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
realmsinthemists
Posts: 28
Joined: Mon Mar 27, 2017 7:29 am

Re: Static linking with a third (own) library in between

Post by realmsinthemists »

Have put the static macro into the properties pages. Now it just compiles. Don't know why it wasn't working and why it kept complaining about the _ITERATOR_DEBUG_LEVEL.

_ITERATOR_DEBUG_LEVEL doesn't make sense anyway since I am linking all as debug to the debug exe.

Also the _IRR_STATIC_LIB_ doesn't make sense to me when it is set at the properties. Just because it is the first line in all projects I am using. But it seemed the solution though, so happy with it.

Am not linking irrlicht into the Irrlichtxtensions.lib only into the exe. Could that be the case, although I believe definitions are only needed when the declarations are (possible actually) called - which is only after linking everything into the exe.

In any case, I am happy to see it is compiling again so one can concentrate on the fun stuff.

Thanks,
For my end result I am working on:
- Volume Voxel System
- Simple light weight physics engine
Post Reply