Thread: Linker Errors

  1. #1
    Darkness Prevails Dark_Phoenix's Avatar
    Join Date
    Oct 2006
    Location
    Houston, Texas
    Posts
    174

    Linker Errors

    I am getting a lot of linker errors (unresolved external symbol) that reference '_String_base::_Xlen ' and '_Xran'. I have done a bit of googleing and have come up with no usable information so I thought I would ask some more knowledgable people.

    I am not sure what these functions (?) do or what header / lib / dll they are in, much less what file is trying to include them.
    Is there a lib that I need to link to or a header that I need to include?

    Sorry if I am being a little cryptic in my description, my morning coffee has not quite kicked in yet :P
    BTW, it is a DirextX app and I am using Code::Blocks. Just started with c::b and still learning how it works so it might just be a setting that I do not have right. Anyway, here are the errors that I am getting.
    Code:
    GameApp.obj:: error LNK2019: unresolved external symbol "public: void __thiscall std::_String_base::_Xran(void)const " (?_Xran@_String_base@std@@QBEXXZ) referenced in function "public: class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > & __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::erase(unsigned int,unsigned int)" (?erase@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAEAAV12@II@Z)
    Framework.obj:: error LNK2001: unresolved external symbol "public: void __thiscall std::_String_base::_Xran(void)const " (?_Xran@_String_base@std@@QBEXXZ)
    StateManager.obj:: error LNK2001: unresolved external symbol "public: void __thiscall std::_String_base::_Xran(void)const " (?_Xran@_String_base@std@@QBEXXZ)
    Utility.obj:: error LNK2001: unresolved external symbol "public: void __thiscall std::_String_base::_Xran(void)const " (?_Xran@_String_base@std@@QBEXXZ)
    GameApp.obj:: error LNK2019: unresolved external symbol "public: void __thiscall std::_String_base::_Xlen(void)const " (?_Xlen@_String_base@std@@QBEXXZ) referenced in function "protected: bool __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::_Grow(unsigned int,bool)" (?_Grow@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@IAE_NI_N@Z)
    Framework.obj:: error LNK2019: unresolved external symbol "public: void __thiscall std::_String_base::_Xlen(void)const " (?_Xlen@_String_base@std@@QBEXXZ) referenced in function "public: void __thiscall CFramework::Pause(bool,bool)" (?Pause@CFramework@@QAEX_N0@Z)
    StateManager.obj:: error LNK2001: unresolved external symbol "public: void __thiscall std::_String_base::_Xlen(void)const " (?_Xlen@_String_base@std@@QBEXXZ)
    Utility.obj:: error LNK2001: unresolved external symbol "public: void __thiscall std::_String_base::_Xlen(void)const " (?_Xlen@_String_base@std@@QBEXXZ)
    Using Code::Blocks and Windows XP

    In every hero, there COULD be a villain!

  2. #2
    Officially An Architect brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,396
    Looks like some internal linkage error caused by not linking with the C++ library. Details on OS/compiler/IDE if any?

    I'm assuming String_base is not something you wrote (if it is, bad on you for putting it in std:: )

  3. #3
    (?<!re)tired Mario F.'s Avatar
    Join Date
    May 2006
    Location
    Ireland
    Posts
    8,446
    I don't think you are linking with the MFC library
    Originally Posted by brewbuck:
    Reimplementing a large system in another language to get a 25% performance boost is nonsense. It would be cheaper to just get a computer which is 25% faster.

  4. #4
    Darkness Prevails Dark_Phoenix's Avatar
    Join Date
    Oct 2006
    Location
    Houston, Texas
    Posts
    174
    Details on OS/compiler/IDE
    WinXP/VS Toolkit 2003/Code::Blocks

    I'm assuming String_base is not something you wrote
    No, its not
    Using Code::Blocks and Windows XP

    In every hero, there COULD be a villain!

  5. #5
    (?<!re)tired Mario F.'s Avatar
    Join Date
    May 2006
    Location
    Ireland
    Posts
    8,446
    There is a switch that links your app with the MFC library. If you have VS installed you can see it easily if you go to the linker setup.

    I think that will fix your problem.
    Originally Posted by brewbuck:
    Reimplementing a large system in another language to get a 25% performance boost is nonsense. It would be cheaper to just get a computer which is 25% faster.

  6. #6
    Darkness Prevails Dark_Phoenix's Avatar
    Join Date
    Oct 2006
    Location
    Houston, Texas
    Posts
    174
    Well, I don't have VS, and I cannot find anything for MFC. I have heard a lot about it but do not know anything about it. Is it a SDK like the MS Platform and DirextX?
    Using Code::Blocks and Windows XP

    In every hero, there COULD be a villain!

  7. #7
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    Location
    Canada
    Posts
    8,057
    dwk

    Seek and ye shall find. quaere et invenies.

    "Simplicity does not precede complexity, but follows it." -- Alan Perlis
    "Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
    "The only real mistake is the one from which we learn nothing." -- John Powell


    Other boards: DaniWeb, TPS
    Unofficial Wiki FAQ: cpwiki.sf.net

    My website: http://dwks.theprogrammingsite.com/
    Projects: codeform, xuni, atlantis, nort, etc.

  8. #8
    Darkness Prevails Dark_Phoenix's Avatar
    Join Date
    Oct 2006
    Location
    Houston, Texas
    Posts
    174
    How can you use in it Code::Blocks? http://forums.codeblocks.org/index.php/topic,380.0.html
    OK, This shows that you cannot use MFC with c::b as the sources and libs are only distributed with the full visual c compilers. But the same app compiled and ran fine with dev-c++. Maybe I am just being stubborn but this tells me that it is not an MFC thing.
    Using Code::Blocks and Windows XP

    In every hero, there COULD be a villain!

  9. #9
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    Location
    Canada
    Posts
    8,057
    Your Dev-C++ probably uses GCC 3.4.2 (mingw-special). What is your Code::Blocks using? gcc 3.4.5 API 3.9?

    Anyway, they probably have different libraries. You can configure Code::Blocks to use a different compiler. Try making it use Dev-C++'s. Or try generating a Makefile with both programs and examining the libraries each is linked with.
    dwk

    Seek and ye shall find. quaere et invenies.

    "Simplicity does not precede complexity, but follows it." -- Alan Perlis
    "Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
    "The only real mistake is the one from which we learn nothing." -- John Powell


    Other boards: DaniWeb, TPS
    Unofficial Wiki FAQ: cpwiki.sf.net

    My website: http://dwks.theprogrammingsite.com/
    Projects: codeform, xuni, atlantis, nort, etc.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Linker errors
    By jw232 in forum C++ Programming
    Replies: 3
    Last Post: 06-12-2009, 12:56 PM
  2. Linker errors in VC++ 2005
    By C+/- in forum C++ Programming
    Replies: 0
    Last Post: 05-18-2007, 07:42 AM
  3. Sneaky little linker errors...
    By Tozar in forum C++ Programming
    Replies: 8
    Last Post: 10-25-2006, 05:40 AM
  4. why am i getting linker errors?
    By dantestwin in forum C++ Programming
    Replies: 11
    Last Post: 07-08-2004, 10:34 AM
  5. Linker errors with Visual C++
    By codegirl in forum C++ Programming
    Replies: 4
    Last Post: 09-11-2003, 09:20 AM