[SDL] Can't use vector push_back with SDL

Eric Lilja mindcooler at gmail.com
Sun Jul 23 02:51:06 PDT 2006


Glenn McCord wrote:
> I'm struggling to get rid of my LINK errors and I've isolated it to
> the use of vector's push_back(). I would really like to use it so any
> help would be appreciated.
>
> I'm using Visual Studio 2005 and I've scaled my program all the way
> down to this:
>
> #include <windows.h>
> #include <vector>
>
> //SDL related libraries
> #include <stdio.h>
> #include <SDL/SDL.h>
>
> using namespace std;
>
> int main( int argc, char* args[] )
> {
>    vector<int> vList;
>    vList.push_back(2);
>    return 0;
> }
>
>
> Not much to look at but it throws these errors
> Error    1    error LNK2019: unresolved external symbol
> __imp___CrtDbgReportW referenced in function "public: __thiscall
> std::_Vector_const_iterator<int,class std::allocator<int>
>>> :_Vector_const_iterator<int,class std::allocator<int> >(int *,class
> std::_Container_base const *)"
> (??0?$_Vector_const_iterator at HV?$allocator at H@std@@@std@@QAE at PAHPBV_Container_base@1@@Z)
> main.obj
>
> Error    2    error LNK2019: unresolved external symbol _SDL_main
> referenced in function _main    SDLmain.lib

I got the same error if I failed to link with SDLmain.lib. When I link with 
both libs it builds fine, but issues a warning:
Compiling...

sdltest.cpp

Linking...

MSVCRTD.lib(cinitexe.obj) : warning LNK4098: defaultlib 'msvcrt.lib' 
conflicts with use of other libs; use /NODEFAULTLIB:library

My test program was identical with yours but I removed the two unnecessary 
includes <windows.h> and <stdio.h>

>
> If I comment out vList.push_back(2); then the program compiles
>
> I have done:
> Linker->Input->Additional Dependencies = SDL.lib SDLmain.lib
> Runtime library = Multi-threaded DLL (/MD)
>
> I figured half a day trying was long enough so here I am, posting to a
> mailing list.
>
> Thanks,
>
> Glenn

/ E 







More information about the SDL mailing list