1

I am a beginner in programming and compiling C++. I am currently trying to build a very basic OGRE application on OSX (10.10) using g++ compiler and makefile. My makefile is based on the one provided on cleversoap's github repository. I am also using a prebuilt version of the SDK for OSX.

When I first tried to build the tutorial framework from the OGRE 3D webiste, I ended up with multiple linking errors related to the Ogre objects and functions definitions. I edited the source file leaving only those few lines of code.

#include <OgreRoot.h>
#include <OgreCamera.h>
#include <OgreSceneManager.h>
#include <OgreRenderWindow.h>
#include <OgreLogManager.h>
#include <OgreViewport.h>
#include <OgreEntity.h>
#include <OgreWindowEventUtilities.h>
#include <OgrePlugin.h>

int main() {
    Ogre::Root* mRoot;
    mRoot = new Ogre::Root("", "", "LowLevelOgre.log");
    delete mRoot;
}

My compile command resulting of the makefile looks like this:

g++ LowLevelOgre.cpp -o OgreMake.app/Contents/MacOS/OgreMake -arch i386 -I/Developer/SDKs/OgreSDK/include/OGRE -I/Developer/SDKs/OgreSDK/include/OGRE/OSX -I/Developer/SDKs/OgreSDK/include/OIS -I/Developer/SDKs/OgreSDK/boost -L/Developer/SDKs/OgreSDK/lib/release -lOIS -F/System/Library/Frameworks -F/Library/Frameworks -framework Carbon -framework AppKit -framework Foundation -framework IOKit -F/Developer/SDKs/OgreSDK/lib/release -framework Cg -framework Ogre

Even though the linker does not complain about the Ogre.framework, I get this error basically meaning that the Ogre::Root definition is missing. (At least I think)

Undefined symbols for architecture x86_64:
"Ogre::Root::Root(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&)", referenced from:
_main in main-3183b9.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [all] Error 1

I cannot seem to find what is causing this linking error. Is there anything I am missing or I may have misunderstood?

Gentle Moose
  • 161
  • 5
  • Use nm or strings and check if libOIS contains the above mentioned symbol. – doptimusprime Jan 20 '15 at 03:40
  • I don't really know how it could help. The OIS library is basically to manage mouse and keyboard inputs. I know that the Ogre::Root header file is contained in the Ogre.framework. – Gentle Moose Jan 20 '15 at 19:10
  • I assume doptimusprime meant Ogre and not OIS, since the allegedly not found symbol is an Ogre core object. What Ogre version are you using? Did you compile it yourself and are sure that that was successful and the symbol is indeed included in your library? – Philip Allgaier Jan 20 '15 at 23:04
  • I talked to our official Ogre OS X maintainer and his advise was to use clang instead with "-std=c++11 -stdlib=libc++" (given that g++ has been deprecated by Apple in favor of clang). Have a look at this answer: http://stackoverflow.com/questions/13752233/using-clang-with-libc-and-c11-from-the-command-line-with-mac-os-x – Philip Allgaier Jan 21 '15 at 00:37
  • @Philip Allgaier Thanks for your answer. I am using the prebuilt SDK version 1.9 for MacOS X. I also installed g++ version 4.8.4 with brew and have the same error as with the apple version (4.2.1 I think). When I use the "-std=c++11 -stdlib=libc++" with clang (version 6.0 of apple if I'm right) I get three errors and a bunch of warnings (as you can see [here](http://pastebin.com/BWZkjq4Q)) I think it's still related to some missing definitions. I also get very similar warning and errors using g++ with the "-std=c++11 -stdlib=libc++" flags. – Gentle Moose Jan 21 '15 at 01:45

0 Answers0