I am working on a project to get myself back in to c++ and one I will hopefully be using in the future as well. The main thing I am working on right now is to make a wrapper around open al so it can more easily be accessed in my code. I have a sound object that will hold a buffer and a source, so you can play it with simply methods like soundname.play(), etc. I also store a map of strings and ALuint's to hold file name and their associated buffers, as to not load a buffer with the same file as another. However, I get a linker error when using visual studio 2010. The offending line (as far as I can tell is:
static map\ buffers;
The error I get (it's very cryptic, and googling returns very few helpfull results):
1>Sound.obj error LNK2001: unresolved external symbol "private: static class std::map\,class std::allocator\ >,unsigned int,struct std::less\,class std::allocator\ > >,class std::allocator\,class std::allocator\ > const ,unsigned int> > > Sound::buffers" (<?buffers@Sound@@0V?>\<$map@V?>\\$basic_\\$char_\<$allocator@D@2@@std@@IU?>\<$less@V?>\\$basic_\\$char_\<$allocator@D@2@@std@@@2@V?>\<$allocator@U?>\\$pair@\\$\\$CBV?\\$basic_\\$char_\<$allocator@D@2@@std@@I@std@@@2@@std@@A>)
1>C:\Users\Owner\Documents\Visual Studio 2010\Projects\audio stuff\Debug\audio stuff.exe : fatal error LNK1120: 1 unresolved externals
I have linked the following libraries:
I have an idea that it has to do with the ALuint in the map, but I'm not sure how to correct it. Any help is appreciated.
It's saying the 'buffers' variable can't be found by the linker. My guess is that you probably haven't defined it. If that line you posted appears in your class definition, that's a declaration of the 'buffers' variable (it tells the compiler that such a variable exists, and allows it to compile code referring to that variable) but it doesn't actually define it (allocate storage for it). In a source file someplace (not a header), you need to add a line:
map<string, ALuint> Sound::buffers;
That should fix the problem.
By the way, most of the spew in that error message is just the fully-expanded definition of that std::map type, including a bunch of optional template parameters that pretty much no one ever uses (but which can be used to do things like store the items in a different order than usual, allocate memory a different way than usual, etc.)
Were you able to fix your linking problem? If you want to see how I wrapped OpenAL in my own C++ class objects have a look here: http://www.marek-knows.com/downloads.php5?vmk=audioEng