라이브러리를 C++ cmake
프로젝트에 연결하는 데 하루 종일 보냈습니다.`boost :: gregorian :: greg_month :: as_short_string() const '에 대한 정의되지 않은 참조를 작성하십시오.
따라서 cmake 3.4
및 boost 1.61.0
을 사용하고 있습니다.
void TestClass::getTime() {
this->endDate = boost::posix_time::second_clock::local_time();
}
가 그럼 난 함수를 반환 문자열 endDate
의 값을 반환 할 : 나는 함수 인 클래스가있는 지역의 시간이 소요됩니다
string testCalss::Info() {
return to_simple_string(this->beginningDate);
}
나는 형식을 변환해야 function이 문자열 유형이기 때문에 endDate
을 string
으로 변 환하십시오.
In function boost::date_time::month_formatter<boost::gregorian::greg_month, boost::date_time::simple_format<char>, char>::format_month(boost::gregorian::greg_month const&, std::ostream&)':
/usr/include/boost/date_time/date_formatting.hpp:44: undefined reference to `boost::gregorian::greg_month::as_short_string() const'
/usr/include/boost/date_time/date_formatting.hpp:49: undefined reference to `boost::gregorian::greg_month::as_long_string() const'
내가 data_time는 헤더 전용 라이브러리뿐만 아니라 내가 구축하고 내 프로젝트에 추가해야 읽었습니다 : 프로그램이 연결되는 동안
나는 오류 메시지를 받고 있습니다.
이 명령을 gcc myapp.cpp -omyapp -lboost_date_time
으로 시도했는데 cmake
프로젝트에서 g++
을 사용하고 있기 때문에 작동하지 않으며 g ++에 대해 아무것도 찾지 못했습니다. 라이브러리를 연결하는 방법을 공식 부스트 문서에서
c++ -I path/to/boost_1_61_0 example.cpp -o example \
~/boost/stage/lib/libboost_regex-gcc34-mt-d-1_36.a
그것의 예 :
나는이 시도했다.cmake
프로젝트에서 나는
cpp
파일이 거의 없습니다. 파일을 사용하여이 명령을 실행해야합니까?
이 오류를 해결하는 더 쉬운 방법이 있습니까?