2013-05-11 5 views
0
에 부스트 :: 직렬화를 사용하는 경우

내가 부스트에서 데모를 구축을 위해 노력하고있다 :: 직렬화 페이지 :링커 오류 엑스 코드

#include <fstream> 

#include <boost/archive/text_oarchive.hpp> 
#include <boost/archive/text_iarchive.hpp> 

class gps_position 
{ 
private: 
    friend class boost::serialization::access; 
    template<class Archive> 
    void serialize(Archive & ar, const unsigned int version) 
    { 
     ar & degrees; 
     ar & minutes; 
     ar & seconds; 
    } 
    int degrees; 
    int minutes; 
    float seconds; 
public: 
    gps_position(){}; 
    gps_position(int d, int m, float s) : 
    degrees(d), minutes(m), seconds(s) 
    {} 
}; 

int main() { 
    std::ofstream ofs("filename"); 

    const gps_position g(35, 59, 24.567f); 

    { 
     boost::archive::text_oarchive oa(ofs); 
     oa << g; 
    } 

    return 0; 
} 

하지만 다음 링커 오류가 점점 오전 :

boost::archive::text_oarchive_impl<boost::archive::text_oarchive>::save(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&)", referenced from: 
(null): "boost::archive::text_oarchive_impl<boost::archive::text_oarchive>::text_oarchive_impl(std::__1::basic_ostream<char, std::__1::char_traits<char> >&, unsigned int)", referenced from: 
(null): "boost::archive::basic_text_oprimitive<std::__1::basic_ostream<char, std::__1::char_traits<char> > >::~basic_text_oprimitive()", referenced from: 
(null): Linker command failed with exit code 1 (use -v to see invocation) 

Mountain Lion 및 XCode 4.6.2에서 부스트 1.53.0을 사용하고 있습니다.
헤더 (헤더 검색 경로) 및 라이브러리 (라이브러리 검색 경로)에 대한 경로를 추가했으며 라이브러리와 함께 링크 바이너리에 libboost_serialization.dylib를 추가했습니다.

다른 스레드에서 검색하면 내 정적 라이브러리 libboost_serialization.a에 대해 컴파일러에게 말하지 않은 것 같습니다. 어떻게해야합니까? (이것이 내 문제라면). 다른 링커 플래그에 다음과 같이 추가하려고했습니다 : 결과가없는 -lboost_serialization.

누구든지이 문제가 발생합니까?

미리 확인하십시오.

+0

'.dylib' 파일 대신'.a' 파일에 연결하는 방법은 무엇입니까? – trojanfoe

+0

@trojanfoe : 여전히 동일한 오류가 발생합니다 – Kobe

답변

0

경고가 발생 했습니까? 파일 당신의 _lib_file_name을 무시

이 파일은 지원되지 않는 파일 형식, 당신은, 적절한 구성으로 부스트를 구축하려고

그것을 연결되는 구조되지 않습니다 (ㅋ ㅋ ㅋ ㅋ ㅋ ㅋ)을 위해 만들어진 .

+0

http://stackoverflow.com/questions/7361751/c-boost-on-iphone을 살펴보아야합니다. 나는 너와 똑같은 문제를 겪었고,이 팁은 나를 도왔다. –