I want to read a whole file into a string. I am using Embarcadero C++Builder XE.
When I use the below code in my project, it is giving errors:
#include <iostream>
#include <iomanip>
#include <iterator>
#include <fstream>
std::ifstream in(Path);
std::string s((std::istreambuf_iterator<char>(in)), std::istreambuf_iterator<char>());
[ILINK32 Error] Error: Unresolved external 'std::_Mutex::_Lock()' [ILINK32 Error] Error: Unresolved external 'std::_Mutex::_Unlock()' [ILINK32 Error] Error: Unresolved external 'std::char_traits::eq_int_type(const int&, const int&)' [ILINK32 Error] Error: Unresolved external 'std::char_traits::not_eof(const int&)' [ILINK32 Error] Error: Unresolved external 'std::char_traits::to_char_type(const int&)' [ILINK32 Error] Error: Unresolved external 'std::char_traits::eof()' [ILINK32 Error] Error: Unresolved external 'std::char_traits::to_int_type(const char&)' [ILINK32 Error] Error: Unresolved external 'std::locale::id::operator unsigned int()' [ILINK32 Error] Error: Unresolved external 'std::locale::name() const' [ILINK32 Error] Error: Unresolved external 'std::codecvt_base::codecvt_base(unsigned int)' [ILINK32 Error] Error: Unresolved external 'std::locale::facet::_Incref()' [ILINK32 Error] Error: Unresolved external 'std::ios_base::ios_base()' [ILINK32 Error] Error: Unresolved external 'std::ios_base::getloc() const' [ILINK32 Error] Error: Unresolved external 'std::ctype::_Getcat(std::locale::facet * *, std::locale *)' [ILINK32 Error] Error: Unresolved external 'std::ctype::widen(char) const' [ILINK32 Error] Error: Unresolved external 'std::ios_base::rdstate() const' [ILINK32 Error] Error: Unable to perform link
Any other solutions for reading a file into a string?
AnsiStringnatively in VCL ...TStringsandTMemo->Linescan load entire text file with simpleLoadFromFilemethod. File access is also simple use VCL:FileOpen/FileCreate, FileSeek, FileRead/FileWrite, FileClose. But to your errors your project is wrongly configured so may be you got some weird settings or corruption in project file ... sometimes creating new one helps.Unresolved externalmeans you have included header but no code nor linked obj/lib/dll where it is