0

I am using windows8 32 bit ,visual studio 2012 and intel pintool (76991 version). I am using developer command prompt to creat dll using command:

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

It is giving error :

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)

Over the internet I found I might be getting this error due to below mentioned reason " trying to build the Pintool in Debug mode. Update the active configuration in Visual Studio to Release , and the link errors will go away"

Which flag I need to include to build it in release mode (as I am using command prompt)?

kunal
  • 33
  • 4
  • Find where `LEVEL_BASE` class is defined. – Ajay Jun 09 '16 at 06:24
  • LEVEL_BASE is a namespace reference in PIN – kunal Jun 09 '16 at 10:02
  • I mean where it is implemented? In some CPP file, or in some LIB/DLL? – Ajay Jun 09 '16 at 10:03
  • Possible duplicate of [What is an undefined reference/unresolved external symbol error and how do I fix it?](http://stackoverflow.com/questions/12573816/what-is-an-undefined-reference-unresolved-external-symbol-error-and-how-do-i-fix) – IInspectable Jun 09 '16 at 13:31
  • Are you building the pintool using the make scripts or are you building it using bare cl and link commands? If you're doing the latter I recommend that you use make and see if there are any differences. Specifically pin should link to a couple of new libraries and not link to the windows c runtime at all. – nitzanms Jun 09 '16 at 16:06
  • @nitzanms i am using cl and link commands.what do you mean by pin should link to a couple of new libraries and not link to the windows c runtime at all – kunal Jun 10 '16 at 04:21
  • @Ajay it is taking reference from some file. – kunal Jun 10 '16 at 04:26
  • I mean that the commands you're using look like the way pin was built in earlier versions. I recommend that you use the building method described in the user guide to see what flags should be given for building pin in version 3.0. – nitzanms Jun 11 '16 at 23:02

1 Answers1

1

I am not sure that this is still needed, but I believe you did not link the pintool with crtbeginS.o. Try to add this object file as first in the linkage command.

Roman
  • 117
  • 1
  • 1
  • 6