Newbie and static linking

Problems building or running the engine, queries about how to use features etc.
Post Reply
spectre1989
Gnoblar
Posts: 15
Joined: Mon Oct 01, 2012 10:32 am
x 1

Newbie and static linking

Post by spectre1989 »

Hi all,

I'm an Ogre newbie, I've been interested in the project for quite some time, but never quite managed to get started. Anyway, I've spent 5 years working on Unity games, but in about a month I'm starting my first C++ game dev job. I'd like to build some stuff with Ogre in the intervening time, as I've got very little experience of writing C++ games with an engine, it's always been all my own code before.

So a couple of questions - I'd firstly quite like to have the ogre source and dependencies in my project along with my source code. The reason for this is basically so I can hack stuff in Ogre and poke around in the inner workings, without having to do that in a seperate project, compile, copy lib to the other project, etc. Is this actually possible? As mentioned before, my experience of linking against libraries is fairly limited. Would I be right in thinking that this wouldn't be slower than statically linking assuming I hadn't changed the Ogre source code since the last build? Finally, last time I had a stab at Ogre there were C++11 issues so I gave up. I've found some threads which suggest that C++11 now plays nicely with Ogre, is this correct?

Cheers
Spec
User avatar
LJS
Greenskin
Posts: 138
Joined: Wed Jan 09, 2013 8:58 pm
x 6

Re: Newbie and static linking

Post by LJS »

Maybe you should use ogre first, get to know it before you start at the end. Of course you can poke around in the code, but again, get to now it as it is first. Thta goes for intermediate level too. Ogre only does the graphics so you need to link (or profide your own and... link) to other libs such as audio, physics or some other collision lib.

Linking to dynamic libs will be faster regarding to statically linking libs. In the latter the binairies will be copied into your executable. Runtime performance won't be effected as far as I know.

Don't know nothing about c++11 - is just as cool 8)


R,
(am very clumbsy, especially with words on a static screen.)
Ogre 3D 1.9.0 static
Bullet 2.8 static
User avatar
areay
Bugbear
Posts: 819
Joined: Wed May 05, 2010 4:59 am
Location: Auckland, NZ
x 69

Re: Newbie and static linking

Post by areay »

I think if you've been using Unity then you're in for a bit of a shock. Unity is a full game engine, all the enginey bits are done for you. Ogre is just a renderer, you need to plumb in all the input, sound, network, level editting (and more) bits and pieces to make it useful.

Regarding using two different applications, well, you can do this but the model resources will probably be in different formats so you'll have to export them all twice. You might be able to share shader code but keep the projects separate in your IDE.

My advice is to start with the tutorials then take it from there.
spectre1989
Gnoblar
Posts: 15
Joined: Mon Oct 01, 2012 10:32 am
x 1

Re: Newbie and static linking

Post by spectre1989 »

Yeah don't worry I've written simple C++ game engines in the past, so I've dealt with input/sound/networking/physics before, I just wanted to use Ogre as rendering was always a pretty major chunk of the overall work. I literally just wanted to know about building ogre from source as part of a game project - which is possible, as at this stage I have managed it. The other part on C++11 I have yet to clarify, but it builds ok in Visual Studio, I have yet to try clang. I would have thought that libc++ will probably be ok too, given that I'm building the dependencies from source too.
User avatar
LJS
Greenskin
Posts: 138
Joined: Wed Jan 09, 2013 8:58 pm
x 6

Re: Newbie and static linking

Post by LJS »

you said:
As mentioned before, my experience of linking against libraries is fairly limited
Linking is very easy, just tell the compiler to do so (all compiler have their own specs I think, only used VS myself). Just make sure you link debugs against debug and releases against release. For this - and most other - a suffix would be used for debug library names (*_d.lib, *_debug.dll or whatever).

And don't make invisible typos - you will be driven mad as it can find 'a' lib. I know from experience. grmphf.

Assuming - from your last post - you've written all in one executable, splitting things up in different libs will have their advantages such as faster compilation but also easier access to all those you need in testing applications.

R,
(am very clumbsy, especially with words on a static screen.)
Ogre 3D 1.9.0 static
Bullet 2.8 static
User avatar
c6burns
Beholder
Posts: 1512
Joined: Fri Feb 22, 2013 4:44 am
Location: Deep behind enemy lines
x 138

Re: Newbie and static linking

Post by c6burns »

Will you really be hacking around in Ogre, or simply integrating Ogre into your framework (which would be hacking around in your framework)? One requires you to recompile Ogre many times, and the other does not. IMHO Static vs Dynamic doesn't really make much difference in this instance (single process using library with no licensing restrictions).

I don't see why there would be c++11 issues. Ogre does not use c++11 but you are free to use it in your own framework which links against Ogre.
spectre1989
Gnoblar
Posts: 15
Joined: Mon Oct 01, 2012 10:32 am
x 1

Re: Newbie and static linking

Post by spectre1989 »

c6burns wrote:Will you really be hacking around in Ogre, or simply integrating Ogre into your framework (which would be hacking around in your framework)? One requires you to recompile Ogre many times, and the other does not. IMHO Static vs Dynamic doesn't really make much difference in this instance (single process using library with no licensing restrictions).

I don't see why there would be c++11 issues. Ogre does not use c++11 but you are free to use it in your own framework which links against Ogre.
I do intend to hack around in the Ogre source code, which would require recompiling, but I'd rather not have to switch between two projects. Though I guess I could just have them as two projects in one solution.

In the past I had issues when compiling for C++11, though these were largely due to those compilers allowing behaviour in the past that they shouldn't have done - e.g. vectors of incomplete types.
User avatar
c6burns
Beholder
Posts: 1512
Joined: Fri Feb 22, 2013 4:44 am
Location: Deep behind enemy lines
x 138

Re: Newbie and static linking

Post by c6burns »

Out of curiosity what parts of Ogre will you be hacking around in?

Are you sure std::vectors of incomplete types has anything to do with c++11? AFAIK those have been rejected by the standard since the beginning and the pressure on the committee was to fix that issue and allow them (like boost has)
User avatar
LJS
Greenskin
Posts: 138
Joined: Wed Jan 09, 2013 8:58 pm
x 6

Re: Newbie and static linking

Post by LJS »

spectre1989: Though I guess I could just have them as two projects in one solution.
If you do, you can see if Ogre is green on the inside too while debugging your own source.

If you use visual studio (maybe other IDEs too) don't check the project dependencies to make sure the ogre source isn't build again when you hit 'rebuild project'. So when you poke around in there, you have to explicitly (re)build ogre.
(am very clumbsy, especially with words on a static screen.)
Ogre 3D 1.9.0 static
Bullet 2.8 static
spectre1989
Gnoblar
Posts: 15
Joined: Mon Oct 01, 2012 10:32 am
x 1

Re: Newbie and static linking

Post by spectre1989 »

c6burns wrote:Out of curiosity what parts of Ogre will you be hacking around in?

Are you sure std::vectors of incomplete types has anything to do with c++11? AFAIK those have been rejected by the standard since the beginning and the pressure on the committee was to fix that issue and allow them (like boost has)
It wasn't C++11 that was the problem as such, but just that the new implementation of std::vector didn't allow for incomplete types (as the standard states), whereas previously it had allowed them (which is shouldn't have done).
User avatar
c6burns
Beholder
Posts: 1512
Joined: Fri Feb 22, 2013 4:44 am
Location: Deep behind enemy lines
x 138

Re: Newbie and static linking

Post by c6burns »

Standard containers have never allowed incomplete types.
spectre1989
Gnoblar
Posts: 15
Joined: Mon Oct 01, 2012 10:32 am
x 1

Re: Newbie and static linking

Post by spectre1989 »

c6burns wrote:Standard containers have never allowed incomplete types.
They have never supposed to, but some past implementations of them have allowed it incorrectly.
Post Reply