Allegro.cc - Online Community

Allegro.cc Forums » Programming Questions » Dev-C++ and STL?

This thread is locked; no one can reply to it. rss feed Print
Dev-C++ and STL?
Hano Wair
Member #5,243
November 2004
avatar

Hi,

I've created a snake game wich works and compiles very well under Linux. Since Allegro is platform independent I'm now trying to get it working under Windows too. I've set up dev-c++ to link with the Allegro libraries and that isn't the problem. But I get this linker errors:

Quote:

znake.o(.text+0x30):znake.cpp: undefined reference to `__gxx_personality_sj0'
znake.o(.text+0x74):znake.cpp: undefined reference to `operator new[](unsigned)'
znake.o(.text+0x82):znake.cpp: undefined reference to `std::string::string()'

znake.o(.text+0x97):znake.cpp: undefined reference to `std::string::string()'
znake.o(.text+0xac):znake.cpp: undefined reference to `std::string::string()'
znake.o(.text+0xc1):znake.cpp: undefined reference to `std::string::string()'
znake.o(.text+0xd6):znake.cpp: undefined reference to `std::string::string()'
znake.o(.text+0x112):znake.cpp: undefined reference to `std::basic_stringstream<char, std::char_traits<char>, std::allocator<char> >::basic_stringstream(std::_Ios_Openmode)'
znake.o(.text+0x135):znake.cpp: undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*)'
znake.o(.text+0x146):znake.cpp: undefined reference to `std::ostream::operator<<(int)'
znake.o(.text+0x156):znake.cpp: undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*)'
znake.o(.text+0x16e):znake.cpp: undefined reference to `std::basic_stringstream<char, std::char_traits<char>, std::allocator<char> >::str() const'
znake.o(.text+0x190):znake.cpp: undefined reference to `std::string::operator=(std::string const&)'
znake.o(.text+0x1b6):znake.cpp: undefined reference to `std::string::~string()'
znake.o(.text+0x1df):znake.cpp: undefined reference to `std::string::~string()'
znake.o(.text+0x1ea):znake.cpp: undefined reference to `std::string::c_str() const'
znake.o(.text+0x204):znake.cpp: undefined reference to `std::basic_ifstream<char, std::char_traits<char> >::basic_ifstream(char const*, std::_Ios_Openmode)'
znake.o(.text+0x21f):znake.cpp: undefined reference to `std::basic_ios<char, std::char_traits<char> >::eof() const'
znake.o(.text+0x24f):znake.cpp: undefined reference to `std::istream::getline(char*, int)'
znake.o(.text+0x261):znake.cpp: undefined reference to `std::string::operator=(char const*)'

znake.o(.text+0x288):znake.cpp: undefined reference to `std::string::find(char const*, unsigned) const'
znake.o(.text+0x2a9):znake.cpp: undefined reference to `std::string::substr(unsigned, unsigned) const'
znake.o(.text+0x2cb):znake.cpp: undefined reference to `std::string::operator=(std::string const&)'
znake.o(.text+0x2f1):znake.cpp: undefined reference to `std::string::~string()'
znake.o(.text+0x31a):znake.cpp: undefined reference to `std::string::~string()'
znake.o(.text+0x341):znake.cpp: undefined reference to `std::string::find(char const*, unsigned) const'
znake.o(.text+0x362):znake.cpp: undefined reference to `std::string::find(char const*, unsigned) const'
znake.o(.text+0x386):znake.cpp: undefined reference to `std::string::substr(unsigned, unsigned) const'
znake.o(.text+0x3a8):znake.cpp: undefined reference to `std::string::operator=(std::string const&)'
znake.o(.text+0x3ce):znake.cpp: undefined reference to `std::string::~string()'
znake.o(.text+0x3f7):znake.cpp: undefined reference to `std::string::~string()'
znake.o(.text+0x41e):znake.cpp: undefined reference to `std::string::find(char const*, unsigned) const'
znake.o(.text+0x43f):znake.cpp: undefined reference to `std::string::find(char const*, unsigned) const'
znake.o(.text+0x463):znake.cpp: undefined reference to `std::string::substr(unsigned, unsigned) const'
znake.o(.text+0x485):znake.cpp: undefined reference to `std::string::operator=(std::string const&)'
znake.o(.text+0x54b):znake.cpp: undefined reference to `std::string::~string()'
znake.o(.text+0x574):znake.cpp: undefined reference to `std::string::~string()'
znake.o(.text+0x57f):znake.cpp: undefined reference to `std::string::c_str() const'
znake.o(.text+0x598):znake.cpp: undefined reference to `std::string::c_str() const'
znake.o(.text+0x5b1):znake.cpp: undefined reference to `std::string::c_str() const'
znake.o(.text+0x612):znake.cpp: undefined reference to `std::basic_ifstream<char, std::char_traits<char> >::close()'
znake.o(.text+0x790):znake.cpp: undefined reference to `std::basic_ifstream<char, std::char_traits<char> >::~basic_ifstream()'
znake.o(.text+0x7b6):znake.cpp: undefined reference to `std::basic_ifstream<char, std::char_traits<char> >::~basic_ifstream()'
znake.o(.text+0x7dc):znake.cpp: undefined reference to `std::basic_stringstream<char, std::char_traits<char>, std::allocator<char> >::~basic_stringstream()'
znake.o(.text+0x802):znake.cpp: undefined reference to `std::basic_stringstream<char, std::char_traits<char>, std::allocator<char> >::~basic_stringstream()'
znake.o(.text+0x825):znake.cpp: undefined reference to `std::string::~string()'
znake.o(.text+0x848):znake.cpp: undefined reference to `std::string::~string()'
znake.o(.text+0x86b):znake.cpp: undefined reference to `std::string::~string()'
znake.o(.text+0x88e):znake.cpp: undefined reference to `std::string::~string()'
znake.o(.text+0x8b1):znake.cpp: undefined reference to `std::string::~string()'
znake.o(.text+0x8d4):znake.cpp: more undefined references to `std::string::~string()' follow
znake.o(.text+0x1266):znake.cpp: undefined reference to `std::cout'
znake.o(.text+0x126b):znake.cpp: undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*)'
znake.o(.text+0x1273):znake.cpp: undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::endl<char, std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&)'
znake.o(.text+0x127b):znake.cpp: undefined reference to `std::ostream::operator<<(std::ostream& (*)(std::ostream&))'
znake.o(.text+0x1326):znake.cpp: undefined reference to `std::cout'
znake.o(.text+0x132b):znake.cpp: undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*)'
znake.o(.text+0x1333):znake.cpp: undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::endl<char, std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&)'
znake.o(.text+0x133b):znake.cpp: undefined reference to `std::ostream::operator<<(std::ostream& (*)(std::ostream&))'
znake.o(.text+0x1423):znake.cpp: undefined reference to `std::cout'
znake.o(.text+0x1428):znake.cpp: undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*)'
znake.o(.text+0x1430):znake.cpp: undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::endl<char, std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&)'
znake.o(.text+0x1438):znake.cpp: undefined reference to `std::ostream::operator<<(std::ostream& (*)(std::ostream&))'
znake.o(.text+0x14f0):znake.cpp: undefined reference to `std::cout'
znake.o(.text+0x14f5):znake.cpp: undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*)'
znake.o(.text+0x14fd):znake.cpp: undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::endl<char, std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&)'
znake.o(.text+0x1505):znake.cpp: undefined reference to `std::ostream::operator<<(std::ostream& (*)(std::ostream&))'
znake.o(.text+0x22f0):znake.cpp: undefined reference to `__gxx_personality_sj0'
znake.o(.text+0x2483):znake.cpp: undefined reference to `operator new[](unsigned)'
znake.o(.text+0x24a4):znake.cpp: undefined reference to `std::basic_ifstream<char, std::char_traits<char> >::basic_ifstream(char const*, std::_Ios_Openmode)'
znake.o(.text+0x24cb):znake.cpp: undefined reference to `std::istream::getline(char*, int)'
znake.o(.text+0x24d9):znake.cpp: undefined reference to `std::basic_ifstream<char, std::char_traits<char> >::close()'
znake.o(.text+0x256e):znake.cpp: undefined reference to `std::basic_ifstream<char, std::char_traits<char> >::~basic_ifstream()'
znake.o(.text+0x25ad):znake.cpp: undefined reference to `std::basic_ifstream<char, std::char_traits<char> >::~basic_ifstream()'
znake.o(.text+0x2632):znake.cpp: undefined reference to `__gxx_personality_sj0'
znake.o(.text+0x2679):znake.cpp: undefined reference to `std::ios_base::Init::Init()'
znake.o(.text+0x2866):znake.cpp: undefined reference to `std::ios_base::Init::~Init()'
znake.o(.text$_ZNSt6vectorI5CTileSaIS0_EE13_M_insert_auxEN9__gnu_cxx17__normal_iteratorIPS0_S2_EERKS0_+0xf):znake.cpp: undefined reference to `__gxx_personality_sj0'
znake.o(.text$_ZNSt6vectorI5CTileSaIS0_EE13_M_insert_auxEN9__gnu_cxx17__normal_iteratorIPS0_S2_EERKS0_+0x213):znake.cpp: undefined reference to `__cxa_begin_catch'
znake.o(.text$_ZNSt6vectorI5CTileSaIS0_EE13_M_insert_auxEN9__gnu_cxx17__normal_iteratorIPS0_S2_EERKS0_+0x259):znake.cpp: undefined reference to `__cxa_rethrow'
znake.o(.text$_ZNSt6vectorI5CTileSaIS0_EE13_M_insert_auxEN9__gnu_cxx17__normal_iteratorIPS0_S2_EERKS0_+0x28e):znake.cpp: undefined reference to `__cxa_end_catch'
znake.o(.text$_ZNSt6vectorI11CSnakeBlockSaIS0_EE13_M_insert_auxEN9__gnu_cxx17__normal_iteratorIPS0_S2_EERKS0_+0xf):znake.cpp: undefined reference to `__gxx_personality_sj0'
znake.o(.text$_ZNSt6vectorI11CSnakeBlockSaIS0_EE13_M_insert_auxEN9__gnu_cxx17__normal_iteratorIPS0_S2_EERKS0_+0x21f):znake.cpp: undefined reference to `__cxa_begin_catch'
znake.o(.text$_ZNSt6vectorI11CSnakeBlockSaIS0_EE13_M_insert_auxEN9__gnu_cxx17__normal_iteratorIPS0_S2_EERKS0_+0x265):znake.cpp: undefined reference to `__cxa_rethrow'
znake.o(.text$_ZNSt6vectorI11CSnakeBlockSaIS0_EE13_M_insert_auxEN9__gnu_cxx17__normal_iteratorIPS0_S2_EERKS0_+0x29a):znake.cpp: undefined reference to `__cxa_end_catch'
znake.o(.text$_ZNSt6vectorI6CAppleSaIS0_EE13_M_insert_auxEN9__gnu_cxx17__normal_iteratorIPS0_S2_EERKS0_+0xf):znake.cpp: undefined reference to `__gxx_personality_sj0'

znake.o(.text$_ZNSt6vectorI6CAppleSaIS0_EE13_M_insert_auxEN9__gnu_cxx17__normal_iteratorIPS0_S2_EERKS0_+0x1fe):znake.cpp: undefined reference to `__cxa_begin_catch'
znake.o(.text$_ZNSt6vectorI6CAppleSaIS0_EE13_M_insert_auxEN9__gnu_cxx17__normal_iteratorIPS0_S2_EERKS0_+0x241):znake.cpp: undefined reference to `__cxa_rethrow'
znake.o(.text$_ZNSt6vectorI6CAppleSaIS0_EE13_M_insert_auxEN9__gnu_cxx17__normal_iteratorIPS0_S2_EERKS0_+0x26d):znake.cpp: undefined reference to `__cxa_end_catch'
znake.o(.text$_ZNSt6vectorI5CTileSaIS0_EED1Ev+0xc):znake.cpp: undefined reference to `__gxx_personality_sj0'
znake.o(.text$_ZNSt6vectorI6CAppleSaIS0_EED1Ev+0xc):znake.cpp: undefined reference to `__gxx_personality_sj0'
znake.o(.text$_ZNSt6vectorI11CSnakeBlockSaIS0_EED1Ev+0xc):znake.cpp: undefined reference to `__gxx_personality_sj0'
znake.o(.text$_ZNSt14__simple_allocI11CSnakeBlockSt24__default_alloc_templateILb1ELi0EEE10deallocateEPS0_j+0x1d):znake.cpp: undefined reference to `std::__default_alloc_template<true, 0>::deallocate(void*, unsigned)'
znake.o(.text$_ZNSt14__simple_allocI6CAppleSt24__default_alloc_templateILb1ELi0EEE10deallocateEPS0_j+0x1d):znake.cpp: undefined reference to `std::__default_alloc_template<true, 0>::deallocate(void*, unsigned)'
znake.o(.text$_ZNSt14__simple_allocI5CTileSt24__default_alloc_templateILb1ELi0EEE10deallocateEPS0_j+0x23):znake.cpp: undefined reference to `std::__default_alloc_template<true, 0>::deallocate(void*, unsigned)'
znake.o(.text$_ZNSt14__simple_allocI5CTileSt24__default_alloc_templateILb1ELi0EEE8allocateEj+0x27):znake.cpp: undefined reference to `std::__default_alloc_template<true, 0>::allocate(unsigned)'
znake.o(.text$_ZNSt14__simple_allocI11CSnakeBlockSt24__default_alloc_templateILb1ELi0EEE8allocateEj+0x1d):znake.cpp: undefined reference to `std::__default_alloc_template<true, 0>::allocate(unsigned)'
znake.o(.text$_ZNSt14__simple_allocI6CAppleSt24__default_alloc_templateILb1ELi0EEE8allocateEj+0x1d):znake.cpp: undefined reference to `std::__default_alloc_template<true, 0>::allocate(unsigned)'

make.exe: *** [znake.exe] Error 1

Execution terminated

I'm compiling as C++. Wich libraries will I need to include in order to use the std:: stuff?

Thanks :)

Richard Phipps
Member #1,632
November 2001
avatar

Hano Wair
Member #5,243
November 2004
avatar

You mean:

#include <vector>
#include <string>
#include <sstream>
#include <iostream>
#include <fstream>

?

Of course I did ;). Btw, I've added using namespace std; below it

X-G
Member #856
December 2000
avatar

Sounds like you compiled with "gcc" instead of "g++".

--
Since 2008-Jun-18, democracy in Sweden is dead. | 悪霊退散!悪霊退散!怨霊、物の怪、困った時は ドーマン!セーマン!ドーマン!セーマン! 直ぐに呼びましょう陰陽師レッツゴー!

Hano Wair
Member #5,243
November 2004
avatar

Even when I use the "override build command" option and replace gcc with g++ it comes up with the same erros.

Richard Phipps
Member #1,632
November 2001
avatar

ok, show us the command line text before the errors. :)

Hano Wair
Member #5,243
November 2004
avatar

Whoops, my bad :-X. I clicked the wrong button after changing gcc into g++. But now it comes up with some other errors:

Quote:

Compiler: Default compiler
Building Makefile: "C:\Kipmans\znake\Makefile.win"
Executing make clean
rm -f znake.o znake.exe

g++ znake.cpp -o znake.o ../allegro/lib/mingw32/liballeg.a

gcc.exe znake.o -o "znake.exe" -L"C:/Dev-Cpp/lib" -mwindows ../allegro/lib/mingw32/liballeg.a

znake.o(.text+0x0):sstream-inst.cc: multiple definition of `mainCRTStartup'
C:/Dev-Cpp/Bin/../lib/gcc-lib/mingw32/3.3.1/../../../crt2.o(.text+0x0):crt1.c: first defined here

znake.o(.text+0x20):sstream-inst.cc: multiple definition of `WinMainCRTStartup'
C:/Dev-Cpp/Bin/../lib/gcc-lib/mingw32/3.3.1/../../../crt2.o(.text+0x20):crt1.c: first defined here
znake.o(.text+0x40):sstream-inst.cc: multiple definition of `atexit'
C:/Dev-Cpp/Bin/../lib/gcc-lib/mingw32/3.3.1/../../../crt2.o(.text+0x40):crt1.c: first defined here
znake.o(.text+0x60):sstream-inst.cc: multiple definition of `_onexit'
C:/Dev-Cpp/Bin/../lib/gcc-lib/mingw32/3.3.1/../../../crt2.o(.text+0x60):crt1.c: first defined here
znake.o(.text+0x280):sstream-inst.cc: multiple definition of `__do_sjlj_init'
C:/Dev-Cpp/Bin/../lib/gcc-lib/mingw32/3.3.1/crtbegin.o(.text+0x0):crtstuff.c: first defined here
znake.o(.data+0x0):stl-inst.cc: multiple definition of `_argc'
C:/Dev-Cpp/Bin/../lib/gcc-lib/mingw32/3.3.1/../../../crt2.o(.data+0x0):crt1.c: first defined here
znake.o(.data+0x4):stl-inst.cc: multiple definition of `_argv'
C:/Dev-Cpp/Bin/../lib/gcc-lib/mingw32/3.3.1/../../../crt2.o(.data+0x4):crt1.c: first defined here

make.exe: *** [znake.exe] Error 1

Execution terminated

It seems there's still something wrong with the libs or something.

X-G
Member #856
December 2000
avatar

Quote:

gcc.exe znake.o -o "znake.exe" -L"C:/Dev-Cpp/lib" -mwindows ../allegro/lib/mingw32/liballeg.a

--
Since 2008-Jun-18, democracy in Sweden is dead. | 悪霊退散!悪霊退散!怨霊、物の怪、困った時は ドーマン!セーマン!ドーマン!セーマン! 直ぐに呼びましょう陰陽師レッツゴー!

Hano Wair
Member #5,243
November 2004
avatar

Even when I run that command manually but with g++ instead of gcc it gives the same errors.

[edit]
Anyone? I need to get this finished before 20:00 (GMT+1) tonight :P

Matt Smith
Member #783
November 2000

-l../allegro/lib/mingw32/liballeg.a

or, when allegro is installed properly (in Dev-Cpp\lib), just ..

-lalleg

The way you've done it will include the whole of allegro in each .o file

Hano Wair
Member #5,243
November 2004
avatar

Same errors. Even when I put this in a bat file and run it:

Quote:

g++ znake.cpp -o znake.o -lalleg
g++ znake.o -o "znake.exe" -L"C:/Dev-Cpp/lib" -mwindows -lalleg

When I use this command line:

Quote:

g++ znake.cpp -o "znake.exe" -mwindows -lalleg

It compiles but then the program crashes immediately after starting it.

[edit]
It compiles :D (with g++ znake.cpp -o znake -lalleg) but when running the game the SCREEN FLICKERS LIKE HELL, though i'm using page flipping. What could be the problem with that?

Dustin Dettmer
Member #3,935
October 2003
avatar

Thats going to be an issue in your own code. We can't really help you with that unless you have a specific problem with example code etc.

Go to: