Domanda

I'm beginner in ogre3D and I'm build mi first program in Ogre3D, but when I try to compile the program I get this error:

In function `main':
test.cpp:(.text+0x14): undefined reference to `std::allocator<char>::allocator()'
test.cpp:(.text+0x30): undefined reference to `std::basic_string<char,                                                                 
std::char_traits<char>, std::allocator<char> >::basic_string(char const*, 
std::allocator<char> const&)'

test.cpp:(.text+0x40): undefined reference to `std::allocator<char>::allocator()'
test.cpp:(.text+0x5c): undefined reference to `std::basic_string<char,    
std::char_traits<char>, std::allocator<char> >::basic_string(char const*,   
std::allocator<char> const&)'

test.cpp:(.text+0x6c): undefined reference to `std::allocator<char>::allocator()'
test.cpp:(.text+0x88): undefined reference to `std::basic_string<char,  
std::char_traits<char>, std::allocator<char> >::basic_string(char const*,  
std::allocator<char> const&)' 

And Continue the fix

  1. I Compile the program manually:
gcc test.cpp  -o test.o test

And my file test is this:

#include <Ogre.h>

using namespace Ogre;

int main()
{
Root* root= new Root();

if( !root->restoreConfig() )
{
    root->showConfigDialog();
    root->saveConfig();
}
return 0;
}

How to fix my problem?

I'm use Debian Wheezy.

The Version Ogre3D: 1.8

Thanks for your answers.

È stato utile?

Soluzione

This is a linker error. Use pkg-config --libs to retrieve the correct linker options

g++ -o test test.cpp -Wall $(pkg-config --cflags OGRE) $(pkg-config --libs OGRE) -lboost_system

If you have installed OGRE in a nonstandard location (say /opt/ogre), you may need to call pkg-config with the PKG_CONFIG_PATH environment variable set:

PKG_CONFIG_PATH=/opt/ogre/lib/pkgconfig pkg-config --libs OGRE

Altri suggerimenti

This is a linker error, but not to Ogre3d, but to the STL (Standard Template Library). The reason for this is that you are using gcc, when you should be using g++. However, I am surprised that you aren't getting linker errors to Ogre as well, and the solution to that is like Thomas suggested (though he also uses "g++" in his example).

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top