Share via


Trouble building tux test with VS 2005

Here is a heads up from one of our Developer's Tools Devs, Marty Larson:

This is something I discovered yesterday, and thought you all might
appreciate a heads up. If you try to build tux tests with VS 2005, you'll
run into this problem.

The default build settings in VS 2005 do not match the settings that the OS
was built with. VS tries to be C++ compliant, and treats wchar_t as a native
type. The OS tries to be backward compatible, and turns off that behavior.

This is only a problem when a dll exports a C++ interface (like kato does).
You'll see the following errors:

error LNK2019: unresolved external symbol "__declspec(dllimport) public: int
__cdecl CKato::EndLevel(wchar_t const *,...)"
(__imp_?EndLevel@CKato@@QAAHPB_WZZ) referenced in function ShellProc
error LNK2019: unresolved external symbol "__declspec(dllimport) public: int
__cdecl CKato::BeginLevel(unsigned long,wchar_t const *,...)"
(__imp_?BeginLevel@CKato@@QAAHKPB_WZZ) referenced in function ShellProc
error LNK2019: unresolved external symbol "__declspec(dllimport) public: int
__cdecl CKato::Log(unsigned long,wchar_t const *,...)"
(__imp_?Log@CKato@@QAAHKPB_WZZ) referenced in function ShellProc

To fix this, go to Project --> Properties --> Configuration Properties -->
C/C++ --> Language, and set 'Treat wchar_t as Built-in Type' to No.

--
Marty Larson [MS]
--
This posting is provided "AS IS" with no warranties, and confers no rights.
Use of included script samples are subject to the terms specified at
https://www.microsoft.com/info/cpyright.htm

Posted by Don Gambrell

Comments

  • Anonymous
    April 11, 2006
    i tried your solution it worked with the test DLL but when i tried using KATO from my dialog based application it resolved the error and generated new ones

    error LNK2019: unresolved external symbol "public: __cdecl CWinApp::CWinApp(unsigned short const *)"
    error LNK2001: unresolved external symbol "public: virtual class CDocument * __cdecl CWinApp::OpenDocumentFile(unsigned short const *)" (?OpenDocumentFile@CWinApp@@UAAPAVCDocument@@PBG@Z)
    error LNK2001: unresolved external symbol "public: virtual int __cdecl CWinApp::DoMessageBox(unsigned short const *,unsigned int,unsigned int)" (?DoMessageBox@CWinApp@@UAAHPBGII@Z)
    error LNK2019: unresolved external symbol "protected: void __cdecl CWinApp::SetRegistryKey(unsigned short const *)" (?SetRegistryKey@CWinApp@@IAAXPBG@Z)
    error LNK2019: unresolved external symbol "__declspec(dllimport) public: __cdecl ATL::CStringT<unsigned short,class StrTraitMFC_DLL<unsigned short,class ATL::ChTraitsOS<unsigned short> > >::~CStringT<unsigned short,class StrTraitMFC_DLL<unsigned short,class ATL::ChTraitsOS<unsigned short> > >(void)" (_imp??1?$CStringT@GV?$StrTraitMFC_DLL@GV?$ChTraitsOS@G@ATL@@@@@ATL@@QAA@XZ)
  • Anonymous
    May 28, 2006
    while upgrading my project from VC++ 6.0 to VS2005 I got LNK2001 error as
    Error LNK 2001:unresolved external symbol "public" virtual class ATL::CTime_thiscall F6XInstrument::GetSatellite Time(void)
    please send me the solution for this Linker error
  • Anonymous
    May 31, 2006
    You can use undname.exe to decode these mangled names. When you do
    > that, you'll see:
    >
    > ?Log@CKato@@QAAHKPB_WZZ --> CKato::Log(unsigned long,wchar_t const
    > *,...) and ?Log@CKato@@QAAHKPBGZZ --> CKato::Log(unsigned
    > long,unsigned short const
    > *,...)
    >
    > Back in the original post I mentioned that the problem was that the
    > new compilers treat wchar's as native types, and you see that
    > reflected in the function signatures. The build settings used for
    > building kato treat wchar as unsigned short, and exported it that way.
    > The build settings used by default in VS treat it as a native type, and expect to import it that way.
    > The mismatch is causing the problem.
    >
    > So, the workaround here simply creates a dll that exports the function
    > signature with wchar as a native type (expected by VS), and forwards
    > it on to the same function in kato.dll that exports as unsigned short.
    >
    > --
    > Marty Larson [MS]
    > --
    > This posting is provided "AS IS" with no warranties, and confers no rights.
    > Use of included script samples are subject to the terms specified at
    > http://www.microsoft.com/info/cpyright.htm
    >
  • Anonymous
    June 22, 2006
    hey !

    I think i have a solution to ur problem!
    Go to project setting-> C/C++ ->language and change "Tream WChar_t as inbuild type" to NO.

    Thats all

    hope that helps
  • Anonymous
    October 22, 2008
    I tried changing project setting under C/C++ -> Langauge to "Treat wchar_t as built in type" as "No" and I still see the following error. (I also used extern "C" while including kato.h. Thanks much for your help in advance. test.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: int __cdecl CKato::Log(unsigned long,char const *,...)" (_imp?Log@CKato@@QAAHKPBDZZ) referenced in function "int __stdcall TestProc(unsigned int,unsigned long *,struct _FUNCTION_TABLE_ENTRY *)" (?TestProc@@YGHIPAKPAU_FUNCTION_TABLE_ENTRY@@@Z) tuxtest.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: int __cdecl CKato::Log(unsigned long,char const *,...)" (_imp?Log@CKato@@QAAHKPBDZZ) tuxtest.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: int __cdecl CKato::EndLevel(char const *,...)" (_imp?EndLevel@CKato@@QAAHPBDZZ) referenced in function _ShellProc@8 tuxtest.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: int __cdecl CKato::BeginLevel(unsigned long,char const *,...)" (_imp?BeginLevel@CKato@@QAAHKPBDZZ) referenced in function _ShellProc@8 tuxtest.obj : error LNK2019: unresolved external symbol _KatoGetDefaultObject@0 referenced in function _ShellProc@8 DebugWM.dll : fatal error LNK1120: 4 unresolved externals