我的CMake文件在将我的程序与Ubuntu下的Boost库链接时应该是什么样的?
运行期间显示的错误make:
main.cpp:(.text+0x3b): undefined reference to `boost::program_options::options_description::m_default_line_length'
Run Code Online (Sandbox Code Playgroud)
主文件非常简单:
#include <boost/program_options/options_description.hpp>
#include <boost/program_options/option.hpp>
using namespace std;
#include <iostream>
namespace po = boost::program_options;
int main(int argc, char** argv) {
po::options_description desc("Allowed options");
desc.add_options()
("help", "produce help message")
;
return 0;
}
Run Code Online (Sandbox Code Playgroud)
我成功地做到了.我添加到CMake文件的唯一行是:
target_link_libraries(
my_target_file
${Boost_PROGRAM_OPTIONS_LIBRARY}
)
Run Code Online (Sandbox Code Playgroud) 如何Boost在Clion中使用MinGW库?我已下载并解压缩boost_1_60_0.zip至C:\boost_1_60_0.我现在该怎么办?我必须安装一些东西吗?这是我的CMakeLists.txt:
cmake_minimum_required(VERSION 3.3)
project(server_client)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -s -O3")
set(CMAKE_EXE_LINKER_FLAGS -static)
set(BOOST_ROOT "C:/boost_1_60_0")
set(BOOSTROOT "C:/boost_1_60_0")
find_package(Boost 1.60.0)
if(NOT Boost_FOUND)
message(FATAL_ERROR "Could not find boost!")
endif()
set(SOURCE_FILES chat_server.cpp)
add_executable(server_client ${SOURCE_FILES})
Run Code Online (Sandbox Code Playgroud)
找不到Boost: