Author Topic: using visual studio 10 compiler  (Read 5771 times)

deviderx

  • Guest
using visual studio 10 compiler
« on: October 08, 2014, 10:29:23 pm »
I try to use  visual studio 10 compiler rather than Gcc
every thing work fine for me but when I tried  to make debug version instead of release version it give me this problems:

build log:


-------------- Build: Debug in C++FARAWAY (compiler: Microsoft Visual C++ 2010)---------------

cl.exe /nologo /W3  /TP /EHa /Za /Zi /D_DEBUG  /TP /EHa /Os /Za   /I"C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include" /c Untitled1.cpp /Foobj\Debug\Untitled1.obj
Untitled1.cpp
link.exe /nologo /LIBPATH:"C:\Program Files\Microsoft SDKs\Windows\v7.1\Lib\x64" /LIBPATH:"C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\lib\amd64" /out:bin\Debug\C++FARAWAY.exe  obj\Debug\Untitled1.obj  /DEBUG /VERBOSE:LIB
Searching libraries
    Searching C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\lib\amd64\libcpmtd.lib:
    Searching C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\lib\amd64\LIBCMT.lib:
    Searching C:\Program Files\Microsoft SDKs\Windows\v7.1\Lib\x64\kernel32.lib:
    Searching C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\lib\amd64\libcpmtd.lib:
    Searching C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\lib\amd64\LIBCMT.lib:
Finished searching libraries
LINK : warning LNK4098: defaultlib 'LIBCMT' conflicts with use of other libs; use /NODEFAULTLIB:library
libcpmtd.lib(xdebug.obj) : error LNK2001: unresolved external symbol _free_dbg
libcpmtd.lib(xmbtowc.obj) : error LNK2001: unresolved external symbol _free_dbg
Untitled1.obj : error LNK2019: unresolved external symbol _free_dbg referenced in function "private: void __cdecl std::_Yarn<char>::_Tidy(void)" (?_Tidy@?$_Yarn@D@std@@AEAAXXZ)
libcpmtd.lib(cin.obj) : error LNK2001: unresolved external symbol _free_dbg
libcpmtd.lib(cout.obj) : error LNK2001: unresolved external symbol _free_dbg
libcpmtd.lib(locale0.obj) : error LNK2001: unresolved external symbol _free_dbg
libcpmtd.lib(cin.obj) : error LNK2019: unresolved external symbol _CrtDbgReportW referenced in function "public: char const & __cdecl std::_String_const_iterator<char,struct std::char_traits<char>,class std::allocator<char> >::operator*(void)const " (??D?$_String_const_iterator@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QEBAAEBDXZ)
libcpmtd.lib(cout.obj) : error LNK2001: unresolved external symbol _CrtDbgReportW
libcpmtd.lib(stdthrow.obj) : error LNK2001: unresolved external symbol _CrtDbgReportW
libcpmtd.lib(xmbtowc.obj) : error LNK2001: unresolved external symbol _CrtDbgReportW
libcpmtd.lib(locale0.obj) : error LNK2019: unresolved external symbol _malloc_dbg referenced in function "public: class std::_Yarn<char> & __cdecl std::_Yarn<char>::operator=(char const *)" (??4?$_Yarn@D@std@@QEAAAEAV01@PEBD@Z)
libcpmtd.lib(xdebug.obj) : error LNK2001: unresolved external symbol _malloc_dbg
libcpmtd.lib(xmbtowc.obj) : error LNK2001: unresolved external symbol _malloc_dbg
libcpmtd.lib(_tolower.obj) : error LNK2019: unresolved external symbol _calloc_dbg referenced in function _Getctype
bin\Debug\C++FARAWAY.exe : fatal error LNK1120: 4 unresolved externals
Process terminated with status 1120 (0 minute(s), 1 second(s))
15 error(s), 1 warning(s) (0 minute(s), 1 second(s))
 
build messages:

||=== Build: Debug in C++FARAWAY (compiler: Microsoft Visual C++ 2010) ===|
LINK||warning LNK4098: defaultlib 'LIBCMT' conflicts with use of other libs; use /NODEFAULTLIB:library|
libcpmtd.lib(xdebug.obj)||error LNK2001: unresolved external symbol _free_dbg|
libcpmtd.lib(xmbtowc.obj)||error LNK2001: unresolved external symbol _free_dbg|
Untitled1.obj||error LNK2019: unresolved external symbol _free_dbg referenced in function "private: void __cdecl std::_Yarn<char>::_Tidy(void)" (?_Tidy@?$_Yarn@D@std@@AEAAXXZ)|
libcpmtd.lib(cin.obj)||error LNK2001: unresolved external symbol _free_dbg|
libcpmtd.lib(cout.obj)||error LNK2001: unresolved external symbol _free_dbg|
libcpmtd.lib(locale0.obj)||error LNK2001: unresolved external symbol _free_dbg|
libcpmtd.lib(cin.obj)||error LNK2019: unresolved external symbol _CrtDbgReportW referenced in function "public: char const & __cdecl std::_String_const_iterator<char,struct std::char_traits<char>,class std::allocator<char> >::operator*(void)const " (??D?$_String_const_iterator@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QEBAAEBDXZ)|
libcpmtd.lib(cout.obj)||error LNK2001: unresolved external symbol _CrtDbgReportW|
libcpmtd.lib(stdthrow.obj)||error LNK2001: unresolved external symbol _CrtDbgReportW|
libcpmtd.lib(xmbtowc.obj)||error LNK2001: unresolved external symbol _CrtDbgReportW|
libcpmtd.lib(locale0.obj)||error LNK2019: unresolved external symbol _malloc_dbg referenced in function "public: class std::_Yarn<char> & __cdecl std::_Yarn<char>::operator=(char const *)" (??4?$_Yarn@D@std@@QEAAAEAV01@PEBD@Z)|
libcpmtd.lib(xdebug.obj)||error LNK2001: unresolved external symbol _malloc_dbg|
libcpmtd.lib(xmbtowc.obj)||error LNK2001: unresolved external symbol _malloc_dbg|
libcpmtd.lib(_tolower.obj)||error LNK2019: unresolved external symbol _calloc_dbg referenced in function _Getctype|
bin\Debug\C++FARAWAY.exe||fatal error LNK1120: 4 unresolved externals|
||=== Build failed: 15 error(s), 1 warning(s) (0 minute(s), 1 second(s)) ===|



I have tried every possible thing I know but nothing happen
i try to use  /nodefaultlib:libcmt.lib 
but nothing happend

please help me

Offline cacb

  • Regular
  • ***
  • Posts: 389
Re: using visual studio 10 compiler
« Reply #1 on: February 27, 2015, 09:25:12 pm »
Late reply, but may be useful for others

Using MSVC10, these are my settings. Notice explicit exclusion of debug runtime libraries in release builds and vice versa, plus explicit inclusion of the relevant runtime for each target.


Release targets:

<Compiler>
   <Add option="/MD" />
   <Add option="/EHs" />
   <Add option="/GR" />
   <Add option="/GF" />
   <Add option="/Ox" />
   <Add option="/W3" />
   <Add option="/EHsc" />
</Compiler>
<Linker>
   <Add option="/NODEFAULTLIB:libcmtd.lib" />
   <Add option="/NODEFAULTLIB:msvcrtd.lib" />
   <Add option="/INCREMENTAL:NO" />
   <Add library="msvcrt.lib" />
</Linker>



Debug targets:

<Compiler>
   <Add option="/MDd" />
   <Add option="/EHs" />
   <Add option="/GR" />
   <Add option="/GF" />
   <Add option="/Od" />
   <Add option="/W3" />
   <Add option="/RTCsu" />
   <Add option="/Fd$(TARGET_OUTPUT_DIR)$(TARGET_OUTPUT_BASENAME).pdb" />
   <Add option="/EHsc" />
</Compiler>
<Linker>
   <Add option="/NODEFAULTLIB:libcmt.lib" />
   <Add option="/NODEFAULTLIB:msvcrt.lib" />
   <Add option="/INCREMENTAL:NO" />
   <Add library="msvcrtd.lib" />
</Linker>

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 11770
    • Travis build status
Re: using visual studio 10 compiler
« Reply #2 on: February 27, 2015, 11:06:24 pm »
Are you sure you're not mixing libraries built for debug and release run times?
I have not used msvc++ for a long time know, but in the past the requirement to use /NODEFAULTLIB has been just a work around for the mixed libs problem.
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline cacb

  • Regular
  • ***
  • Posts: 389
Re: using visual studio 10 compiler
« Reply #3 on: February 28, 2015, 12:59:15 pm »
Are you sure you're not mixing libraries built for debug and release run times?
I have not used msvc++ for a long time know, but in the past the requirement to use /NODEFAULTLIB has been just a work around for the mixed libs problem.

I am being explicit about which runtime libraries to include and which to exclude in the two build targets, instead of relying on some implicit behaviour I have little control over. So yes, I am sure I am not mixing debug and release runtimes. This is exactly what I am preventing.

It is clear from the list deviderx provided that there is a mix of debug/release runtimes happening in his case, and the listing even recommends using /NODEFAULTLIB . In my experience this easily happens when using MSVC compiler/linker, unless you are explicit about it, like I am.

What I showed is how I am being explicit, and it has worked for me to do it this way for a number of years. I don't think /NODEFAULTLIB is a work-around, I think it is a requirement to gain control.