Thread: LNK1120 error

  1. #1
    Registered User
    Join Date
    Aug 2010

    LNK1120 error

    I'm learning genetic algorithms and am having a linking error. The code compiles fine, but something is wrong with the linking part. I pruned out all the unneeded code. The problems somewhere in the function void init_population(ga_vector &population). I'm using Visual C++ 2008.

    I've removed everything except the bare frame for SDL and am still get the linking error.

    1>main.obj : error LNK2019: unresolved external symbol __imp___CrtDbgReportW referenced in function "public: __thiscall std::_Vector_const_iterator<struct ga_struct,class std::allocator<struct ga_struct> >::_Vector_const_iterator<struct ga_struct,class std::allocator<struct ga_struct> >(struct ga_struct *,class std::_Container_base_secure const *)" (??0?$_Vector_const_iterator@Uga_struct@@V?$alloca tor@Uga_struct@@@std@@@std@@QAE@PAUga_struct@@PBV_ Container_base_secure@1@@Z)

    fatal error LNK1120: 1 unresolved externals

    #include <SDL.h>
    #include <string>
    #include <vector>
    #define GA_POPSIZE				2048				// ga population size
    #define GA_MOVES				80					// movement points
    struct ga_struct
    	std::string str;
    	unsigned int fitness;
    	float matingPossibility;
    typedef std::vector<ga_struct> ga_vector;
    void init_population(ga_vector &population)
    	int moves = GA_MOVES * 2;
    	int pSize = GA_POPSIZE;
    	for(int i = 0; i < pSize; i++)
    		ga_struct citizen;
  = 0;
    		citizen.matingPossibility = 0.0f;
    		for(int j = 0; j < moves; j++)
    			citizen.str += (rand()%2) + 48;
    int main( int argc, char* args[] )
        //Start SDL
    	ga_vector pop_alpha;
        //Quit SDL
        return 0;    
    I've googled LNK1120 and it is sometimes a problem with the prototypes. I've tried a lot of different combinations, but haven't had any luck.

    Thanks for reading over it.

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    The edge of the known universe
    _CrtDbgReport, _CrtDbgReportW (CRT)

    Debug versions of C run-time libraries only.
    You need to link with the debug libraries.
    There's a link in the quoted text, on that site
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Testing some code, lots of errors...
    By Sparrowhawk in forum C Programming
    Replies: 48
    Last Post: 12-15-2008, 04:09 AM
  2. Post...
    By maxorator in forum C++ Programming
    Replies: 12
    Last Post: 10-11-2005, 08:39 AM
  3. Dikumud
    By maxorator in forum C++ Programming
    Replies: 1
    Last Post: 10-01-2005, 06:39 AM
  4. Learning OpenGL
    By HQSneaker in forum C++ Programming
    Replies: 7
    Last Post: 08-06-2004, 08:57 AM
  5. Couple C questions :)
    By Divx in forum C Programming
    Replies: 5
    Last Post: 01-28-2003, 01:10 AM