Author Topic: "Unresolved externals" problem with msvc compiler.  (Read 20635 times)

Offline Ahriman

  • Single posting newcomer
  • *
  • Posts: 2
"Unresolved externals" problem with msvc compiler.
« on: June 06, 2012, 12:36:14 pm »
Hello,
I want to use Code::Blocks with Microsoft Visual C++ 2010 compiler\debugger. So I did:

1) Installed winSDK 7.1 with debugging tools.
2) Installed windows symbols package(C:\WINDOWS\symbols install dir)
3) Installed nightly build of Code::Blocks( 04 April 2012 DEBUGGER BRANCH version  - i could not make Code::Blocks 10.05 work with cdb debugger.

Code::Blocks found ms compiler automatically( in C:\Program Files\Microsoft Visual Studio 10.0\VC ). My compiler and linker search directories are:
C:\Program Files\Microsoft Visual Studio 10.0\VC
C:\Program Files\Microsoft Visual Studio 10.0\VC

Also I added  C:\Program Files\Microsoft SDKs\Windows\v7.1\Lib\Kernel32.Lib to linker settings cause CB could not find kernel32.dll at first.

Now I can compile and debug simple program, like:
Code
 #include <stdio.h>
 int main() {
   printf("Hello\n");
   return 0;
 }
but when I try to use any c++ library like <iostream> or <string>, I get a lot of "unresolved externals" errors:
Code
#include <iostream>
 int main() {
   std::cout << "Hello\n";
   return 0;
 }

and errors:

LINK||warning LNK4098: defaultlib 'LIBCMT' conflicts with use of other libs; use /NODEFAULTLIB:library|
libcpmtd.lib(cout.obj)||error LNK2019: unresolved external symbol __CrtDbgReportW referenced in function "public: char const & __thiscall 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@@QBEABDXZ)|
libcpmtd.lib(stdthrow.obj)||error LNK2001: unresolved external symbol __CrtDbgReportW|
libcpmtd.lib(cout.obj)||error LNK2019: unresolved external symbol __free_dbg referenced in function "private: void __thiscall std::_Yarn<char>::_Tidy(void)" (?_Tidy@?$_Yarn@D@std@@AAEXXZ)|
libcpmtd.lib(xdebug.obj)||error LNK2001: unresolved external symbol __free_dbg|
libcpmtd.lib(locale0.obj)||error LNK2001: unresolved external symbol __free_dbg|
libcpmtd.lib(xdebug.obj)||error LNK2019: unresolved external symbol __malloc_dbg referenced in function "void * __cdecl operator new(unsigned int,struct std::_DebugHeapTag_t const &,char *,int)" (??2@YAPAXIABU_DebugHeapTag_t@std@@PADH@Z)|
libcpmtd.lib(locale0.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\test.exe||fatal error LNK1120: 4 unresolved externals|
||=== Build finished: 9 errors, 1 warnings (0 minutes, 0 seconds) ===|


I compiled succesfully the same code using MinGW, so i suppose there is problem with msvc compiler installation, but compiler settings seems ok to me  ???. Please help me, maybe I just missing smth.

Offline Ahriman

  • Single posting newcomer
  • *
  • Posts: 2
Re: "Unresolved externals" problem with msvc compiler.
« Reply #1 on: June 06, 2012, 01:43:20 pm »
I found what I've missed. Setting compiler flag /MTd (multiThreaded debug runtime library) solved the problem. Topic couldbe closed.