Building OGRE as static library - Visual studio 2013

Problems building or running the engine, queries about how to use features etc.
Post Reply
codetemplar
Gnoblar
Posts: 22
Joined: Mon Nov 24, 2014 8:02 pm

Building OGRE as static library - Visual studio 2013

Post by codetemplar »

Hi all,

I am building ogre from source by using cmake. I added the dependencies I wanted, checked the "build Ogre as static library" checkbox, configured and then generated. No complaints. I then opened the sln file and built all projects as static libraries. All fine.

My game now successfully builds and links against the libraries but it throws an exception when run. Which is:

"exception(1813) The specified resource type cannot be found in the image file, in ConfigDialog::display"

It hasnt generated an ogre.cfg file and my plugins_d is pretty much empty as I shouldn't need my rendering system built as a plugin dll because I have statically linked against RenderSystem_Direct3D9Static_d.lib. This is my plugins_d file:
# Defines plugins to load

# Define plugin folder
PluginFolder=.

# Define plugins
See pretty much empty. I have no dll in my target folder as everything should be built into the exe. Have I missed something out?

This is my ogre.log file:
13:45:18: Creating resource group General
13:45:18: Creating resource group Internal
13:45:18: Creating resource group Autodetect
13:45:18: SceneManagerFactory for type 'DefaultSceneManager' registered.
13:45:18: Registering ResourceManager for type Material
13:45:18: Registering ResourceManager for type Mesh
13:45:18: Registering ResourceManager for type Skeleton
13:45:18: MovableObjectFactory for type 'ParticleSystem' registered.
13:45:18: ArchiveFactory for archive type FileSystem registered.
13:45:18: ArchiveFactory for archive type Zip registered.
13:45:18: ArchiveFactory for archive type EmbeddedZip registered.
13:45:18: DDS codec registering
13:45:18: FreeImage version: 3.16.0
13:45:18: This program uses FreeImage, a free, open source image library supporting all common bitmap formats. See http://freeimage.sourceforge.net for details
13:45:18: Supported formats: bmp,ico,jpg,jif,jpeg,jpe,jng,koa,iff,lbm,mng,pbm,pbm,pcd,pcx,pgm,pgm,png,ppm,ppm,ras,tga,targa,tif,tiff,wap,wbmp,wbm,psd,cut,xbm,xpm,gif,hdr,g3,sgi,rgb,rgba,bw,exr,j2k,j2c,jp2,pfm,pct,pict,pic,3fr,arw,bay,bmq,cap,cine,cr2,crw,cs1,dc2,dcr,drf,dsc,dng,erf,fff,ia,iiq,k25,kc2,kdc,mdc,mef,mos,mrw,nef,nrw,orf,pef,ptx,pxn,qtk,raf,raw,rdc,rw2,rwl,rwz,sr2,srf,srw,sti,webp,jxr,wdp,hdp
13:45:18: PVRTC codec registering
13:45:18: ETC codec registering
13:45:18: Registering ResourceManager for type HighLevelGpuProgram
13:45:18: Registering ResourceManager for type Compositor
13:45:18: MovableObjectFactory for type 'Entity' registered.
13:45:18: MovableObjectFactory for type 'Light' registered.
13:45:18: MovableObjectFactory for type 'BillboardSet' registered.
13:45:18: MovableObjectFactory for type 'ManualObject' registered.
13:45:18: MovableObjectFactory for type 'BillboardChain' registered.
13:45:18: MovableObjectFactory for type 'RibbonTrail' registered.
13:45:18: *-*-* OGRE Initialising
13:45:18: *-*-* Version 1.10.0unstable (Xalafu)
13:45:18: Creating resource group Essential
13:45:18: Added resource location 'media/thumbnails' of type 'FileSystem' to resource group 'Essential'
13:45:18: Added resource location 'media/packs/SdkTrays.zip' of type 'Zip' to resource group 'Essential'
13:45:18: Added resource location '.' of type 'FileSystem' to resource group 'General'
13:45:18: Added resource location './media/materials' of type 'FileSystem' to resource group 'General'
13:45:18: Added resource location './media/models' of type 'FileSystem' to resource group 'General'
13:45:24: OGRE EXCEPTION(6:FileNotFoundException): 'ogre.cfg' file not found! in ConfigFile::load at ..\..\OgreMain\src\OgreConfigFile.cpp (line 88)
13:45:24: OGRE EXCEPTION(6:FileNotFoundException): 'ogre.cfg' file not found! in ConfigFile::load at ..\..\OgreMain\src\OgreConfigFile.cpp (line 88)
As you can see it is complaining about something it isn't creating.


Thanks
codetemplar
Gnoblar
Posts: 22
Joined: Mon Nov 24, 2014 8:02 pm

Re: Building OGRE as static library - Visual studio 2013

Post by codetemplar »

The problem was that as it is a static library the resource files were not getting loaded. So now I have the config dialog screen showing me which rendering system to choose from. However my options are empty. This is usually populated by the render systems plugins dll files, however as I said im static linking theses in as lib files. How can I get this populated?

Its probably because the linker is skipping the render system library from the build as it appears like it wont be used.

Im getting this link error:
libRenderSystem_Direct3D9-vc120-mt-sgd-1_9_0.lib(OgreD3D9EngineDll.obj) : warning LNK4221: This object file does not define any previously undefined public symbols, so it will not be used by any link operation that consumes this library
Would forcing this to statically link solve this issue?

Thanks
User avatar
Kojack
OGRE Moderator
OGRE Moderator
Posts: 7157
Joined: Sun Jan 25, 2004 7:35 am
Location: Brisbane, Australia
x 534

Re: Building OGRE as static library - Visual studio 2013

Post by Kojack »

I don't know how up to date it is (I don't do static builds, so don't know the exact steps), but there's a page about it here: http://www.ogre3d.org/tikiwiki/tiki-ind ... ticLinking
Basically the problem is that render systems (and all other plugins like scene managers, particle effects, cg, etc) are typically initialised and added to the Ogre root automatically as they are loaded by plugins.cfg. But in a static link, no dynamic plugin loading is done (obviously). This means even if you link with the plugins and include their headers, they are never initialised. You need to do that manually.
For example, the particle system plugin requires something like this to be recognised: (put it after root is initialised, but before the config dialog)

Code: Select all

#include "OgreParticleFXPlugin.h"
 ..
 ..
 // Assumes mParticlePlugin is a member variable in your class somewhere
 mParticlePlugin = new ParticleFXPlugin();
 Root::getSingleton().installPlugin(mParticlePlugin);
The same is needed for the render systems, you need to create an instance of them then pass that pointer to ogre's root to install the plugin.
codetemplar
Gnoblar
Posts: 22
Joined: Mon Nov 24, 2014 8:02 pm

Re: Building OGRE as static library - Visual studio 2013

Post by codetemplar »

Perfect thank you. Who is responsible for deleting the plugin? Game or Ogre?


Thanks
User avatar
c6burns
Beholder
Posts: 1512
Joined: Fri Feb 22, 2013 4:44 am
Location: Deep behind enemy lines
x 138

Re: Building OGRE as static library - Visual studio 2013

Post by c6burns »

Since you call new, you are responsible for calling delete.
User avatar
blitzcoder
Halfling
Posts: 99
Joined: Wed Oct 09, 2019 4:06 am
x 18
Contact:

Re: Building OGRE as static library - Visual studio 2013

Post by blitzcoder »

Updating this old static build issue which I encountered exactly the same errors as the OP posted above.

The reason for this is OgreWin32Resources.rc.obj is being compiled but not linked to SampleBrowser:

viewtopic.php?p=554834#p554834

and not exclusive on VStudio but same on MinGW build.

New Blitz3D/BlitzBasic/BlitzMax Home - https://blitzcoder.org
Post Reply