>

2014년 11월 26일 수요일

CUDA, opencv-3.0.0-beta install - libstdc++

A gui version of CMake was used and the following error happened:

Scanning dependencies of target opencv_test_cudev
[ 32%] Building CXX object modules/cudev/test/CMakeFiles/opencv_test_cudev.dir/test_main.cpp.o
Linking CXX executable ../../../bin/opencv_test_cudev
Undefined symbols for architecture x86_64:
  "cv::PrintTo(cv::Size_<int> const&, std::ostream*)", referenced from:
      std::string testing::PrintToString<cv::Size_<int> >(cv::Size_<int> const&) in opencv_test_cudev_generated_test_warp.cu.o
  "testing::internal::StringStreamToString(std::basic_stringstream<char, std::char_traits<char>, std::allocator<char> >*)", referenced from:
      testing::AssertionResult testing::internal::CmpHelperFloatingPointEQ<float>(char const*, char const*, float, float) in opencv_test_cudev_generated_test_reduction.cu.o

-------------------
** libc++ or libstdc++, that is the question!

$ vi cmake/OpenCVDetectCUDA.cmake

117   # NVCC flags to be set

118   set(NVCC_FLAGS_EXTRA " -Xcompiler -stdlib=libstdc++; -Xlinker -stdlib=libstdc++")

$ vi cmake/OpenCVCompilerOptions.cmake

 26 set(OPENCV_EXTRA_FLAGS "")
 27 set(OPENCV_EXTRA_C_FLAGS "")
 28 set(OPENCV_EXTRA_CXX_FLAGS " -stdlib=libstdc++")
 29 set(OPENCV_EXTRA_FLAGS_RELEASE "")
 30 set(OPENCV_EXTRA_FLAGS_DEBUG "")
 31 set(OPENCV_EXTRA_EXE_LINKER_FLAGS " -stdlib=libstdc++")
 32 set(OPENCV_EXTRA_EXE_LINKER_FLAGS_RELEASE "")

 33 set(OPENCV_EXTRA_EXE_LINKER_FLAGS_DEBUG "")

---
now it was done!

gpu $ make optical_flow
clang++ -stdlib=libstdc++   -L/usr/local/lib -lopencv_core -lopencv_highgui -lopencv_imgproc -lopencv_imgcodecs -lopencv_videoio -lopencv_video -lopencv_cuda -lopencv_cudaarithm -lopencv_cudabgsegm -lopencv_cudafeatures2d -lopencv_cudafilters -lopencv_cudaimgproc -lopencv_cudalegacy -lopencv_cudaoptflow -lopencv_cudastereo -lopencv_cudawarping  optical_flow.cpp   -o optical_flow

yndkMacHost:11.28[15:35:13]gpu $ ./optical_flow ../data/rubberwhale1.png ../data/rubberwhale2.png 
Brox : 0.17475 sec
init done
opengl support available
LK : 0.0214009 sec
Farn : 0.0369818 sec
TVL1 : 0.185709 sec
BM : 0.34601 sec
Fast BM : 0.0497536 sec

! Finished.

----
A method, which had been tried but not recommended.
opencv-3.0.0-beta/build $ vi CMakeCache.txt 

// line 449
//Semi-colon delimit multiple arguments.
CUDA_NVCC_FLAGS:STRING= -Xcompiler -stdlib=libstdc++; -Xlinker -stdlib=libstdc++

---

// line 196
//Flags used by the compiler during all build types.
CMAKE_CXX_FLAGS:STRING= -stdlib=libstdc++

// line 231
//Flags used by the linker.
CMAKE_EXE_LINKER_FLAGS:STRING= -stdlib=libstdc++

-------
build $ make
>> Make succeeded but it started compiling again when I did 'make install' So, this is no good!

댓글 없음:

댓글 쓰기