使openmp g++-6.2.0没有这样的文件[重复]

Posted

技术标签:

【中文标题】使openmp g++-6.2.0没有这样的文件[重复]【英文标题】:make openmp g++-6.2.0 no such file [duplicate] 【发布时间】:2016-12-21 20:56:16 【问题描述】:

cmakelist.txt

cmake_minimum_required(VERSION 3.7)

project(multithreading)

# Find ITK.
find_package(ITK REQUIRED)
include($ITK_USE_FILE)

FIND_PACKAGE( OpenMP REQUIRED)
if(OPENMP_FOUND)
message("OPENMP FOUND")
set(CMAKE_C_FLAGS “$CMAKE_C_FLAGS $OpenMP_C_FLAGS”)
set(CMAKE_CXX_FLAGS “$CMAKE_CXX_FLAGS $OpenMP_CXX_FLAGS“)
set(CMAKE_EXE_LINKER_FLAGS “$CMAKE_EXE_LINKER_FLAGS $OpenMP_EXE_LINKER_FLAGS”)
endif()

add_executable(multithreading multithreading.cpp )

target_link_libraries(multithreading $ITK_LIBRARIES)
TARGET_LINK_LIBRARIES(multithreading $OpenMP_CXX_LIBRARIES)

然后我将默认编译器 AppleClang 更改为 gcc-6.2.0,然后更改为 cmake ,所有openmp标志都找到了,配置就好了。

cmake -DCMAKE_C_COMPILER=/usr/local/gcc-6.2.0/bin/gcc-6.2.0 -DCMAKE_CXX_COMPILER=/usr/local/gcc-6.2.0/bin/g++-6.2.0 ./

-- The C compiler identification is GNU 6.2.0
-- The CXX compiler identification is GNU 6.2.0
-- Checking whether C compiler has -isysroot
-- Checking whether C compiler has -isysroot - yes
-- Checking whether C compiler supports OSX deployment target flag
-- Checking whether C compiler supports OSX deployment target flag - yes
-- Check for working C compiler: /usr/local/gcc-6.2.0/bin/gcc-6.2.0
-- Check for working C compiler: /usr/local/gcc-6.2.0/bin/gcc-6.2.0 -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Checking whether CXX compiler has -isysroot
-- Checking whether CXX compiler has -isysroot - yes
-- Checking whether CXX compiler supports OSX deployment target flag
-- Checking whether CXX compiler supports OSX deployment target flag - yes
-- Check for working CXX compiler: /usr/local/gcc-6.2.0/bin/g++-6.2.0
-- Check for working CXX compiler: /usr/local/gcc-6.2.0/bin/g++-6.2.0 -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Try OpenMP C flag = [-fopenmp]
-- Performing Test OpenMP_FLAG_DETECTED
-- Performing Test OpenMP_FLAG_DETECTED - Success
-- Try OpenMP CXX flag = [-fopenmp]
-- Performing Test OpenMP_FLAG_DETECTED
-- Performing Test OpenMP_FLAG_DETECTED - Success
-- Found OpenMP: -fopenmp  
OPENMP FOUND
-- Configuring done
-- Generating done

接下来,当我“制作”时,它会显示给我

canning dependencies of target multithreading
[ 50%] Building CXX object CMakeFiles/multithreading.dir/multithreading.cpp.o
g++-6.2.0: error: “: No such file or directory
g++-6.2.0: fatal error: no input files
compilation terminated.
/bin/sh: -fopenmp“: command not found
make[2]: *** [CMakeFiles/multithreading.dir/multithreading.cpp.o] Error 127
make[1]: *** [CMakeFiles/multithreading.dir/all] Error 2
make: *** [all] Error 2

如果我执行 g++ -fopenmp myproject.cpp 它不会链接 ITK 库

g++ -fopenmp multithreading.cpp 
multithreading.cpp:4:44: fatal error: itkRescaleIntensityImageFilter.h: No such file or directory
 #include "itkRescaleIntensityImageFilter.h"
                                            ^
compilation terminated.

所以我想知道如何解决这个问题,所以同时使用 itk 和 openmp 作为库。

【问题讨论】:

不要在 CMake 脚本中使用特定语言的双引号 ()。 Similar problem最近出现了。 非常感谢,我不小心 【参考方案1】:

您正在使用特定于语言/区域设置的双引号。大多数编程语言不支持这些,包括 CMake。使用“正常”双引号:"

【讨论】:

以上是关于使openmp g++-6.2.0没有这样的文件[重复]的主要内容,如果未能解决你的问题,请参考以下文章

读取文件时无法使用 OpenMP 获得加速

如何使用 g++ 编译 openmp

Vscode运行c++的openmp并行问题

如何用openmp编译c ++? (在Windows 10中使用g ++)

无法使 OpenMP 与 CodeBlocks 和 GFortran 一起工作

OpenMP为啥这段程序是死锁?