提问: /usr/bin/ld: cannot find -lOPTIONS
我在UBUNTU 18.04 下用CUDA 10.2 和 C++11标准编译一个较大的工程。 Makefile 是用CMAKE文件生成的。当我在terminal完成编译时显示了如下错误:
/usr/bin/ld: cannot find -lOPTIONS
collect2: error: ld returned 1 exit status
CMakeFiles/cuda_othermain.dir/build.make:132: recipe for target 'bin/cuda_othermain' failed
make[2]: *** [bin/cuda_othermain] Error 1
CMakeFiles/Makefile2:79: recipe for target 'CMakeFiles/cuda_othermain.dir/all' failed
make[1]: *** [CMakeFiles/cuda_othermain.dir/all] Error 2
Makefile:83: recipe for target 'all' failed
make: *** [all] Error 2
提示是找不到一个叫OPTIONS的库。我的camke和源码里都没有链接这个库,而且我在网上搜索也根本没有一个库叫做OPTIONS。我很疑惑,编译工程时没有显示任何其他错误,顶多就是有几个warning,我查了一下都是没有太大关系的。所以现在没有什么思路去解决这个问题。 所以想请教一下各位有没有什么解决思路。 CMAKE文件如下:
cmake_minimum_required (VERSION 3.8 FATAL_ERROR)
#project (cusam_cuda)
project(cusam_cuda LANGUAGES C CXX CUDA)
find_package(CUDA 10.2 REQUIRED)
set(CUDA_NVCC_FLAGS -std=c++11 -L/usr/local/cuda-10.2/lib64 -lcudart -lcuda)
set(CMAKE_CXX_STANDARD 11)
if (CUDA_VERBOSE_PTXAS)
set(VERBOSE_PTXAS --ptxas-options=-v)
endif (CUDA_VERBOSE_PTXAS)
#set(CMAKE_BUILD_TYPE "Release")
set(CMAKE_BUILD_TYPE "Debug")
SET(CMAKE_CXX_FLAGS_DEBUG "$ENV{CUDA_NVCC_FLAGS} -O0 -Wall -g -ggdb")
SET(CMAKE_CXX_FLAGS_RELEASE "$ENV{CUDA_NVCC_FLAGS} -O3 -Wall")
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
set(GENCODE_SM30
-gencode=arch=compute_30,code=sm_30 -gencode=arch=compute_30,code=compute_30)
set(GENCODE_SM35
-gencode=arch=compute_35,code=sm_35 -gencode=arch=compute_35,code=compute_35)
set(GENCODE_SM37
-gencode=arch=compute_37,code=sm_37 -gencode=arch=compute_37,code=compute_37)
set(GENCODE_SM50
-gencode=arch=compute_50,code=sm_50 -gencode=arch=compute_50,code=compute_50)
set(GENCODE_SM60
-gencode=arch=compute_60,code=sm_60 -gencode=arch=compute_60,code=compute_60)
set(GENCODE_SM61
-gencode=arch=compute_61,code=sm_61 -gencode=arch=compute_61,code=compute_61)
set(GENCODE_SM70
-gencode=arch=compute_70,code=sm_70 -gencode=arch=compute_70,code=compute_70)
set(GENCODE_SM71
-gencode=arch=compute_71,code=sm_71 -gencode=arch=compute_71,code=compute_71)
set(GENCODE_SM75
-gencode=arch=compute_75,code=sm_75 -gencode=arch=compute_75,code=compute_75)
option(CUDAMATRIX_GENCODE_SM30 "GENCODE_SM30" OFF)
option(CUDAMATRIX_GENCODE_SM35 "GENCODE_SM35" ON)
option(CUDAMATRIX_GENCODE_SM37 "GENCODE_SM37" OFF)
option(CUDAMATRIX_GENCODE_SM50 "GENCODE_SM50" OFF)
option(CUDAMATRIX_GENCODE_SM60 "GENCODE_SM60" OFF)
option(CUDAMATRIX_GENCODE_SM61 "GENCODE_SM61" OFF)
option(CUDAMATRIX_GENCODE_SM70 "GENCODE_SM70" OFF)
option(CUDAMATRIX_GENCODE_SM71 "GENCODE_SM71" OFF)
option(CUDAMATRIX_GENCODE_SM75 "GENCODE_SM75" OFF)
if (CUDAMATRIX_GENCODE_SM37)
set(GENCODE ${GENCODE} ${GENCODE_SM37})
endif(CUDAMATRIX_GENCODE_SM37)
if (CUDAMATRIX_GENCODE_SM50)
set(GENCODE ${GENCODE} ${GENCODE_SM50})
endif(CUDAMATRIX_GENCODE_SM50)
if (CUDAMATRIX_GENCODE_SM60)
set(GENCODE ${GENCODE} ${GENCODE_SM60})
endif(CUDAMATRIX_GENCODE_SM60)
if (CUDAMATRIX_GENCODE_SM61)
set(GENCODE ${GENCODE} ${GENCODE_SM61})
endif(CUDAMATRIX_GENCODE_SM61)
if (CUDAMATRIX_GENCODE_SM70)
set(GENCODE ${GENCODE} ${GENCODE_SM70})
endif(CUDAMATRIX_GENCODE_SM70)
if(CUDAMATRIX_GENCODE_SM71)
set(GENCODE ${GENCODE} ${GENCODE_SM71})
endif(CUDAMATRIX_GENCODE_SM71)
if(CUDAMATRIX_GENCODE_SM75)
set(GENCODE ${GENCODE} ${GENCODE_SM75})
endif(CUDAMATRIX_GENCODE_SM75)
include_directories(/usr/local/cuda/include)
include_directories(utils)
#include_directories(3rdparty/googletest/googletest)
#include_directories(3rdparty/googletest/googletest/include)
#add_subdirectory(3rdparty/googletest/googletest googletest.out)
add_subdirectory(geometry)
add_subdirectory(navigation)
add_subdirectory(3rdparty)
add_subdirectory(nonlinear)
add_subdirectory(inference)
add_subdirectory(mat)
add_subdirectory(miniblas)
add_subdirectory(miniblas/cblas)
add_subdirectory(miniblas/blas)
add_subdirectory(miniblas/permutation)
add_subdirectory(miniblas/sys)
add_subdirectory(miniblas/linalg)
add_subdirectory(linear)
#add_subdirectory(test)
#cuda_add_executable(imukittiexamplegps_gaussiannewton imukittiexamplegps_gaussiannewton.cpp
# OPTIONS ${GENCODE} ${CUDA_VERBOSE_PTXAS})
#target_link_libraries(imukittiexamplegps_gaussiannewton geometry miniblas blas cblas linalg permutation sys navigation 3rdparty linear nonlinear inference mat)
#cuda_add_executable(othermain othermain.cpp
# OPTIONS ${GENCODE} ${CUDA_VERBOSE_PTXAS})
#target_link_libraries(othermain geometry miniblas blas cblas linalg permutation sys navigation 3rdparty linear nonlinear inference mat)
target_compile_features(nonlinear PUBLIC cxx_std_11)
cuda_add_executable(cuda_othermain cuda_othermain.cu
OPTIONS ${GENCODE} ${CUDA_VERBOSE_PTXAS})
target_compile_features(cuda_othermain PUBLIC cxx_std_11)
set_target_properties(cuda_othermain
PROPERTIES CUDA_SEPARABLE_COMPILATION ON)
target_link_libraries(cuda_othermain geometry miniblas blas cblas linalg permutation sys navigation 3rdparty linear nonlinear inference mat)
源代码就没发帖了,因为工程还算比较大。有劳各位了。