0
부스트에서 파일 시스템을 사용할 때 연결 문제가 있습니다. 내가 튜토리얼에서 코드를 복사 :부스트 라이브러리 및 clion을 사용하여 오류로 연결
#include <iostream>
#include <boost/filesystem.hpp>
using namespace boost::filesystem;
int main(int argc, char* argv[])
{
if (argc < 2)
{
std::cout << "Usage: tut1 path\n";
return 1;
}
std::cout << argv[1] << " " << file_size(argv[1]) << '\n';
return 0;
}
은 아마 작동합니다,하지만 난 그런 오류가 있습니다
이Scanning dependencies of target untitled
[ 50%] Building CXX object CMakeFiles/untitled.dir/main.cpp.o
[100%] Linking CXX executable untitled
Undefined symbols for architecture x86_64:
"boost::filesystem::detail::file_size(boost::filesystem::path const&, boost::system::error_code*)", referenced from:
boost::filesystem::file_size(boost::filesystem::path const&) in main.cpp.o
"boost::system::system_category()", referenced from:
___cxx_global_var_init.2 in main.cpp.o
"boost::system::generic_category()", referenced from:
___cxx_global_var_init in main.cpp.o
___cxx_global_var_init.1 in main.cpp.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[3]: *** [untitled] Error 1
make[2]: *** [CMakeFiles/untitled.dir/all] Error 2
make[1]: *** [CMakeFiles/untitled.dir/rule] Error 2
make: *** [untitled] Error 2
내 CMakeLists.txt 파일 :
cmake_minimum_required(VERSION 3.7)
project(untitled)
set(CMAKE_CXX_STANDARD 11)
set(SOURCE_FILES main.cpp)
add_executable(untitled ${SOURCE_FILES})
find_package(Boost)
IF (Boost_FOUND)
include_directories(${Boost_INCLUDE_DIR})
endif()
내가 무엇을 개선 할 수 있습니다 이 코드를 컴파일 하시겠습니까? OSX에서 CLion 편집기를 사용합니다.
make make/makefile/CMakeLists.txt를 알려주세요! – Rama
'cmake_minimum_required (버전 3.7) 프로젝트 (제목) 세트 (CMAKE_CXX_STANDARD 11) 세트 (SOURCE_FILES의 MAIN.CPP) add_executable (제목 $ {SOURCE_FILES}) find_package (부스트) IF (Boost_FOUND) include_directories의 ($ {Boost_INCLUDE_DIR}) endif() 이 붙여 넣기 형식으로 죄송합니다. 여러 줄로 만드는 방법을 모르겠습니다. – emil
@emil 당신은 코멘트에 남기지 않고 질문에 덧붙이고 싶을 것입니다. – chbchb55