VS2005 Linking problem std::_String_base::_Xran
-
Friday, August 26, 2005 9:45 PMHello,
I trying to build my project in VS8 (it was building fine in VS2003).
I get these linking error :
engine.lib(ECMFileHandler.obj) : error LNK2001: unresolved external symbol "public: void __thiscall std::_String_base::_Xran(void)const " (?_Xran@_String_base@std@@QBEXXZ)
engine.lib(ECMFileHandler.obj) : error LNK2001: unresolved external symbol "public: void __thiscall std::_String_base::_Xlen(void)const " (?_Xlen@_String_base@std@@QBEXXZ)
engine.lib(ECMFileHandler.obj) : error LNK2001: unresolved external symbol "public: void __thiscall std::ios_base::_Addstd(void)" (?_Addstd@ios_base@std@@QAEXXZ)
I checked to make sure all my projects are compiled in MT debug.
Here are the command line of the linker for my projects:
Dodgeball:
/OUT:"D:\SVN_Dev\build\dodgeball\Debug\DodgeBall.exe" /NOLOGO /LIBPATH:"D:\SVN_Dev\libs\NewtonSDK\sdk\dll" /MANIFEST /MANIFESTFILE:"Debug\DodgeBall.exe.intermediate.manifest" /DEBUG /PDB:"d:\SVN_Dev\build\dodgeball\Debug\DodgeBall.pdb" /ERRORREPORT:PROMPT d3dx9d.lib d3d9.lib comctl32.lib d3dxof.lib dinput.lib libcmtd.lib libcpmtd.lib dinput8.lib dsound.lib dsetup.lib dplayx.lib dxguid.lib dxtrans.lib dxErr9.lib winmm.lib newton.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib "..\..\build\engin\debug\engine.lib" "..\..\build\dx9utils\debug\dx9utils.lib" "..\..\build\math\debug\math.lib" "..\..\build\utils\debug\utils.lib"
dx9utils:
/OUT:"D:\SVN_Dev\build\dx9utils\Debug\DX9Utils.dll" /NOLOGO /DLL /MANIFEST /MANIFESTFILE:"D:\SVN_Dev\build\dx9utils\Debug\DX9Utils.dll.intermediate.manifest" /DEBUG /PDB:"d:\SVN_Dev\build\dx9utils\Debug\DX9Utils.pdb" /ERRORREPORT:PROMPT d3dx9d.lib d3d9.lib d3dxof.lib dinput.lib dinput8.lib dsound.lib dsetup.lib dplayx.lib dxguid.lib dxtrans.lib dxErr9.lib winmm.lib libcpmtd.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib
engine:
/OUT:"D:\SVN_Dev\build\Engin\Debug\Engine.dll" /NOLOGO /LIBPATH:"D:\SVN_Dev\libs\NewtonSDK\sdk\dll" /DLL /MANIFEST /MANIFESTFILE:"D:\SVN_Dev\build\Engin\Debug\Engine.dll.intermediate.manifest" /DEBUG /PDB:"d:\SVN_Dev\build\Engin\Debug\Engine.pdb" /ERRORREPORT:PROMPT d3dx9d.lib d3d9.lib d3dxof.lib dinput.lib dinput8.lib dsound.lib dsetup.lib dplayx.lib dxguid.lib dxtrans.lib dxErr9.lib winmm.lib newton.lib libcpmtd.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib "..\..\build\dx9utils\debug\dx9utils.lib" "..\..\build\math\debug\math.lib" "..\..\build\utils\debug\utils.lib"
math:
/OUT:"D:\SVN_Dev\build\Math\Debug\Math.dll" /NOLOGO /DLL /MANIFEST /MANIFESTFILE:"D:\SVN_Dev\build\Math\Debug\Math.dll.intermediate.manifest" /DEBUG /PDB:"d:\SVN_Dev\build\math\Debug\Math.pdb" /ERRORREPORT:PROMPT libcpmtd.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib
utils:
/OUT:"D:\SVN_Dev\build\utils\Debug\Utils.dll" /NOLOGO /DLL /MANIFEST /MANIFESTFILE:"D:\SVN_Dev\build\utils\Debug\Utils.dll.intermediate.manifest" /DEBUG /PDB:"d:\SVN_Dev\build\utils\Debug\Utils.pdb" /ERRORREPORT:PROMPT libcpmtd.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ..\..\build\dx9utils\Debug\DX9Utils.lib
I have been adding different libs to the configuration and searching on google with no success...
I hope someone can tell me what is going on !
Thanks
All Replies
-
Friday, August 26, 2005 11:55 PMModerator
Hmm: I think I might know what is going on here. A dump of the symbols in the libcpmtd.lib that ships with Visual C++ 2005 show the following definition for Xran
131 00000000 SECT62 notype () External | ?_Xran@_String_base@std@@SAXXZ (public: static void __cdecl std::_String_base::_Xran(void))
Notice how it is a __cdecl function and the error message you are seeing states that it is a __thiscall function.
Also if I look at the current definition of _String_base (which is in the xstring header file) I see the following:
class
_CRTIMP2_PURE _String_base : public _Container_base
{
public:
_MRTIMP2_NPURE_NCEEPURE static void __CLRCALL_PURE_OR_CDECL _Xlen();
_MRTIMP2_NPURE_NCEEPURE static void __CLRCALL_PURE_OR_CDECL _Xran();
_MRTIMP2_NPURE_NCEEPURE static void __CLRCALL_PURE_OR_CDECL _Xinvarg();
};
For a native compilation __CLRCALL_PURE_OR_CDECL should map to __cdecl.
If I was you I would take a look at your definition of _String_base and check that the member function declarations use the __CLRCALL_PURE_OR_CDECL macro and if they don't then you might want to make them explicitly __cdecl as I note that you do not appear to be compiling for the CLR. -
Tuesday, March 14, 2006 6:56 PM
I had the same problem when convertin Crypto51/523 library from VS2003 to VS2005. I figured out that newly built cryptolib.lib went to different folder and the main app was trying to link to old .lib file. As soon as paths were fixed the issue resolved.- Proposed As Answer by Shock_ Monday, September 10, 2012 9:30 AM
-
Friday, July 21, 2006 2:03 PMI'm having this same problem. The linker output says __thiscall instead of __cdecl. If the linker is showing __thiscall, but it should be __cdecl, why is the linker doing this? Which library should Xran be found in?
-
Friday, July 06, 2007 10:11 PMDid you ever figure this out? I'm encountering the same issue...
-
Monday, July 23, 2007 5:15 PMI got rid of this problem by just doing a "Rebuild All" of my project.
-
Tuesday, August 28, 2007 2:16 PM
Hi,
I have the same problem...I am new to VC++...Here are the errors
dSSTSDKsul.lib(hex.obj) : error LNK2001: unresolved external symbol "public: void __thiscall std::_String_base::_Xran(void)const " (?_Xran@_String_base@std@@QBEXXZ)
1>dSSTSDKsul.lib(oaep.obj) : error LNK2001: unresolved external symbol "public: void __thiscall std::_String_base::_Xran(void)const " (?_Xran@_String_base@std@@QBEXXZ)
From your explanation above i see that the function call should be _cdecl instead of _thiscall.But i don't know how to change it...
Pls help me out.
Thanks
Thilak Raj S
-
Friday, October 19, 2007 7:42 PMI face the same problem
I got a solution , i followed the steps .
Go to the Tools Menu ,click on the Options
a dialogbox will appear ,
Go to the Projects->vc++Directories->click
In the dropdonw box select " Show directories for : " select " Library files "
check the order of the path it should be somethin like
$(VCInstallDir)lib
$(VCInstallDir)atlmfc\lib
$(VCInstallDir)PlatformSDK\lib\prerelease
$(VCInstallDir)PlatformSDK\lib
$(FrameworkSDKDir)lib
Note : This might change for different project , ther might be additional paths .( but it works me ) -
Saturday, January 26, 2008 2:46 PM
Hi everybody,
I'm facing quite the same problem when tried to port one of apps from VC6.0 to
VC2005.
In two words: my program links additional 3-rd party libs (gx*.lib - see
logs) that were developed probably in VC6.0. The conflict seems to
appear exactly as said - at function decoration - old style is __thiscall while new VC2005
style is __stdcall (courtesy of google).
My problem seems to be little more complicated - I can't rebuild these 3-rd party
libs against correct decoration.
My questions are:
1. Does attached compiler output mean that I refer to improper PSDK
libs? Are VC2005 default libs not proper? I'm not an expert when facing
such fat output from compiler...
2. Is VC2005 and/or PSDK installation self-contained when facing this
sort of problems with different versions of stdc++ library? Or do I have
to download some additional stuff?
3. How to configure project options to correct this situation? I tried
hints met across different forums (reordering lib dir order in VC
options, /MT option, excluding particular lib files, ect.), rather 0%
accuracy in my case (or improperly applied).
If someone could explain me step by step an actual mechanism of this error, I would
appreciate it a lot.
---------------------------------------------------
Here is compiler error log:
http://cacheserver.duu.pl/logs/log01.html
Here is compiler error log (verbose):
http://cacheserver.duu.pl/logs/log02.html
Compiler options:
/Od /I "D:\MK Local Exchange\eXcite\include" /I "/include" /D "WIN32" /D
"_DEBUG" /D "_CONSOLE" /D "USE_GXCAM" /D "_WIN32_WINNT=0x500" /D "_MBCS"
/Gm /EHsc /RTC1 /MTd /Fo"Debug\\" /Fd"Debug\vc80.pdb" /W3 /nologo /c /ZI
/TP /errorReport
rompt
Linker options:
/OUT:"F:\Projects\VS2005\eXcite\src\bin/simplegrab_d.exe" /INCREMENTAL
/NOLOGO /LIBPATH:"D:\Program Files\Microsoft SDK\Lib"
/LIBPATH:"F:\Projects\VS2005\eXcite\src\../lib" /MANIFEST
/MANIFESTFILE:"Debug\simplegrab_d.exe.intermediate.manifest" /DEBUG
/PDB:"Debug/simplegrab_d.pdb" /SUBSYSTEM:CONSOLE /MACHINE:X86
/ERRORREPORT
ROMPT baslercam_md.lib gxdevice_mt.lib xcam_md.lib
gtrans.lib gxpp_md.lib kernel32.lib user32.lib gdi32.lib winspool.lib
comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib
odbc32.lib odbccp32.lib
---------------------------------------------------
Any response greatly welcome...
Greetings
mk -
Friday, August 22, 2008 1:30 PM
Hi aberazioon,
I faced the same problem but in my case, the external libraries were compiled using Studio 2003 and I only had 2 unresolved external symbols: Xran and Xlen.
This problem hapens because the library libcpmt.lib (libcpmtd.lib) in MS Visual 2003 and MS Visual 2008 has different prototype definitions for xRan and xLen (MS Visual 200* + command prompt + type the command "dumpbin /ALL libcpmtd.lib" )
In 2003:
// 00000018 REL32 00000000 34C ?_Xran@_String_base@std@@QBEXXZ (public: void __thiscall std::_String_base::_Xran(void)const )
// 0000001E REL32 00000000 2DF ?_Xlen@_String_base@std@@QBEXXZ (public: void __thiscall std::_String_base::_Xlen(void)const )In 2008:
// 00000019 REL32 00000000 5CC ?_Xran@_String_base@std@@SAXXZ (public: static void __cdecl std::_String_base::_Xran(void))
// 0000001D REL32 00000000 5C6 ?_Xlen@_String_base@std@@SAXXZ (public: static void __cdecl std::_String_base::_Xlen(void))To solve the problem I did the following... a bit bizarre but it works for me:
(The general idea here is to create a dll / library that exports the unknown symbols and these new methods in the dll will call the new methods behaviour in libcpmt.lib @ 2008)
1) I used MS Visual 2003 pre-processor (type the command "cl /EP <source code_1.cpp>") to get the "String_base" class definition.// Source code_1.cpp
#include <string>
// end of code_1.cpp
In MS Visual 2003, class definition is:
class _String_base
{
public:
void _Xlen() const;
void _Xran() const;
};2) According with _Xran and _Xlen definition in 2008, both methods are static.
3) Compile the following source code in 2008. Type the command "cl /D_DLL_EXPORT /EHsc /LD libvisual2003_visual2008.cpp /link".
// Source libvisual2003_visual2008.cpp
#include <string>namespace std2003_2008
{
class _String_base2003_2008
{
public:
__declspec(dllexport) void _Xlen2003_2008(void) const;
__declspec(dllexport) void _Xran2003_2008(void) const;
};
};void std2003_2008::_String_base2003_2008::_Xran2003_2008 () const
{
std::_String_base::_Xran ();
}void std2003_2008::_String_base2003_2008::_Xlen2003_2008 () const
{
std::_String_base::_Xlen ();
}// end of libvisual2003_visual2008.cpp
4) Type the command "dumpbin /ALL libvisual2003_visual2008.dll" (MS Visual 2008) to get the public symbols of _Xran2003_2008 and _Xlen2003_2008.
// ?_Xlen2003_2008@_String_base2003_2008@std2003_2008@@QBEXXZ
// ?_Xran2003_2008@_String_base2003_2008@std2003_2008@@QBEXXZ5) Re-compile again libvisual2003_visual2008.cpp with following command "cl /D_DLL_EXPORT /EHsc /LD libvisual2003_visual2008.cpp /link /export:?_Xran@_String_base@std@@QBEXXZ=?_Xran2003_2008@_String_base2003_2008@std2003_2008@@QBEXXZ /export:?_Xlen@_String_base@std@@QBEXXZ=?_Xlen2003_2008@_String_base2003_2008@std2003_2008@@QBEXXZ"
Here, the new dll will export 2 new symbols (the ones that were unknown in initial compilation) and they will map to the methods _Xlen2003_2008 and _Xran2003_2008.
6) If you dump the public symbols of the new dll (step 5), you will get the following:
// 1 0 00001010 ?_Xlen2003_2008@_String_base2003_2008@std2003_2008@@QBEXXZ
// 2 1 00001010 ?_Xlen@_String_base@std@@QBEXXZ
// 3 2 00001000 ?_Xran2003_2008@_String_base2003_2008@std2003_2008@@QBEXXZ
// 4 3 00001000 ?_Xran@_String_base@std@@QBEXXZ7) Re-compile the program again with the new "libvisual2003_visual2008.lib" library.
8) To run the application don't forget the "libvisual2003_visual2008.dll".
Greetings
JN123 @ Portugal -
Thursday, March 11, 2010 9:55 AMI had the same problem.
Solved.
Solution: Ignore all default libraries was set to yes under linker options. Set to no !
EugenWiebe1 -
Friday, February 25, 2011 11:58 AMI too faced the same problem and found that platform sdk path was on the top of the list of lib path. After moving it to the last and it worked fine.
-
Tuesday, April 05, 2011 2:31 PM
i have the same problem and found that i build some library (smartwin++) from make bat file with VS 9.0 and tryied to build sample with VS 10.0 from devend and got unresolved links.
building library with appropriate VS version (10.0) solved problem.

