Compiling without 3D

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
LunaRebirth
Posts: 386
Joined: Sun May 11, 2014 12:13 am

Compiling without 3D

Post by LunaRebirth »

I'm building a 2D game for the web using Emscripten. With my code and the Irrlicht library (including with the Makefile containing CXXFLAG defines for -DNO_IRR_COMPILE_WITH_...) the .wasm file contains 8,000KB and the .wast contains 103,000KB. This is far too much.

I'm trying to compile Irrlicht to be as small as possible, so I'm removing things from the library that I don't need/won't use. This includes [all] 3D capabilities.
I can't simply remove linking the associated .o files without getting undefined symbols.

What steps would I need to take to strip down the Irrlicht library?

I know I would need to remove linking the .o file and make sure the .h is removed/commented out, but this isn't enough alone to be able to successfully compile Irrlicht.
CuteAlien
Admin
Posts: 9734
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: Compiling without 3D

Post by CuteAlien »

Yeah, I also got around 12MB I think. To get down from that I think you really have to modify the engine seriously and manually kick out things. Like removing scenenodes you don't use from the engine (like COctreeSceneNode, CTerrainSceneNode, etc). You get an idea which one will take up space simply by looking at the .o files. So basically you start by deleting a file and removing it from Makefile. Then check compile-errors and remove all references to those files.

It's the amount of features which makes it big. There are some larger ones (like serialization makes up nearly half an MB) which could still be defined out maybe (some work, but not too compilcated, it would be a patch that I would accept).

But maybe you don't even end up with all that in your application? emscripten compiler should be using static linking I think, so the end-size of you application might be a good deal smaller than the Irrlicht library. Thought if I remember right the emscripten compiler was really not that good at kicking out stuff.

What parts do you actually use for the 2D game. Irrlicht-gui? Any file-formats? Anything 3d?
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
LunaRebirth
Posts: 386
Joined: Sun May 11, 2014 12:13 am

Re: Compiling without 3D

Post by LunaRebirth »

I don't need anything 3D, so I just need 2D file formats like png, jpeg, bmp, etc. and the irrlicht gui.

For example, in the Makefile, because I don't need mesh, billboards, particles, animated objects, the scene manager, etc. I can remove the following:

Code: Select all

 
# removed $(IRRMESHOBJ) $(IRROBJ) $(IRRPARTICLEOBJ) $(IRRANIMOBJ) from below
LINKOBJ = \
    $(IRRVIDEOOBJ) $(IRRSWRENDEROBJ) $(IRRIOOBJ) $(IRROTHEROBJ) \
    $(IRRGUIOBJ) $(ZLIBOBJ) $(JPEGLIBOBJ) $(LIBPNGOBJ) $(LIBAESGM) \
    $(BZIP2OBJ) $(EXTRAOBJ)
 
I compile Irrlicht with the above (in green) taken out. No errors.

I then compile my 2D project and get the following errors:

Code: Select all

error: undefined symbol: _ZN3irr5scene18createSceneManagerEPNS_5video12IVideoDriverEPNS_2io11IFileSystemEPNS_3gui14ICursorControlEPNS7_15IGUIEnvironmentE
error: undefined symbol: _ZTTN3irr5scene16CMeshManipulatorE
error: undefined symbol: _ZTVN3irr5scene16CMeshManipulatorE
I am able to compile undefined symbols as warnings instead of errors, but then my game crashes on start-up.

So I search for where _ZTVN3irr5scene16CMeshManipulatorE might be coming from, so I search for "MeshManipulator".
It comes from the following files:
1. IMeshManipulator
2. ISceneManager
3. IVideoDriver
4. irrlicht
5. CNullDriver
6. Several files associated with mesh objects...

When I comment them all out and recompile Irrlicht, the results are the same. Still an undefined symbol for _ZTVN3irr5scene16CMeshManipulatorE.

Unless I am missing a file somewhere that I can't seem to find, where is this "undefined symbol" coming from?
CuteAlien
Admin
Posts: 9734
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: Compiling without 3D

Post by CuteAlien »

It should usually tell you the obj file in which you get that error exactly.

edit: As I notice you remove particles - those have a define NO_IRR_COMPILE_WITH_PARTICLES_.
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
LunaRebirth
Posts: 386
Joined: Sun May 11, 2014 12:13 am

Re: Compiling without 3D

Post by LunaRebirth »

It doesn't say which obj file.
The error is given during compiling the game with the irrlicht.a file, not while compiling irrlicht itself.
CuteAlien
Admin
Posts: 9734
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: Compiling without 3D

Post by CuteAlien »

Tricky. But you can compile the engine maybe with Makefile for mingw or so and get better linker errors there.
Sorry, can't help much right now, hope I'll be more back to Irrlicht once I got doing yearly taxes behind me (just spend 4 days in a row not doing them *sigh* should have coded Irrlicht instead).
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
CuteAlien
Admin
Posts: 9734
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: Compiling without 3D

Post by CuteAlien »

If you updated to newest svn version (r5806) you can try a few new defines:

NO_IRR_COMPILE_WITH_OCTREE_SCENENODE_
NO_IRR_COMPILE_WITH_TERRAIN_SCENENODE_
NO_IRR_COMPILE_WITH_SHADOW_VOLUME_SCENENODE_
NO_IRR_COMPILE_WITH_BILLBOARD_SCENENODE_
NO_IRR_COMPILE_WITH_WATER_SURFACE_SCENENODE_
NO_IRR_COMPILE_WITH_SKYDOME_SCENENODE_
NO_IRR_COMPILE_WITH_CUBE_SCENENODE_
NO_IRR_COMPILE_WITH_SPHERE_SCENENODE_

If you try then please tell me afterwards if they made any difference, I can add a few more (thought those are likely the biggest).
Might also help if you send me then a list of your obj files, sorted by size. Maybe I can see some more to reduce.
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
LunaRebirth
Posts: 386
Joined: Sun May 11, 2014 12:13 am

Re: Compiling without 3D

Post by LunaRebirth »

Thank you, that brought it down just a bit.

Compiling Irrlicht with Emscripten, here are the Irrlicht.a sizes:

Before any defines for NO_IRR_COMPILE_WITH:
43,415 KB
After NO_IRR_COMPILE_WITH (uncommented from the Makefile):
39,519 KB
After NO_IRR_COMPILE_WITH including the most recent svn version:
34,644 KB

That brought my .wasm down from 8,000 KB to 7,330 KB and my .wast from 103,000 KB to 90,000 KB.

.o sizes in order by bytes:

Code: Select all

COgreMeshFileLoader.o (944828)
COGLES2Driver.o (938528)
CSceneManager.o (789984)
CNullDriver.o (767936)
CAttributes.o (733868)
CMeshManipulator.o (689124)
CQuake3ShaderSceneNode.o (672860)
CSkinnedMesh.o (661036)
CQ3LevelMesh.o (640520)
CXMeshFileLoader.o (593796)
CWebGL1Driver.o (538360)
CLWOMeshFileLoader.o (536632)
CAnimatedMeshSceneNode.o (511972)
CCSMLoader.o (509180)
CPLYMeshFileLoader.o (508380)
CTextSceneNode.o (503248)
CAnimatedMeshHalfLife.o (493848)
CDMFLoader.o (489452)
COBJMeshFileLoader.o (485236)
CMY3DMeshFileLoader.o (464080)
CGUIEnvironment.o (450188)
C3DSMeshFileLoader.o (446164)
CAnimatedMeshMD3.o (430844)
CB3DMeshFileLoader.o (420568)
CGUITable.o (369180)
CGUIEditBox.o (353636)
CMS3DMeshFileLoader.o (347232)
CGeometryCreator.o (345768)
CLMTSMeshFileLoader.o (335060)
COCTLoader.o (331368)
CGUIListBox.o (327144)
CMeshSceneNode.o (323732)
CCameraSceneNode.o (322220)
CSMFMeshFileLoader.o (302404)
CGUITreeView.o (299704)
CGUITabControl.o (291768)
CSTLMeshFileLoader.o (289048)
CSkyBoxSceneNode.o (285916)
CGUIContextMenu.o (281936)
CLightSceneNode.o (280276)
CSceneCollisionManager.o (273904)
CGUIFont.o (272356)
CGUIColorSelectDialog.o (268240)
CGUIComboBox.o (264144)
CVolumeLightSceneNode.o (263392)
CGUIButton.o (260640)
CGUIStaticText.o (257720)
CAnimatedMeshMD2.o (255640)
CGUIMeshViewer.o (252460)
CBoneSceneNode.o (245792)
CDummyTransformationSceneNode.o (241140)
CB3DMeshWriter.o (240748)
CGUISpinBox.o (237820)
CGUIFileOpenDialog.o (237544)
CGUIScrollBar.o (235480)
CEmptySceneNode.o (232300)
CGUIWindow.o (228996)
CIrrDeviceSDL.o (220576)
CGUIMessageBox.o (217056)
CGUIProfiler.o (213640)
CGUICheckBox.o (211744)
CGUIMenu.o (211176)
CTriangleSelector.o (209112)
CSceneNodeAnimatorCameraFPS.o (206484)
CGUIImage.o (204592)
COctreeTriangleSelector.o (195576)
CGUIModalScreen.o (195420)
CGUIToolBar.o (194404)
CGUIInOutFader.o (191556)
CFileSystem.o (189360)
CGUISpriteBank.o (186044)
CMD2MeshFileLoader.o (184188)
COGLES2MaterialRenderer.o (168860)
COGLES2FixedPipelineRenderer.o (162276)
CZipReader.o (159328)
CImage.o (157500)
CGUISkin.o (150664)
CParticleAnimatedMeshSceneNodeEmitter.o (147244)
CIrrDeviceConsole.o (140992)
CSceneNodeAnimatorCameraMaya.o (137720)
CSceneNodeAnimatorTexture.o (136444)
CIrrDeviceStub.o (114648)
COGLES2ParallaxMapRenderer.o (110696)
CSceneNodeAnimatorFollowSpline.o (108784)
COGLES2NormalMapRenderer.o (108520)
CEGLManager.o (106308)
CMountPointReader.o (104372)
CTriangleBBSelector.o (101784)
CSceneNodeAnimatorCollisionResponse.o (99716)
CDefaultSceneNodeFactory.o (97600)
CNPKReader.o (96372)
CProfiler.o (95352)
Irrlicht.o (93580)
CWADReader.o (91492)
CTarReader.o (90644)
CImageLoaderPVR.o (90640)
COGLES2Renderer2D.o (90540)
CImageLoaderRGB.o (84424)
CMeshCache.o (84040)
CImageLoaderJPG.o (83648)
CMetaTriangleSelector.o (81896)
CPakReader.o (81208)
CFileList.o (79148)
CSceneLoaderIrr.o (78300)
CImageLoaderPPM.o (75368)
CImageLoaderDDS.o (74924)
CImageLoaderWAL.o (74692)
CImageLoaderBMP.o (72200)
CImageLoaderPSD.o (71504)
COGLES2ExtensionHandler.o (70972)
CImageLoaderPNG.o (67408)
CImageLoaderPCX.o (66300)
CImageLoaderTGA.o (66096)
CDefaultSceneNodeAnimatorFactory.o (65916)
CColorConverter.o (59736)
CSceneNodeAnimatorFlyStraight.o (59492)
CVideoModeList.o (56912)
CBSPMeshFileLoader.o (55700)
CSceneNodeAnimatorFlyCircle.o (55004)
CLogger.o (52152)
CMemoryFile.o (50108)
CMeshTextureLoader.o (48980)
COSOperator.o (48372)
CSceneNodeAnimatorRotation.o (46204)
CMD3MeshFileLoader.o (45888)
CSceneNodeAnimatorDelete.o (42236)
CDefaultGUIElementFactory.o (40340)
CLimitReadFile.o (39672)
CGUIImageList.o (38484)
CReadFile.o (36648)
CImageWriterPSD.o (36488)
CWriteFile.o (36484)
os.o (31512)
CSoftwareDriver2.o (21560)
COGLESDriver.o (21512)
COpenGLDriver.o (21464)
utf8.o (15548)
CSoftwareDriver.o (8816)
CDepthBuffer.o (8756)
CZBuffer.o (8080)
CTRTextureGouraudVertexAlpha2.o (7340)
CTRTextureLightMapGouraud2_M4.o (7340)
CTRTextureLightMap2_Add.o (7324)
CTRTextureLightMap2_M4.o (7320)
CTRTextureLightMap2_M1.o (7316)
CTRTextureLightMap2_M2.o (7316)
CTRTextureDetailMap2.o (7304)
CTRTextureGouraud2.o (7296)
CTRTextureWire2.o (7296)
CTRTextureGouraudAlphaNoZ.o (7292)
CTRTextureGouraudAddNoZ2.o (7288)
CTRGouraudAlpha2.o (7280)
CTRTextureGouraudAlpha.o (7276)
CTRTextureGouraudAdd2.o (7268)
CTRTextureGouraudNoZ2.o (7268)
CTRGouraudAlphaNoZ2.o (7256)
CTRGouraud2.o (7252)
CTRStencilShadow.o (7240)
CTRTextureBlend.o (7236)
CTRNormalMap.o (7220)
CFPSCounter.o (7064)
CXMLReader.o (6640)
CBurningShader_Raster_Reference.o (5128)
CXMLWriter.o (5036)
irrXML.o (5024)
CTRTextureGouraudNoZ.o (3148)
CTRTextureGouraudWire.o (2768)
CTRTextureGouraudAdd.o (2764)
CTRTextureFlatWire.o (2748)
CTRTextureGouraud.o (2744)
CTRGouraudWire.o (2728)
CTRTextureFlat.o (2728)
CTRFlatWire.o (2708)
CTRGouraud.o (2704)
CTRFlat.o (2684)
COpenGLShaderMaterialRenderer.o (1472)
CD3D9HLSLMaterialRenderer.o (1464)
CD3D9ShaderMaterialRenderer.o (1464)
COpenGLParallaxMapRenderer.o (1464)
COpenGLSLMaterialRenderer.o (1464)
CParticleAttractionAffector.o (1464)
CParticleRotationAffector.o (1464)
CD3D9ParallaxMapRenderer.o (1460)
COpenGLNormalMapRenderer.o (1460)
CParticleCylinderEmitter.o (1460)
CParticleFadeOutAffector.o (1460)
CParticleGravityAffector.o (1460)
CParticleSystemSceneNode.o (1460)
CTerrainTriangleSelector.o (1460)
CD3D9NormalMapRenderer.o (1452)
COGLESExtensionHandler.o (1452)
COpenGLExtensionHandler.o (1452)
CParticleMeshEmitter.o (1452)
CParticlePointEmitter.o (1452)
CParticleRingEmitter.o (1452)
CParticleScaleAffector.o (1452)
CParticleSphereEmitter.o (1452)
CShadowVolumeSceneNode.o (1452)
CWaterSurfaceSceneNode.o (1452)
CBillboardSceneNode.o (1440)
CColladaFileLoader.o (1440)
CColladaMeshWriter.o (1440)
CIrrMeshFileLoader.o (1440)
COctreeSceneNode.o (1440)
COpenGLCacheHandler.o (1440)
CParticleBoxEmitter.o (1440)
CSkyDomeSceneNode.o (1440)
CSoftwareTexture.o (1440)
CSoftwareTexture2.o (1440)
CSphereSceneNode.o (1440)
CTerrainSceneNode.o (1440)
CImageWriterBMP.o (1432)
CImageWriterJPG.o (1432)
CImageWriterPCX.o (1432)
CImageWriterPNG.o (1432)
CImageWriterPPM.o (1432)
CImageWriterTGA.o (1432)
CIrrDeviceLinux.o (1432)
CIrrDeviceWin32.o (1432)
CCubeSceneNode.o (1428)
CD3D9Texture.o (1428)
CIrrDeviceFB.o (1428)
CIrrMeshWriter.o (1428)
COBJMeshWriter.o (1428)
CPLYMeshWriter.o (1428)
CSTLMeshWriter.o (1428)
IBurningShader.o (1428)
CD3D9Driver.o (1420)
CGLXManager.o (1420)
CWGLManager.o (1420)
leakHunter.o (1420)
CuteAlien
Admin
Posts: 9734
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: Compiling without 3D

Post by CuteAlien »

You can still disable a few of those with compile flags. Maybe go over IrrCompileConfig.h and check for all you don't need. For example for 2d I suppose you don't need 3d mesh-loaders and no bone animations.
Disabling NO_IRR_COMPILE_WITH_SKINNED_MESH_SUPPORT_ will already disable a bunch of loaders.
NO_IRR_COMPILE_WITH_BSP_LOADER_ will disable all the quake-node and loader stuff.

You can likely disable all loaders you see in IrrCompileConfig.h between NO_IRR_COMPILE_WITH_IRR_MESH_LOADER_ and NO_IRR_COMPILE_WITH_SMF_LOADER_

Also you still seem to use writers - until you write out stuff disable them all.

Then check if you need all image formats, disable those you don't need (p.E. wal, ppm, psd, bmp)
And probably all image writers.

Not sure why some stuff like software-renderer still shows up with so many KB even thought it should be disabled already (well, around 140kb, so not too bad).

Btw... for 2D you might consider using SDL instead. It's very well supported by emscripten (Irrlicht uses SDL actually for WebGL). And should be much smaller.
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
LunaRebirth
Posts: 386
Joined: Sun May 11, 2014 12:13 am

Re: Compiling without 3D

Post by LunaRebirth »

You're right, I was able to remove much more.
Thanks, I've got ideas on defines to add on my own. Perhaps I'll commit them, if it's necessary.

Speaking of,
CB3DMeshWriter.cpp contains the define for _IRR_COMPILE_WITH_B3D_WRITER_, it shouldn't.
I tried to commit the change myself but got a Permission Denied error.
CuteAlien
Admin
Posts: 9734
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: Compiling without 3D

Post by CuteAlien »

Thanks, that was indeed wrong. Fixed now svn.

And sorry, you can't commit. But you can create patches by calling "svn diff" and send those to me (or put them online for example in the bug/patch tracker). No promise about applying them all as I don't want to pepper the whole code with defines.

Thought given the sizes you have posted, it seems Irrlicht is only responsible for 1/3 of your final size. So maybe try to figure what else is taking up space.
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