Simple Program
Mar 22, 2010 at 5:41pm UTC
I made this program to duplicate an error I'm receiving. When I run the program I receive:
Snake.obj : error LNK2019: unresolved external symbol
__imp___CrtDbgReportW referenced in function "public: __thiscall
std::_Vector_const_iterator<short,class std::allocator<short>
>::_Vector_const_iterator<short,class std::allocator<short> >(short *,class
std::_Container_base_secure const *)"
(??0?$_Vector_const_iterator@FV?$allocator@F@std@@@std@@QAE@PAFPBV_Container_base_secure@1@@Z)
I've looked up information about LNK2019 and LNK2001 in multiple forums, on MSVC, and other websites, but the information didn't really seem to apply.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
#pragma comment(lib, "SDL.lib")
#pragma comment(lib, "SDLmain.lib")
#pragma comment(lib, "SDL_TTF.lib")
#pragma comment(lib, "SDL_image.lib")
#include <vector>
#include <string>
#include "SDL.h"
#include "SDL_TTF.h"
#include "SDL_image.h"
using namespace std;
class Test {
public :
Test();
private :
vector<vector<short >> myvar;
};
Test::Test()
: myvar ()
{
//Uncommenting these two lines,
//it will report LNK2001 instead of LNK2019
//vector<short> test (2, 10);
//this->myvar.push_back(test);
myvar.resize(1);
}
SDL_Event testevent;
int main( int argc, char * args[] ) {
bool genericloop = true ;
while ( genericloop ) {
SDL_PollEvent( &testevent );
if ( testevent.type == SDL_QUIT ) genericloop = false ;
}
return 0;
}
Does anyone have any ideas? Thanks!
-Aaron
Mar 22, 2010 at 7:44pm UTC
Hey Aaron. First I'll say that I'm no expert (you probably know more than I do about this)...I'm just hoping to learn something too (and nobody else is replying). You may have already seen it, but I found what looks to be a very relevant thread on MSDN:
http://social.msdn.microsoft.com/Forums/en/vcgeneral/thread/5e126c79-77f3-4d50-a47f-a9ce35cff0a4
If that doesn't help, would I be right in saying that the linker errors have nothing do with the SDL-related code, but rather with std::vector?
I built the following code without a problem (same as yours, but with all SDL references taken out). Perhaps you could try just building this (just an idea)...
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
#include <vector>
#include <string>
using namespace std;
class Test
{
public :
Test();
private :
vector<vector<short >> myvar;
};
Test::Test()
: myvar ()
{
vector<short > test (2, 10);
this ->myvar.push_back(test);
myvar.resize(1);
}
int main( int argc, char * args[] ) {
Test mytest = Test();
bool genericloop = true ;
...
}
It probably won't help, but I thought I'd give it a shot. I'll keep an eye on this thread so that I can learn what's going on here too...
Topic archived. No new replies allowed.