LibstdC ++找不到静态库

时间:2017-09-04 22:40:53

标签: c++ opencv cmake

我使用OpenCV代码编译并运行C ++并成功运行静态库。项目工作正常。

我的CmakeListed.txt

cmake_minimum_required(VERSION 2.8)
PROJECT(word)  
set(OpenCV_DIR "/home/medo/opencv/share" CACHE PATH "docs") 
FIND_PACKAGE( OpenCV REQUIRED ) 
INCLUDE_DIRECTORIES( ${OpenCV_INCLUDE_DIRS} ) 
ADD_EXECUTABLE(wordx Source.cpp) 
TARGET_LINK_LIBRARIES (wordx ${OpenCV_LIBS})

现在我尝试在PHP Linux主机上运行该项目。它给了我以下错误:

"./wordx: /usr/lib64/libstdc++.so.6: version `GLIBCXX_3.4.20' not found (required by ./wordx)"
[1]=>
"./wordx: /usr/lib64/libstdc++.so.6: version `GLIBCXX_3.4.21' not found (required by ./wordx)"
[2]=>
"./wordx: /usr/lib64/libstdc++.so.6: version `GLIBCXX_3.4.15' not found 
(required by ./wordx)"
[3]=>
 "./wordx: /lib64/libc.so.6: version `GLIBC_2.14' not found (required by ./wordx)"

我在Google上搜索并发现:

set(CMAKE_EXE_LINKER_FLAGS "-static-libgcc -static-libstdc++")

我在上面添加了项目:

cmake_minimum_required(VERSION 2.8)
PROJECT(word)  
set(OpenCV_DIR "/home/medo/opencv/share" CACHE PATH "docs") 
set(CMAKE_EXE_LINKER_FLAGS "-static-libgcc  -static-libstdc++")
FIND_PACKAGE( OpenCV REQUIRED ) 
INCLUDE_DIRECTORIES( ${OpenCV_INCLUDE_DIRS} ) 
ADD_EXECUTABLE(wordx Source.cpp) 
TARGET_LINK_LIBRARIES (wordx ${OpenCV_LIBS})

我的代码大小增加但是当我运行项目时,它给了我同样的错误。

0 个答案:

没有答案