OpenSceneGraph Forum Forum Index OpenSceneGraph Forum
Official forum which mirrors the existent OSG mailing lists. Messages posted here are forwarded to the mailing list and vice versa.
   FAQFAQ    SearchSearch    MemberlistMemberlist    RulesRules    UsergroupsUsergroups    RegisterRegister 
 Mail2Forum SettingsMail2Forum Settings  ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
   AlbumAlbum  OpenSceneGraph IRC ChatOpenSceneGraph IRC Chat   SmartFeedSmartFeed 

How I build OpenSceneGraph manually for desktop, mobile, and web

Post new topic   Reply to topic    OpenSceneGraph Forum Forum Index -> General
View previous topic :: View next topic  
Author Message

Joined: 01 Oct 2013
Posts: 308

PostPosted: Tue Aug 14, 2018 11:51 am    Post subject:
How I build OpenSceneGraph manually for desktop, mobile, and web
Reply with quote


Recently I've started building OpenSceneGraph without using official
CMakeLists.txt file. I've decided to describe why and how of this

1. WHY.

I use OpenSceneGraph to develop cross-platform applications. While
desktop builds work mostly fine, anything else (Android, iOS, Web) is
easy to break and hard to fix.

Here's my list of top annoying things I had to deal with frequently:

1.1. Inability to build Lua plugin out of the box on macOS

My project's CMakeLists.txt uses `ADD_DEFINITIONS("-std=c++11")` to
force C++11. This breaks Lua plugin building on macOS because Clang
says C language does not have `C++11`, which makes sense. However,
Linux's GCC simply warns about it.

1.2. Hacking PNG plugin safety checks for Android

To build OpenSceneGraph's PNG plugin for Android, I need to hack
CMake's PNG plugin detection because OpenSceneGraph's CMakeLists.txt
uses standard `FIND_PNG`. While this works fine on desktops, Android
sucks at supporting STL, exceptions, and other standard stuff in old
APIs. I personally target API 14.

1.3. Maintaining two different builds for iOS - simulator and device

You have to configure and work with two different versions of the same
application for both simulator and device. Which means you can't
switch between device and simulator in the single project. Not to
mention how many hacks went into OpenSceneGraph's CMakeLists.txt to
support iOS.

1.4. Building OpenSceneGraph takes A LOT of time

Even firing 10 parallel build processes with 'make -j10' is damn slow
because OpenSceneGraph has a ton of files.

2. HOW.

2.1. Build OpenSceneGraph as part of the project into static library

Here's CMakeLists.txt I currently use for all platforms except iOS:

2.2. Build OpenSceneGraph libraries from custom source files

Custom source files include OpenSceneGraph source files directly.
Here's how osgGA.cpp looks like:

This allows to build OpenSceneGraph multitudes time faster at the
expense of using more RAM during building.
As for plugins, I no longer need to hack my way through plugin
dependencies' safety checks, I simply include necessary source files.

2.3. Prepare OpenSceneGraph header files for each platform in advance

OpenSceneGraph and OpenThreads require different headers (osg/GL,
osg/Version, osg/Config, etc.) for different platforms and (probably)
compilers. I simply generated those headers by configuring stub

2.4. Build OpenSceneGraph as part of iOS project without CMakeLists.txt

Wrap all C++ files (.cpp extension) into Objective-C++ files (.mm
extension) and include them into Xcode project. Now you can switch
between simulator and device just like in other iOS projects.


OpenSceneGraph cross-platform examples now use described approach.
Check out how easy it is to build them for desktop, mobile, and web

Post generated by Mail2Forum
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    OpenSceneGraph Forum Forum Index -> General All times are GMT
Page 1 of 1

Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum

Similar Topics
Topic Author Forum Replies Posted
No new posts osgslice build failure on OSX ravidavi Build system [build] 5 Mon Sep 09, 2019 4:45 pm View latest post
No new posts Could not build for iOS drewpts Build system [build] 0 Sun Jul 28, 2019 11:24 am View latest post
No new posts OpenSceneGraph-3.6.4 released robertosfield General 1 Fri Jul 26, 2019 3:16 pm View latest post
No new posts OpenSceneGraph-3.6.4-rc9 tagged robertosfield General 0 Thu Jul 25, 2019 2:15 pm View latest post
No new posts An entity that could build OSG? Zachary1234 General 6 Tue Jul 23, 2019 5:19 am View latest post

Board Security Anti Bot Question MOD - phpBB MOD against Spam Bots
Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP