Vector push_back causing linker errors
Hi i'm having a lot of trouble with the stl vector. It keeps throwing me linker errors whenever I try to use push_back.
The errors I am getting are:
[Linker error] undefined reference to `std::_GLIBCPP_mutex_init('
[Linker error] undefined reference to `std::_GLIBCPP_once'
[Linker error] undefined reference to `std::_GLIBCPP_mutex'
[Linker error] undefined reference to std::_GLIBCPP_mutex_address_init()'
there are a few more but they are all very similar.
In a class I have the line
vector<char*> textureNames;
and in the same header file i have
#include <vector>
using namespace std;
and in one of the methods:
textureNames.push_back("hello");
If i comment out that line, everything compiles. This has me stumped and I cant find any info on the errors. So any help would be great, i'm using Dev C++.
Thanks
Kazade.
Member of the NeHe team.
I know this is not the same but still. Why don't you use: std::vector<std::string> textureNames;
You should never let your fears become the boundaries of your dreams.
Thats what i was using, i changed it so that i could find what exactly was going wrong :)
Member of the NeHe team.
Hm.. Are you linking against right librarys (single/multi-threaded)
You should never let your fears become the boundaries of your dreams.
I think so, everything else is working fine, the moment i use stl it throws those errors at me.
Member of the NeHe team.
Probably someone using Dev C++ should know a bit more, but I'm almost sure this comes form library mismatch, since errors are from linker and the term 'mutex' comes form multithreading enviroment.
You should never let your fears become the boundaries of your dreams.
I had a very similar error on a recent DevC++ project but for the life of me I can't remember how I fixed it, I'm sure it had something to do with multiple #include's of the same header: I think I just did a #ifndef #define..#endif around the code and that fixed it.
Sorry I couldn't be of more help mate :(
Sorry I couldn't be of more help mate :(
--
Cheers,
Darren Clark
Cheers,
Darren Clark
It's ok, I got it fixed, I had to completely uninstall dev c++, reinstall it, then install different versions of wxWidgets one at a time to make it work. It must have been something to do with that, i forgot to mention it in my post i didnt think it would be related. Still not sure exactly what was wrong, but its working now so i dont care ;)
Cheers guys.
Kazade.
Cheers guys.
Kazade.
Member of the NeHe team.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement