相关疑难解决方法(0)

CMake无法找到OpenMP

我正在尝试使用OpenMP进行编译.我CMakeLists.txt包含这条线

find_package(OpenMP REQUIRED)

和CMake错误

CMake Error at /opt/ros/groovy/share/catkin/cmake/catkinConfig.cmake:72 (find_package):
  Could not find a configuration file for package openmp.

  Set openmp_DIR to the directory containing a CMake configuration file for
  openmp.  The file will have one of the following names:

    openmpConfig.cmake
    openmp-config.cmake
Run Code Online (Sandbox Code Playgroud)

检查我的文件系统,我看到我有/usr/share/cmake-2.8/Modules/FindOpenMP.cmake但没有openmpConfig.cmakeopenmp-config.cmake.我需要做些什么来解决这个问题?

cmake openmp

14
推荐指数
3
解决办法
2万
查看次数

Configure CMake in windows to use clang from command line to get modern OpenMP support

I have a small test project that uses OpenMP for parallelization. My target is to compile it so it produces .dll and .lib for libraries (because my real project links to external libraries distributed using these types), with support for OpenMP 4.5 or newer and do it from the command line so it can be done on a docker for testing and checking (the docker part is out of the scope of this question, it is just for reference on …

c++ dll cmake clang visual-studio

9
推荐指数
1
解决办法
270
查看次数

如何使用CMake在链接命令行的末尾添加标志?

我有一个问题,其中CMake 无法检测到pthread。作为一种解决方法,我尝试过:

set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -lpthread")
Run Code Online (Sandbox Code Playgroud)

但是,这会插入-lpthread错误的位置:

/usr/bin/c++    -std=c++11 -D_GNU_SOURCE  -Wall [manyflags ...]    -lpthread \
    CMakeFiles/connectivity_tool.dir/connectivity_tool/conn_tool.cpp.o       \
    -o connectivity_tool -rdynamic -lboost_system [many libraries...]
Run Code Online (Sandbox Code Playgroud)

结果是:

/usr/bin/ld: /tmp/ccNvRifh.ltrans3.ltrans.o: undefined reference to symbol 'pthread_mutexattr_settype@@GLIBC_2.2.5'
/lib/x86_64-linux-gnu/libpthread.so.0: error adding symbols: DSO missing from command line
Run Code Online (Sandbox Code Playgroud)

当然,-lpthread应当位于第三行的末尾,而不是第一行的末尾。

我该如何要么-lpthread在此行的末尾添加CMake,要么以某种不可靠的方式修改生成的Makefile,以使其正常工作?

(如果答案涉及实际检测pthread,请回答链接的问题。)

c++ linker makefile compilation cmake

6
推荐指数
1
解决办法
8214
查看次数

标签 统计

cmake ×3

c++ ×2

clang ×1

compilation ×1

dll ×1

linker ×1

makefile ×1

openmp ×1

visual-studio ×1