Scons build with Ogre

Problems building or running the engine, queries about how to use features etc.
Post Reply
User avatar
bana
Greenskin
Posts: 132
Joined: Mon Aug 02, 2004 7:40 am
Location: Austin, Texas
Contact:

Scons build with Ogre

Post by bana »

I am trying to get my program to compile with Scons and I can get it including the Ogre library okay but I really don't know how to point all my source files at the Ogre.h etc.. locations in a cross platform way from within scons. Here's what the file looks like so far:

Code: Select all

env = Environment()
conf = Configure(env)

if conf.CheckLib('libode'):
        print 'Good, you have the ODE lib'
if conf.CheckLib('libOgreMain'):
        print 'Good, you have OGRE'

SConscript(['src/SConscript'])
SConscript(['dependencies/tiny/SConscript'])

env = conf.Finish()
with the src SConscript looking like this:

Code: Select all

list = ['Builder.cpp', 'CollideableObject.cpp', 'Container.cpp', 'GameIterator.cpp', 'GameStateController.cpp', 'InGameInputHandler.cpp', 'InGameMenuInputHandler.cpp', 'MenuInputHandler.cpp', 'NamedObject.cpp', 'NCGLog.cpp', 'OpenFragApplication.cpp', 'openFrag.cpp','Physics.cpp', 'PhysicsCube.cpp' , 'WalkInputHandler.cpp']

Object(list,LIBS=['tinyXML','OgreMain','OgrePlatform'],LIBPATH=['#/dependencies/tiny/' , '/usr/local/lib/'])
Yet I get things like this:

Code: Select all

[bana@localhost techdemo_v6]$ scons
scons: Reading SConscript files ...
Checking for main() in C library libode... yes
Good, you have the ODE lib
Checking for main() in C library libOgreMain... yes
Good, you have OGRE
scons: done reading SConscript files.
scons: Building targets ...
g++ -c -o src/Builder.o src/Builder.cpp
src/Builder.cpp:5:18: Ogre.h: No such file or directory
In file included from src/Builder.cpp:6:
src/../include/Builder.h:31: error: `Ogre' has not been declared
src/../include/Builder.h:31: error: `String' has not been declared
Also I would like to replace the /usr/local/lib path with something more extensible to. I am a little overwhelmed by some of the Scons documentation (not knowing much python and all).
A proud member of the OpenFrag Coding Team.
http://coolhands.blogspot.com/
User avatar
Clay
OGRE Community Helper
OGRE Community Helper
Posts: 518
Joined: Wed Mar 17, 2004 4:14 am
x 1
Contact:

Post by Clay »

g++ -c -o src/Builder.o src/Builder.cpp
This is your problem here, though I'm not quite sure how to fix it. You will need to define a -I[path_to_ogre_headers] on that command line.

Tisba is our resident scons expert, perhaps he could shed some light on this. I'm planning on using scons for my next project. We'll see how that turns out.

Edit: What you are looking to do is set your CXXFLAGS environment variable to contain -I[path_to_ogre_headers]. I am not sure how this is done.

Code: Select all

env = Environment( CXXFLAGS='-I[]' )
Might be it, but I'm not certain. I don't fully understand how that env variable is being used in the SConscript I have here.
User avatar
bana
Greenskin
Posts: 132
Joined: Mon Aug 02, 2004 7:40 am
Location: Austin, Texas
Contact:

Post by bana »

Ahh good I got it by putting your CXXFLAGS='-I[]' in the src/SConscript like this:

Code: Select all

Object(list,LIBS=['tinyXML','OgreMain','OgrePlatform'],LIBPATH=['#/dependencies/tiny/' , '/usr/local/lib/'], CXXFLAGS='-I/usr/local/include/OGRE/')
From this page: http://www.scons.org/doc/HTML/scons-user/x838.html

Now as for a cross platform/portable way of doing this... beats me :) although I would like to know, I gather its something to do with system.os.getLibFolder() or something like that :)

With this addition, I am now getting these kinds of errors:

Code: Select all

[bana@localhost techdemo_v6]$ scons
scons: Reading SConscript files ...
Checking for main() in C library libode... yes
Good, you have the ODE lib
Checking for main() in C library libOgreMain... yes
Good, you have OGRE
scons: done reading SConscript files.
scons: Building targets ...
g++ -I/usr/local/include/OGRE/ -c -o src/Builder.o src/Builder.cpp
In file included from /usr/local/include/OGRE/OgrePrerequisites.h:88,
                 from /usr/local/include/OGRE/Ogre.h:28,
                 from src/Builder.cpp:5:
/usr/local/include/OGRE/OgreStdHeaders.h:30:23: hash_set: No such file or directory
/usr/local/include/OGRE/OgreStdHeaders.h:31:23: hash_map: No such file or directory
In file included from /usr/local/include/OGRE/OgreAnimation.h:30,
                 from /usr/local/include/OGRE/Ogre.h:30,
                 from src/Builder.cpp:5:
/usr/local/include/OGRE/OgreString.h:64: error: expected init-declarator before '<' token
/usr/local/include/OGRE/OgreString.h:64: error: expected `;' before '<' token
/usr/local/include/OGRE/OgreString.h:172: error: expected init-declarator before '<' token
/usr/local/include/OGRE/OgreString.h:172: error: expected `,' or `;' before '<' token
In file included from /usr/local/include/OGRE/OgreArchiveManager.h:30,
                 from /usr/local/include/OGRE/Ogre.h:33,
                 from src/Builder.cpp:5:
/usr/local/include/OGRE/OgreResourceManager.h:342: error: ISO C++ forbids declaration of `hash_map' with no type
Do I need to somehow point scons to the boost or STL library?
A proud member of the OpenFrag Coding Team.
http://coolhands.blogspot.com/
User avatar
Clay
OGRE Community Helper
OGRE Community Helper
Posts: 518
Joined: Wed Mar 17, 2004 4:14 am
x 1
Contact:

Post by Clay »

User avatar
bana
Greenskin
Posts: 132
Joined: Mon Aug 02, 2004 7:40 am
Location: Austin, Texas
Contact:

Post by bana »

Excellent :D After adding the commands from pkg-config Ogre --cflags like this:

Code: Select all

Object(list,LIBS=['tinyXML','OgreMain','OgrePlatform'] , LIBPATH=['#/dependencies/tiny/' , '/usr/local/lib/'], CXXFLAGS=['-I/usr/local/include/OGRE/','-DGCC_3_1', '-DEXT_HASH'])
Looks like I'm now onto errors of my own devising :) Thanks
A proud member of the OpenFrag Coding Team.
http://coolhands.blogspot.com/
User avatar
Clay
OGRE Community Helper
OGRE Community Helper
Posts: 518
Joined: Wed Mar 17, 2004 4:14 am
x 1
Contact:

Post by Clay »

Anytime.

Though if you want OTHER people to use that SConscript, you'll eventually need to figure out how to run that pkg-config inside SConscript. Also be sure to do the same thing with libs that you did with cflags, just in case.

Woot! 200th post.
Robbob
Kobold
Posts: 27
Joined: Mon Apr 28, 2003 12:13 pm
Location: UK

Post by Robbob »

try

env.ParseConfig( "pkg-config OGRE --cflags --libs" )

Rob
User avatar
bana
Greenskin
Posts: 132
Joined: Mon Aug 02, 2004 7:40 am
Location: Austin, Texas
Contact:

Post by bana »

Ahh that looks excellent Robbob thx, although what about windows? Pkg-config isn't used in windows right? And how do I automatically generate VS.NET project files from scons? (I have heard this is possible but saw nothing in the userguide).
A proud member of the OpenFrag Coding Team.
http://coolhands.blogspot.com/
User avatar
:wumpus:
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 3067
Joined: Tue Feb 10, 2004 12:53 pm
Location: The Netherlands
x 1

Post by :wumpus: »

On windows it's much harder; as there is no pkg-config facility you should either assume OGRE is in the default include/lib path, or ask the user (yech).
Fredz
Greenskin
Posts: 122
Joined: Wed May 26, 2004 1:45 pm
Location: Perpignan, France

Post by Fredz »

In fact, pkg-config does exist for MS Windows (and I don't mean only for Cygwin), it's been used by the GTK+ port and the Mono and GTK# ones too I think. You can have more information about it on this page :
http://cvs.osafoundation.org/viewcvs.cg ... 2?rev=HEAD
and you can download it there :
http://www.gimp.org/~tml/gimp/win32/downloads.html
User avatar
bana
Greenskin
Posts: 132
Joined: Mon Aug 02, 2004 7:40 am
Location: Austin, Texas
Contact:

Post by bana »

Thanks for the links Fredz but that would require all windows users (to compile at least) to install pkg-config which might be a lot of work compared to just using VS.NET

Another problem I've been having lately is that when using:

Code: Select all

env.ParseConfig( "pkg-config OGRE --cflags --libs" ) 
The -DEXT_HASH and -DGCC_3_1 flags are added fine when compiling but when linking all the object files together, these flags are no longer used creating all the hash_map errors that I was getting earlier. Any way to add these to some linking flags?
A proud member of the OpenFrag Coding Team.
http://coolhands.blogspot.com/
Post Reply