Linker Errors

This is a discussion on Linker Errors within the C++ Programming forums, part of the General Programming Boards category; I am getting a lot of linker errors (unresolved external symbol) that reference '_String_base::_Xlen ' and '_Xran'. I have done ...

  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
    Captain Crash brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,263
    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
    Portugal
    Posts
    7,532
    I don't think you are linking with the MFC library
    The programmer’s wife tells him: “Run to the store and pick up a loaf of bread. If they have eggs, get a dozen.”
    The programmer comes home with 12 loaves of bread.


    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
    Portugal
    Posts
    7,532
    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.
    The programmer’s wife tells him: “Run to the store and pick up a loaf of bread. If they have eggs, get a dozen.”
    The programmer comes home with 12 loaves of bread.


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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21