Xcode 4.5.2를 사용하고 Boost를 사용했지만 몇 가지 문제가 있습니다.Xcode에서 부스트 라이브러리를 사용할 때의 몇 가지 문제
빌드 설정에서 libC++ (C++ 11 지원이있는 LLVM C++ 표준 라이브러리)를 선택하면 "Apple Mach-O Linker (ld) Error"오류 메시지가 표시됩니다. 그냥 같이 :
Undefined symbols for architecture x86_64:
"boost::filesystem::path_traits::dispatch(boost::filesystem::directory_entry const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >&, std::__1::codecvt<wchar_t, char, __mbstate_t> const&)"
referenced from:
boost::filesystem::path::path<boost::filesystem::directory_entry>(boost::filesystem::directory_entry const&, boost::enable_if<boost::filesystem::path_traits::is_pathable<boost::decay<boost::filesystem::directory_entry>::type>, void>::type*) in test1 - inverted index.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
나는이 두 헤더 포함
#include <boost/filesystem.hpp>
#include <boost/operators.hpp>
을 나는 또한 빌드 단계에서 다음을 추가
libboost_filesystem-mt.dylib
libboost_filesystem-mt.a
libboost_system-mt.dylib
libboost_system-mt.a
코드는 여기에 있습니다 :
#include <boost/filesystem.hpp>
#include <boost/operators.hpp>
#include <iostream>
#include <fstream>
#include <string>
#include <map>
#include <set>
using namespace boost::filesystem;
std::map<std::string, std::set<int>> invertedIndex;
std::map<std::string, int> number;
bool check_char(const char in)
{
if((in>='A' && in<='Z') || (in>='a' && in<='z'))
return true;
else
return false;
}
int main() {
int con = 0;
std::string word;
path root("/Users/tomhu/Desktop/pro/data/");
std::string rootDirectory = root.native();
recursive_directory_iterator iter(root);
recursive_directory_iterator end;
for (; iter != end; ++iter)
{
if(is_regular_file(*iter))
{
std::string filename;
std::string directory(rootDirectory);
filename = iter->path().filename().native();
directory.append(filename);
std::ifstream fileIn(directory.c_str());
number[filename] = con;
if(!fileIn)
{
std::cerr << "File doesn't exist!" << std::endl;
exit(1);
}
while(fileIn>>word)
{
long po = 0;
if(!check_char(*(word.end()-1)))
word.pop_back();
transform(word.begin(),word.end(),word.begin(),::tolower);
if(word=="i")
word="I";
invertedIndex[word].insert(con);
}
}
}
std::cout << con << std::endl;
return 0;
}
!!!!!!!! "Build Setting"에서 libstdC++ (GUN C++ 표준 라이브러리)를 선택하면 Boost에 대한 오류 메시지가 나타나지 않지만 C++ 11 Standard에서는 아무 것도 사용할 수 없습니다.
어떻게 이러한 문제를 해결할 수 있습니까?
를 왜 모두 정적 및 동적 라이브러리에 연결하고 여기
그리고 당신 ++ 연타 + libc에 대한 부스트를 재 컴파일 할 수있는 방법인가? – trojanfoe
어떤 것이 작동할지 모르므로 ...... – h1994st
정적으로 시도하십시오. 동적 인 것을 버리십시오. – trojanfoe