2015. 9. 18. 17:55

Boost 관련 메모

1.boost 를 사용할때 class boost::system::error_category 링크 오류가 나는 경우


1>Timer.obj : error LNK2001: unresolved external symbol "class boost::system::error_category const & __cdecl boost::system::system_category(void)" (?system_category@system@boost@@YAABVerror_category@12@XZ)

1>UdpBinder.obj : error LNK2001: unresolved external symbol "class boost::system::error_category const & __cdecl boost::system::system_category(void)" (?system_category@system@boost@@YAABVerror_category@12@XZ)

1>Service.obj : error LNK2001: unresolved external symbol "class boost::system::error_category const & __cdecl boost::system::system_category(void)" (?system_category@system@boost@@YAABVerror_category@12@XZ)


부스트 라이브러리를 사용해서 컴파일 하는데 위와같은 링크오류가 계속 나서 찾아본 결과


프로젝트의 타켓 플랫폼(32bit x86, 64bit x64)과 부스트 라이브러리가 컴파일된 address-model(32, 64)이 다를 경우 발생하는 오류.


boost를 컴파일 할때 address-model=32 로 했을 경우 타겟 플랫폼은 32bit(x86)이어야 되고

address-model=64는 프로젝트 타겟 64bit(x64) 플랫폼으로 사용되어야 하니 주의할 것.


또 boost는 address-model을 지정해주지 않으면 32bit(x86)으로 컴파일 되니 이것도 주의.


2. C++11 reverse range based for loop (for문 역순)


std::list x { 2, 3, 5, 7, 11, 13, 17, 19 };
    for (auto i : boost::adaptors::reverse(x))
        std::cout << i << '\n';


마지막에 </int>붙는건 티스토리 에디터 버그같으네요.