相关疑难解决方法(0)

如何让CMake找到我的替代Boost安装?

我已经安装了最新版本的Boost /usr/local(包含in /usr/local/include/boost和库/usr/local/lib/boost),我现在正尝试从源代码安装Wt,但CMake(版本2.6)似乎无法找到Boost安装.它尝试提供有关设置BOOST_DIR和Boost_LIBRARYDIR的有用建议,但我无法通过调整这些变量来使其工作.

我得到的最新错误消息是它找不到库,但它似乎表明它正在使用"/ usr/local/include"作为包含路径,这是不正确的(我可以'似乎解决了这个问题).是否有一个解决方案,他们的头顶,或者我需要在CMake内部捣乱才能弄明白?

linux build-automation boost cmake wt

51
推荐指数
8
解决办法
10万
查看次数

如何使用CMake将外部库(boost)包含到CLion C++项目中?

我有以下C++开发设置:

  • OS X Yosemite
  • CLion 140.2310.6(一个跨平台的C/C++ - 由JetBrains CMake用作构建系统的IDE )
  • boost通过安装brew install boost/usr/local/Cellar/boost/

现在,我的目标是设置一个简单的项目并包含boost库.我只定义了一个看起来像这样的test.cpp文件:

#include <iostream>
#include <boost>

using namespace std;

int test() {
    cout << "Hello, World!" << endl;
    return 0; 
}
Run Code Online (Sandbox Code Playgroud)

我的CMakeLists.txt文件如下所示:

cmake_minimum_required(VERSION 2.8.4) 
project(MyProject)

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") 

include_directories("/usr/local/Cellar/boost/1.57.0/include/boost")

set(SOURCE_FILES main.cpp ./test.cpp)
add_executable(MyProject ${SOURCE_FILES}) 
Run Code Online (Sandbox Code Playgroud)

当我构建项目时,我收到以下错误:

/Users/nburk/Documents/uni/master/master_thesis/MyProject/test.cpp:2:10:致命错误:找不到'boost'文件

make [3]:***[CMakeFiles/MyProject.dir/test.cpp.o]错误1 make [2]:***[CMakeFiles/MyProject.dir/all]错误2 make [1]:***[CMakeFiles/MyProject.dir/rule]错误2 make:***[MyProject]错误2

我在这里和那里调整路径,并使用add_librarytarget_link_libraries,没有一个使项目成功构建.

有人能指出正确的方向如何确保我可以boost在我的CLion C++项目中包含功能吗?

更新: 感谢@ Waxo的回答我在我的CMakeLists.txt …

c++ boost cmake clion

47
推荐指数
2
解决办法
7万
查看次数

如何使用cmake链接boost.system

我使用cmake生成的makefile来编译依赖于boost文件系统库的c ++文件.

在链接过程中,我收到以下错误:

Undefined symbols:
  "boost::system::get_generic_category()", referenced from:
      __static_initialization_and_destruction_0(int, int)in FaceRecognizer.cpp.o
      __static_initialization_and_destruction_0(int, int)in FaceRecognizer.cpp.o
      __static_initialization_and_destruction_0(int, int)in FaceRecognizer.cpp.o
  "boost::system::get_system_category()", referenced from:
      __static_initialization_and_destruction_0(int, int)in FaceRecognizer.cpp.o
      __static_initialization_and_destruction_0(int, int)in FaceRecognizer.cpp.o
ld: symbol(s) not found
collect2: ld returned 1 exit status
make[2]: *** [src/ImageMarker] Error 1

生成此错误的makefile中的操作是以下行:

cd /Users/janusz/Documents/workspace/ImageMarker/Debug/src && /opt/local/bin/cmake -E cmake_link_script CMakeFiles/ImageMarker.dir/link.txt --verbose=1
/usr/bin/c++   -O3 -Wall -Wno-deprecated -g -verbose -Wl,-search_paths_first -headerpad_max_install_names -fPIC CMakeFiles/ImageMarker.dir/ImageMarker.cpp.o CMakeFiles/ImageMarker.dir/Image.cpp.o CMakeFiles/ImageMarker.dir/utils.cpp.o CMakeFiles/ImageMarker.dir/XMLWriter.cpp.o CMakeFiles/ImageMarker.dir/FaceRecognizer.cpp.o  -o ImageMarker  -L/opt/local/lib ../libTinyXml.a /opt/local/lib/libboost_filesystem-mt.dylib 

一些谷歌搜索告诉我,这个错误似乎在使用boost文件系统库的mac上很常见,因为我必须链接到boost.system库或根据boost.system库创建我的项目.

如何在没有硬编码库路径的情况下强制cmake链接到库?

这是otool的结果:

otool -L /opt/local/lib/libboost_filesystem-mt.dylib
 /opt/local/lib/libboost_filesystem-mt.dylib:
 /opt/local/lib/libboost_filesystem-mt.dylib (compatibility version 0.0.0, …
Run Code Online (Sandbox Code Playgroud)

c++ macos linker boost cmake

35
推荐指数
2
解决办法
4万
查看次数

链接Boost线程库

我正在尝试将 Boost 的线程库包含在我的 C++ 项目中。我的 CMake 文件是这样的:

cmake_minimum_required(VERSION 3.6)
project(LearningC)

find_package(Boost REQUIRED)
include_directories(${Boost_INCLUDE_DIR})

set(CMAKE_CXX_STANDARD 11)

set(SOURCE_FILES main.cpp Student.cpp Student.h)

add_executable(LearningC ${SOURCE_FILES})

target_link_libraries(LearningC ${Boost_LIBRARIES})
Run Code Online (Sandbox Code Playgroud)

我收到错误:

Undefined symbols for architecture x86_64:
  "boost::this_thread::interruption_point()", referenced from:
      boost::condition_variable::wait(boost::unique_lock<boost::mutex>&) in main.cpp.o
   [More stack traces...]
Run Code Online (Sandbox Code Playgroud)

我究竟做错了什么?

c++ boost cmake

5
推荐指数
2
解决办法
1万
查看次数

vcpkg + cmake + visual studio无法正常工作

我有一个使用boost和zmq库的基于cmake的C ++项目。

我正在尝试使用Visual Studio Community 2017和vcpkg在Windows上构建它。

我按照项目页面上的说明安装了vcpkg。

现在,我可以看到已安装所需的软件包:

PS C:\Users\me\source\repos\vcpkg> .\vcpkg list
boost-accumulators:x64-windows                     1.67.0           Boost accumulators module
boost-accumulators:x86-windows                     1.67.0           Boost accumulators module
boost-algorithm:x64-windows                        1.67.0           Boost algorithm module
boost-algorithm:x86-windows                        1.67.0           Boost algorithm module
…
boost-variant:x64-windows                          1.67.0           Boost variant module
boost-variant:x86-windows                          1.67.0           Boost variant module
boost-vcpkg-helpers:x64-windows                    4                a set of vcpkg-internal scripts used to modulari...
boost-vcpkg-helpers:x86-windows                    4                a set of vcpkg-internal scripts used to modulari...
boost-vmd:x64-windows                              1.67.0           Boost vmd module
boost-vmd:x86-windows                              1.67.0           Boost vmd module
boost-wave:x64-windows                             1.67.0           Boost wave module
boost-wave:x86-windows                             1.67.0 …
Run Code Online (Sandbox Code Playgroud)

c++ cmake visual-studio vcpkg

5
推荐指数
1
解决办法
1465
查看次数

如何为 Visual Studio 代码设置 boost

所以我基本上构建了整个boost库并将它们放在C:\boost\include\boost-1_73中。但我有一种感觉,在使用这个库之前我必须包含更多步骤。我一直遵循本指南,直到将其设置为 Visual Studio 代码。所以现在我正在互联网上搜索如何设置它。这是我遵循的指南。但我没有像指南中那样将其包含在program_files目录中。

https://gist.github.com/sim642/29caef3cc8afaa273ce6

在我的 Task.Json 中我有

{
    "version": "2.0.0",
    "tasks": [
        {
            "type": "shell",
            "label": "C/C++: g++.exe build active file",
            "command": "C:\\new\\mingw-w64\\i686-8.1.0-posix-dwarf-rt_v6-rev0\\mingw32\\bin\\g++.exe",
            "args": [
                "-g",
                "${fileDirname}\\**.cpp",
                "-o",
                "${fileDirname}\\${fileBasenameNoExtension}.exe",      
            ],
            "options": {
                "cwd": "${workspaceFolder}"
            },
            "problemMatcher": [
                "$gcc"
            ],
            "group": {
                "kind": "build",
                "isDefault": true
            }
        }
    ]
}
Run Code Online (Sandbox Code Playgroud)

在我的主要 settings.json 中我有

{
    "terminal.integrated.shell.windows": "C:\\WINDOWS\\System32\\cmd.exe",
    "code-runner.saveFileBeforeRun": true,
    "code-runner.saveAllFilesBeforeRun": true,
    "code-runner.fileDirectoryAsCwd": true,
    "code-runner.ignoreSelection": true,
    "haskelly.exec.reuseTerminal": true,
    "C_Cpp.updateChannel": "Insiders",
    "r.rterm.windows": "C:\\Program Files\\R\\R-3.6.1\\bin\\R",
    "vsicons.dontShowNewVersionMessage": true,
    "files.autoSave": "onWindowChange",
    "workbench.colorCustomizations": {},
    "editor.tokenColorCustomizations": null,
    "php.validate.executablePath": …
Run Code Online (Sandbox Code Playgroud)

c++ boost visual-studio-code

5
推荐指数
1
解决办法
1万
查看次数