VC6中用不了 iostream 中的 cout 等的一种解决办法

  今晚用VC6写的几句非常简单的C++代码, 发现居然编译器能编译通过,但链接能不过, 错误是:

Compiling...
test.cpp
Linking...
test.obj : error LNK2001: unresolved external symbol "class stlpmtx_std::basic_ostream<char,class stlpmtx_std::char_traits<char> > stlpmtx_std::cout" (?cout@stlpmtx_std@@3V?$basic_ostream@DV?$char_traits@D@stlpmtx_std@@@1@A)
test.obj : error LNK2001: unresolved external symbol "protected: void __thiscall stlpmtx_std::ios_base::_M_throw_failure(void)" (?_M_throw_failure@ios_base@stlpmtx_std@@IAEXXZ)
Debug/test.exe : fatal error LNK1120: 2 unresolved externals
Error executing link.exe.

 反正我是没看懂到底是个什么错误, 貌似是因为我装的STL模板库的问题, 不管了...

临时解决办法:
  在VC6中, Project->Settings->C/C++->Category:Code Generation,
将Use Runtile Library改成多线程版本:
  Debug Multithreaded / Debug Multithreaded DLL (Debug版本)
  Multithreaded / Multithreaded DLL (Release版本)

我的测试代码:

#include <iostream>
using namespace std;

int main(void)
{
    cout<<"hello, beauty!";    
    return 0;
}

 

女孩不哭 @ 2013-08-15 00:10:17 @ http://www.cnblogs.com/nbsofer

你可能感兴趣的:(iostream)