iOS apps and static linking

Discussion of issues specific to mobile platforms such as iOS, Android, Symbian and Meego.
spectre1989
Gnoblar
Posts: 15
Joined: Mon Oct 01, 2012 10:32 am
x 1

iOS apps and static linking

Post by spectre1989 »

Hi there,

I'm starting to make an iOS game using Ogre3D. I built Ogre and its dependencies using XCode without CMake (I got errors, and I wanted to build with llvm and libc++) successfully after a couple of weeks of muddling through it in my evenings. Though I have it.. I don't trust it, because I had to edit some of the source code in Ogre to get it to build for libc++. So, I've gone back to the prebuilt SDK download, I've heard you can't release apps which use 3rd party dylibs - does that mean I eventually will need to build Ogre from source and hardcode the plugins?

Cheers
Joe
User avatar
masterfalcon
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 4270
Joined: Sun Feb 25, 2007 4:56 am
Location: Bloomington, MN
x 126

Re: iOS apps and static linking

Post by masterfalcon »

Well, I'm not sure how you managed to build a dylib for iOS. But yes, you do need to statically link Ogre on iOS.
spectre1989
Gnoblar
Posts: 15
Joined: Mon Oct 01, 2012 10:32 am
x 1

Re: iOS apps and static linking

Post by spectre1989 »

masterfalcon wrote:Well, I'm not sure how you managed to build a dylib for iOS. But yes, you do need to statically link Ogre on iOS.
I didn't build a dylib, I just dragged all the Ogre source code into the XCode project for my game - but as I said, I don't trust that I've done it correctly, and I don't want to come up against some obscure bug which takes weeks to fix, which turns out to be because I built Ogre wrong!

My question is - will I eventually have to compile Ogre from source, so that I can hardcode the plugins? The pre-built SDK for iOS seems to still load plugins at runtime, or am I mistaken?
User avatar
masterfalcon
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 4270
Joined: Sun Feb 25, 2007 4:56 am
Location: Bloomington, MN
x 126

Re: iOS apps and static linking

Post by masterfalcon »

It would probably be better to build it from source. And you're right Ogre does load plugins at runtime. But it's not loading them from a dynamic library. The plugins are statically linked and they are initialized at runtime.
spectre1989
Gnoblar
Posts: 15
Joined: Mon Oct 01, 2012 10:32 am
x 1

Re: iOS apps and static linking

Post by spectre1989 »

masterfalcon wrote:It would probably be better to build it from source. And you're right Ogre does load plugins at runtime. But it's not loading them from a dynamic library. The plugins are statically linked and they are initialized at runtime.
Ah I see. Out of interest, why is it better to build from source? Might I run into problems if I'm using libc++ but Ogre and its dependencies are using libstdc++?
User avatar
masterfalcon
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 4270
Joined: Sun Feb 25, 2007 4:56 am
Location: Bloomington, MN
x 126

Re: iOS apps and static linking

Post by masterfalcon »

That's definitely possible.
spectre1989
Gnoblar
Posts: 15
Joined: Mon Oct 01, 2012 10:32 am
x 1

Re: iOS apps and static linking

Post by spectre1989 »

masterfalcon wrote:That's definitely possible.
So is that the reason why building from source is better? Or are there other factors? Sorry to ask so many questions, I'm really new to Ogre..
User avatar
masterfalcon
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 4270
Joined: Sun Feb 25, 2007 4:56 am
Location: Bloomington, MN
x 126

Re: iOS apps and static linking

Post by masterfalcon »

Just to make it easier to build really. As long as you have your CFLAGS and OgreBuildSettings.h set up right then you could compile it into your own project. You may or may not run into link errors with libc++ and the dependencies, I haven't tried in a while.
spectre1989
Gnoblar
Posts: 15
Joined: Mon Oct 01, 2012 10:32 am
x 1

Re: iOS apps and static linking

Post by spectre1989 »

masterfalcon wrote:Just to make it easier to build really. As long as you have your CFLAGS and OgreBuildSettings.h set up right then you could compile it into your own project. You may or may not run into link errors with libc++ and the dependencies, I haven't tried in a while.
Mmkay.. Perhaps I'll tussle with CMake again and try to generate a project again.. As I wrote in this thread I managed to work around the errors I got from building Ogre with libc++ by using boost containers, but at some point it'd be good to have a proper fix. Anyway, thanks for all your help, I've got plenty to crack on with now =)