简体   繁体   中英

Reading from std::cin produces Linker error

I have a rather unusual problem. I am trying to do this:

char *content = new char[10000];
std::cin.read(content, 10000);

And I get the following linker error (weird because the code was compiling fine a few weeks ago, and it hasn't been modified):

Error LNK2001: unresolved external symbol "__declspec(dllimport) public: class std::basic_istream<char,struct std::char_traits<char> > & __thiscall std::basic_istream<char,struct std::char_traits<char> >::read(char *,__int64)" (__imp_?read@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV12@PAD_J@Z) main.obj

I verified that I have all the required dependencies linked in the Project Properties, verified that I have /MT set, and the like. The project was compiling fine just a few weeks ago-- the only thing I have done between then and now is update VS2012. Here are my includes.

#include <stdlib.h>

#ifdef _WIN32
    #include <process.h>
#else
    #include <unistd.h>
    extern char ** environ;
#endif

#include "fcgio.h"
#include "fcgi_config.h"

#include <boost/filesystem.hpp>
#include <boost/filesystem/fstream.hpp>
#include <boost/algorithm/string.hpp>

It appears that after updating Visual Studio 2012, the project (somehow) became non-functional. Copying the exact same code over to a new project has fixed the problem.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM