我正在使用Windows8 32位,Visual Studio 2012和Intel PinTool(76991版本)。
我正在使用开发人员命令提示符使用命令创建dll:
link /DLL /EXPORT:main /NODEFAULTLIB /NOLOGO /INCREMENTAL:NO /MACHINE:x86 /ENTRY:Ptrace_DllMainCRTStartup /BASE:0xC5000000 /OPT:REF /out:obj-ia32/inscount0.dll inscount0.obj shmem_ritu.obj /LIBPATH:C:\Users\kunal\Downloads\pin-3.0-76991-msvc-windows\pin-3.0-76991-msvc-windows\ia32\lib /LIBPATH:C:\Users\kunal\Downloads\pin-3.0-76991-msvc-windows\pin-3.0-76991-msvc-windows\ia32\lib-ext /LIBPATH:C:\Users\kunal\Downloads\pin-3.0-76991-msvc-windows\pin-3.0-76991-msvc-windows\extras\xed-ia32\lib pin.lib libxed.lib libcpmt.lib libcmt.lib pinvm.lib kernel32.lib C:\Users\kunal\Downloads\pin-3.0-76991-msvc-windows\pin-3.0-76991-msvc-windows\ia32\lib-ext\ntdll-32.lib
cl -c -IC:\Users\kunal\Downloads\pin-3.0-76991-msvc-windows\pin-3.0-76991-msvc-windows\source\include -IC:\Users\kunal\Downloads\pin-3.0-76991-msvc-windows\pin-3.0-76991-msvc-windows\source\tools\InstLib -IC:\Users\kunal\Downloads\pin-3.0-76991-msvc-windows\pin-3.0-76991-msvc-windows\extras\xed2-ia32\include -IC:\Users\kunal\Downloads\pin-3.0-76991-msvc-windows\pin-3.0-76991-msvc-windows\extras\components\include -IC:\Users\kunal\Downloads\pin-3.0-76991-msvc-windows\pin-3.0-76991-msvc-windows\source/include/gen -IC:\Users\kunal\Downloads\pin-3.0-76991-msvc-windows\pin-3.0-76991-msvc-windows\source/include/pin -IC:\Users\kunal\Downloads\pin-3.0-76991-msvc-windows\pin-3.0-76991-msvc-windows\source/include/pin/gen -DTARGET_IA32E -DHOST_IA32E -DTARGET_WINDOWS -IC:\minor\filesIncludeInVisualStudio inscount0.cpp
它给出了错误:
LINK : error LNK2001: unresolved external symbol _Ptrace_DllMainCRTStartup
inscount0.obj : error LNK2019: unresolved external symbol "public: void __cdecl LEVEL_BASE::MESSAGE_TYPE::MessageNoReturn(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,bool,enum PIN_ERRTYPE,int,...)" (?MessageNoReturn@MESSAGE_TYPE@LEVEL_BASE@@QAAXABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@_NW4PIN_ERRTYPE@@HZZ) referenced in function "void __cdecl printip(unsigned int,void *,char *)" (?printip@@YAXIPAXPAD@Z)
inscount0.obj : error LNK2019: unresolved external symbol "class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __cdecl LEVEL_BASE::AssertString(char const *,char const *,unsigned int,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (?AssertString@LEVEL_BASE@@YA?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@PBD0IABV23@@Z) referenced in function "void __cdecl printip(unsigned int,void *,char *)" (?printip@@YAXIPAXPAD@Z)
inscount0.obj : error LNK2019: unresolved external symbol "class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __cdecl LEVEL_BASE::StringDec(unsigned __int64,unsigned int,char)" (?StringDec@LEVEL_BASE@@YA?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@_KID@Z) referenced in function "class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __cdecl LEVEL_BASE::decstr(unsigned int,unsigned int)" (?decstr@LEVEL_BASE@@YA?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@II@Z)
inscount0.obj : error LNK2019: unresolved external symbol "public: __thiscall LEVEL_BASE::KNOB_BASE::KNOB_BASE(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,enum LEVEL_BASE::KNOB_MODE)" (??0KNOB_BASE@LEVEL_BASE@@QAE@ABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@0000W4KNOB_MODE@1@@Z) referenced in function "public: __thiscall LEVEL_BASE::KNOB<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > >::KNOB<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > >(enum LEVEL_BASE::KNOB_MODE,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (??0?$KNOB@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@LEVEL_BASE@@QAE@W4KNOB_MODE@1@ABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@1111@Z)
inscount0.obj : error LNK2019: unresolved external symbol "public: static class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __cdecl LEVEL_BASE::KNOB_BASE::StringKnobSummary(void)" (?StringKnobSummary@KNOB_BASE@LEVEL_BASE@@SA?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@XZ) referenced in function "int __cdecl Usage(void)" (?Usage@@YAHXZ)
inscount0.obj : error LNK2019: unresolved external symbol "class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __cdecl LEVEL_CORE::INS_Disassemble(class LEVEL_CORE::INDEX<6>)" (?INS_Disassemble@LEVEL_CORE@@YA?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@V?$INDEX@$05@1@@Z) referenced in function "void __cdecl Instruction(class LEVEL_CORE::INDEX<6>,void *)" (?Instruction@@YAXV?$INDEX@$05@LEVEL_CORE@@PAX@Z)
inscount0.obj : error LNK2019: unresolved external symbol "class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const & __cdecl LEVEL_PINCLIENT::RTN_Name(class LEVEL_CORE::INDEX<3>)" (?RTN_Name@LEVEL_PINCLIENT@@YAABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@V?$INDEX@$02@LEVEL_CORE@@@Z) referenced in function "void __cdecl FlagRtn(class LEVEL_CORE::INDEX<3>,void *)" (?FlagRtn@@YAXV?$INDEX@$02@LEVEL_CORE@@PAX@Z)
inscount0.obj : error LNK2019: unresolved external symbol "public: static unsigned __int64 __cdecl LEVEL_BASE::KNOBVALUE<unsigned __int64>::FromString(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (?FromString@?$KNOBVALUE@_K@LEVEL_BASE@@SA_KABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z) referenced in function "public: void __thiscall LEVEL_BASE::KNOBVALUE<unsigned __int64>::Accumulate(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (?Accumulate@?$KNOBVALUE@_K@LEVEL_BASE@@QAEXABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z)
inscount0.obj : error LNK2019: unresolved external symbol "public: static class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const __cdecl LEVEL_BASE::KNOBVALUE<unsigned __int64>::Type(void)" (?Type@?$KNOBVALUE@_K@LEVEL_BASE@@SA?BV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@XZ) referenced in function "public: virtual class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const __thiscall LEVEL_BASE::KNOB<unsigned __int64>::Type(void)" (?Type@?$KNOB@_K@LEVEL_BASE@@UAE?BV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@XZ)
inscount0.obj : error LNK2019: unresolved external symbol "public: static __int64 __cdecl LEVEL_BASE::KNOBVALUE<__int64>::FromString(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (?FromString@?$KNOBVALUE@_J@LEVEL_BASE@@SA_JABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z) referenced in function "public: void __thiscall LEVEL_BASE::KNOBVALUE<__int64>::Accumulate(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (?Accumulate@?$KNOBVALUE@_J@LEVEL_BASE@@QAEXABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z)
inscount0.obj : error LNK2019: unresolved external symbol "public: static class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const __cdecl LEVEL_BASE::KNOBVALUE<__int64>::Type(void)" (?Type@?$KNOBVALUE@_J@LEVEL_BASE@@SA?BV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@XZ) referenced in function "public: virtual class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const __thiscall LEVEL_BASE::KNOB<__int64>::Type(void)" (?Type@?$KNOB@_J@LEVEL_BASE@@UAE?BV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@XZ)
inscount0.obj : error LNK2019: unresolved external symbol "public: static class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __cdecl LEVEL_BASE::KNOBVALUE<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > >::FromString(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (?FromString@?$KNOBVALUE@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@LEVEL_BASE@@SA?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@ABV34@@Z) referenced in function "public: void __thiscall LEVEL_BASE::KNOBVALUE<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > >::Accumulate(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (?Accumulate@?$KNOBVALUE@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@LEVEL_BASE@@QAEXABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z)
inscount0.obj : error LNK2019: unresolved external symbol "public: static class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const __cdecl LEVEL_BASE::KNOBVALUE<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > >::Type(void)" (?Type@?$KNOBVALUE@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@LEVEL_BASE@@SA?BV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@XZ) referenced in function "public: virtual class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const __thiscall LEVEL_BASE::KNOB<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > >::Type(void)" (?Type@?$KNOB@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@LEVEL_BASE@@UAE?BV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@XZ)
pin.lib(reg.obj) : error LNK2001: unresolved external symbol "public: static void * __cdecl std::__malloc_alloc::allocate(unsigned int)" (?allocate@__malloc_alloc@std@@SAPAXI@Z)
pin.lib(cfg_ia32.obj) : error LNK2001: unresolved external symbol "public: static void * __cdecl std::__malloc_alloc::allocate(unsigned int)" (?allocate@__malloc_alloc@std@@SAPAXI@Z)
pin.lib(ipc_common_windows.obj) : error LNK2001: unresolved external symbol "public: static void * __cdecl std::__malloc_alloc::allocate(unsigned int)" (?allocate@__malloc_alloc@std@@SAPAXI@Z)
pin.lib(ipc_connection_windows.obj) : error LNK2001: unresolved external symbol "public: static void * __cdecl std::__malloc_alloc::allocate(unsigned int)" (?allocate@__malloc_alloc@std@@SAPAXI@Z)
pin.lib(modules_win.obj) : error LNK2001: unresolved external symbol "public: static void * __cdecl std::__malloc_alloc::allocate(unsigned int)" (?allocate@__malloc_alloc@std@@SAPAXI@Z)
pin.lib(elf_windows.obj) : error LNK2019: unresolved external symbol "public: static void * __cdecl std::__malloc_alloc::allocate(unsigned int)" (?allocate@__malloc_alloc@std@@SAPAXI@Z) referenced in function "class LEVEL_CORE::INDEX<21> __cdecl LEVEL_CORE::FindLinkerDefinedSymbol(class std::basic_string<char,class std::char_traits<char>,class std::allocator<char> > const &)" (?FindLinkerDefinedSymbol@LEVEL_CORE@@YA?AV?$INDEX@$0BF@@1@ABV?$basic_string@DV?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z)
在互联网上,由于以下原因,我可能会收到此错误消息
“尝试在调试模式下构建Pintool。将Visual Studio中的活动配置更新为Release,链接错误将消失”
我需要包括哪个标志才能在发布模式下构建它(因为我正在使用命令提示符)?
最佳答案
我不确定是否仍然需要这样做,但是我相信您没有将pintool与crtbeginS.o链接。尝试在链接命令中首先添加此对象文件。
关于c++ - Windows中无法解析的外部符号,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/37718095/