2016-05-05 13 views
-2

私はC++ CmakeとClionには比較的新しいので、私はClion(私はUbuntu Gnome上で動作します)でプロジェクト用にCGALをインストールするのに苦労しました。私はここや他の場所で同様の問題を見つけることができず、今一週間以上ブロックされているので、私はいくつかの助けに大いに感謝します。CLION/LinuxプロジェクトにCGALを含めるには

私はCGAL Cmake GUIをインストールして、makeとインストールを実行します。 Clionで、次のCMakeList.txtで:ここ

cmake_minimum_required(VERSION 3.5) 
project(AGRAN) 

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -frounding-math") 

find_package(OpenCV REQUIRED) 
include_directories(${OpenCV_INCLUDE_DIRS}) 
set(LIBS ${LIBS} ${OpenCV_LIBRARIES}) 

find_package(CGAL REQUIRED COMPONENTS Core GMP RS3 MPFI) 
include_directories(${CGAL_INCLUDE_DIRS}) 
set(LIBS ${LIBS} ${CGAL_LIBRARIES}) 

find_package(Boost REQUIRED) 
include_directories(${Boost_INCLUDE_DIRS}) 
set(LIBS ${LIBS} ${Boost_LIBRARIES}) 

set(SOURCE_FILES main.cpp) 
add_executable(AGRAN ${SOURCE_FILES}) 
target_link_libraries(AGRAN ${LIBS}) 

とmain.cppにある:

私は外部ライブラリ/ヘッダ検索パスにそのファイルを見ることができるようにCGALはClionによってreckognizedさ
#include <iostream> 
#include <CGAL/Nef_polyhedron_3.h> 

using namespace std; 

int main() { 
    cout << "Hello, World!" << endl; 
    return 0; 
} 

オートコンプリートとして、ここではNef_polyhedron_3.hのようなCGAL要素を識別します。

/home/jeremie/CMake/cmake-3.5.2-Linux-x86_64/bin/cmake --build/home/jeremie/.CLion2016.1/system/cmake/generated/AGRAN-39898ace/39898ace/Debug0 --target AGRAN -- -j 8 
[ 50%] Building CXX object CMakeFiles/AGRAN.dir/main.cpp.o 
CMakeFiles/AGRAN.dir/main.cpp.o: In function `CGAL::Interval_nt<false>::Test_runtime_rounding_modes::Test_runtime_rounding_modes()': 
/usr/local/include/CGAL/Interval_nt.h:208: undefined reference to `CGAL::assertion_fail(char const*, char const*, int, char const*)' 
/usr/local/include/CGAL/Interval_nt.h:210 
間隔nt.h見た

:208私は見ることができ、まだこの単純な未使用で、私は、イベントログから「ビルドがで... MS失敗しました」とメッセージがウィンドウの出力を構築し得る文を含めます次のコード抽出:

typename Interval_nt<>::Internal_protector P; 
CGAL_assertion_msg(-CGAL_IA_MUL(-1.1, 10.1) != CGAL_IA_MUL(1.1, 10.1), 
"Wrong rounding: did you forget the -frounding-math option if you use GCC (or -fp-model strict for Intel)?"); 
CGAL_assertion_msg(-CGAL_IA_DIV(-1., 10) != CGAL_IA_DIV(1., 10), 
"Wrong rounding: did you forget the -frounding-math option if you use GCC (or -fp-model strict for Intel)?"); 
} 

私はCMakeLists.txtに(成功なしで)-frounding-mathを追加しました。私はCMAKE_CXX_FALGSがCGALを構築するときにCmakeの-frounding-mathであることも確認しました(画像参照)。ここで

CMAKE CAPTURE CGAL BUILD CMAKE CXX FLAGS -frounding-math

マルクによって示唆されているようにmake VERBOSE=1出力されます:マークは、問題を示唆し

/home/jeremie/CMake/cmake-3.5.2-Linux-x86_64/bin/cmake --build /home/jeremie/.CLion2016.1/system/cmake/generated/AGRAN-39898ace/39898ace/Debug0 --target AGRAN -- -j 8 
/home/jeremie/CMake/cmake-3.5.2-Linux-x86_64/bin/cmake -H/home/jeremie/ClionProjects/AGRAN -B/home/jeremie/.CLion2016.1/system/cmake/generated/AGRAN-39898ace/39898ace/Debug0 --check-build-system CMakeFiles/Makefile.cmake 0 
/usr/bin/make -f CMakeFiles/Makefile2 AGRAN 
make[1]: Entering directory '/home/jeremie/.CLion2016.1/system/cmake/generated/AGRAN-39898ace/39898ace/Debug0' 
/home/jeremie/CMake/cmake-3.5.2-Linux-x86_64/bin/cmake -H/home/jeremie/ClionProjects/AGRAN -B/home/jeremie/.CLion2016.1/system/cmake/generated/AGRAN-39898ace/39898ace/Debug0 --check-build-system CMakeFiles/Makefile.cmake 0 
/home/jeremie/CMake/cmake-3.5.2-Linux-x86_64/bin/cmake -E cmake_progress_start /home/jeremie/.CLion2016.1/system/cmake/generated/AGRAN-39898ace/39898ace/Debug0/CMakeFiles 2 
/usr/bin/make -f CMakeFiles/Makefile2 CMakeFiles/AGRAN.dir/all 
make[2]: Entering directory '/home/jeremie/.CLion2016.1/system/cmake/generated/AGRAN-39898ace/39898ace/Debug0' 
/usr/bin/make -f CMakeFiles/AGRAN.dir/build.make CMakeFiles/AGRAN.dir/depend 
make[3]: Entering directory '/home/jeremie/.CLion2016.1/system/cmake/generated/AGRAN-39898ace/39898ace/Debug0' 
cd /home/jeremie/.CLion2016.1/system/cmake/generated/AGRAN-39898ace/39898ace/Debug0 && /home/jeremie/CMake/cmake-3.5.2-Linux-x86_64/bin/cmake -E cmake_depends "Unix Makefiles" /home/jeremie/ClionProjects/AGRAN /home/jeremie/ClionProjects/AGRAN /home/jeremie/.CLion2016.1/system/cmake/generated/AGRAN-39898ace/39898ace/Debug0 /home/jeremie/.CLion2016.1/system/cmake/generated/AGRAN-39898ace/39898ace/Debug0 /home/jeremie/.CLion2016.1/system/cmake/generated/AGRAN-39898ace/39898ace/Debug0/CMakeFiles/AGRAN.dir/DependInfo.cmake --color= 
make[3]: Leaving directory '/home/jeremie/.CLion2016.1/system/cmake/generated/AGRAN-39898ace/39898ace/Debug0' 
/usr/bin/make -f CMakeFiles/AGRAN.dir/build.make CMakeFiles/AGRAN.dir/build 
make[3]: Entering directory '/home/jeremie/.CLion2016.1/system/cmake/generated/AGRAN-39898ace/39898ace/Debug0' 
[ 50%] Linking CXX executable AGRAN 
/home/jeremie/CMake/cmake-3.5.2-Linux-x86_64/bin/cmake -E cmake_link_script CMakeFiles/AGRAN.dir/link.txt --verbose=1 
/usr/bin/c++ -std=c++11 -frounding-math -g CMakeFiles/AGRAN.dir/main.cpp.o -o AGRAN /usr/local/lib/libopencv_videostab.so.3.1.0 /usr/local/lib/libopencv_superres.so.3.1.0 /usr/local/lib/libopencv_stitching.so.3.1.0 /usr/local/lib/libopencv_shape.so.3.1.0 /usr/local/lib/libopencv_photo.so.3.1.0 /usr/local/lib/libopencv_objdetect.so.3.1.0 /usr/local/lib/libopencv_calib3d.so.3.1.0 /usr/local/lib/libopencv_features2d.so.3.1.0 /usr/local/lib/libopencv_ml.so.3.1.0 /usr/local/lib/libopencv_highgui.so.3.1.0 /usr/local/lib/libopencv_videoio.so.3.1.0 /usr/local/lib/libopencv_imgcodecs.so.3.1.0 /usr/local/lib/libopencv_flann.so.3.1.0 /usr/local/lib/libopencv_video.so.3.1.0 /usr/local/lib/libopencv_imgproc.so.3.1.0 /usr/local/lib/libopencv_core.so.3.1.0 -Wl,-rpath,/usr/local/lib 
CMakeFiles/AGRAN.dir/main.cpp.o: In function `CGAL::Interval_nt<false>::Test_runtime_rounding_modes::Test_runtime_rounding_modes()': 
/usr/local/include/CGAL/Interval_nt.h:208: undefined reference to `CGAL::assertion_fail(char const*, 

:VERBOSEでプロジェクトを作るとき

/home/jeremie/CMake/cmake-3.5.2-Linux-x86_64/bin/cmake -H/home/jeremie/CLibraries/CGAL-4.8 -B/home/jeremie/CLibraries/CGAL-4.8/build --check-build-system CMakeFiles/Makefile.cmake 0 
/home/jeremie/CMake/cmake-3.5.2-Linux-x86_64/bin/cmake -E cmake_progress_start /home/jeremie/CLibraries/CGAL-4.8/build/CMakeFiles /home/jeremie/CLibraries/CGAL-4.8/build/CMakeFiles/progress.marks 
make -f CMakeFiles/Makefile2 all 
make[1]: Entering directory '/home/jeremie/CLibraries/CGAL-4.8/build' 
make -f src/CGAL/CMakeFiles/CGAL.dir/build.make src/CGAL/CMakeFiles/CGAL.dir/depend 
make[2]: Entering directory '/home/jeremie/CLibraries/CGAL-4.8/build' 
cd /home/jeremie/CLibraries/CGAL-4.8/build && /home/jeremie/CMake/cmake-3.5.2-Linux-x86_64/bin/cmake -E cmake_depends "Unix Makefiles" /home/jeremie/CLibraries/CGAL-4.8 /home/jeremie/CLibraries/CGAL-4.8/src/CGAL /home/jeremie/CLibraries/CGAL-4.8/build /home/jeremie/CLibraries/CGAL-4.8/build/src/CGAL /home/jeremie/CLibraries/CGAL-4.8/build/src/CGAL/CMakeFiles/CGAL.dir/DependInfo.cmake --color= 
Dependee "/home/jeremie/CLibraries/CGAL-4.8/build/src/CGAL/CMakeFiles/CGAL.dir/DependInfo.cmake" is newer than depender "/home/jeremie/CLibraries/CGAL-4.8/build/src/CGAL/CMakeFiles/CGAL.dir/depend.internal". 
Dependee "/home/jeremie/CLibraries/CGAL-4.8/build/src/CGAL/CMakeFiles/CMakeDirectoryInformation.cmake" is newer than depender "/home/jeremie/CLibraries/CGAL-4.8/build/src/CGAL/CMakeFiles/CGAL.dir/depend.internal". 
Scanning dependencies of target CGAL 
make[2]: Leaving directory '/home/jeremie/CLibraries/CGAL-4.8/build' 
make -f src/CGAL/CMakeFiles/CGAL.dir/build.make src/CGAL/CMakeFiles/CGAL.dir/build 
make[2]: Entering directory '/home/jeremie/CLibraries/CGAL-4.8/build' 
[ 16%] Building CXX object src/CGAL/CMakeFiles/CGAL.dir/all_files.cpp.o 
cd /home/jeremie/CLibraries/CGAL-4.8/build/src/CGAL && /usr/bin/c++ -DCGAL_EXPORTS -DCGAL_USE_GMP -DCGAL_USE_MPFR -I/home/jeremie/CLibraries/CGAL-4.8/build/include -I/home/jeremie/CLibraries/CGAL-4.8/include -isystem /usr/include/x86_64-linux-gnu -frounding-math -O3 -DNDEBUG -fPIC -o CMakeFiles/CGAL.dir/all_files.cpp.o -c /home/jeremie/CLibraries/CGAL-4.8/build/src/CGAL/all_files.cpp 
[ 33%] Linking CXX shared library ../../lib/libCGAL.so 
cd /home/jeremie/CLibraries/CGAL-4.8/build/src/CGAL && /home/jeremie/CMake/cmake-3.5.2-Linux-x86_64/bin/cmake -E cmake_link_script CMakeFiles/CGAL.dir/link.txt --verbose=1 
/usr/bin/c++ -fPIC -frounding-math -O3 -DNDEBUG -shared -Wl,-soname,libCGAL.so.11 -o ../../lib/libCGAL.so.11.0.2 CMakeFiles/CGAL.dir/all_files.cpp.o -lmpfr -lgmp -lboost_thread -lboost_system -lboost_chrono -lboost_date_time -lboost_atomic 
cd /home/jeremie/CLibraries/CGAL-4.8/build/src/CGAL && /home/jeremie/CMake/cmake-3.5.2-Linux-x86_64/bin/cmake -E cmake_symlink_library ../../lib/libCGAL.so.11.0.2 ../../lib/libCGAL.so.11 ../../lib/libCGAL.so 
make[2]: Leaving directory '/home/jeremie/CLibraries/CGAL-4.8/build' 
[ 33%] Built target CGAL 
make -f src/CGAL_Core/CMakeFiles/CGAL_Core.dir/build.make src/CGAL_Core/CMakeFiles/CGAL_Core.dir/depend 
make[2]: Entering directory '/home/jeremie/CLibraries/CGAL-4.8/build' 
cd /home/jeremie/CLibraries/CGAL-4.8/build && /home/jeremie/CMake/cmake-3.5.2-Linux-x86_64/bin/cmake -E cmake_depends "Unix Makefiles" /home/jeremie/CLibraries/CGAL-4.8 /home/jeremie/CLibraries/CGAL-4.8/src/CGAL_Core /home/jeremie/CLibraries/CGAL-4.8/build /home/jeremie/CLibraries/CGAL-4.8/build/src/CGAL_Core /home/jeremie/CLibraries/CGAL-4.8/build/src/CGAL_Core/CMakeFiles/CGAL_Core.dir/DependInfo.cmake --color= 
Dependee "/home/jeremie/CLibraries/CGAL-4.8/build/src/CGAL_Core/CMakeFiles/CGAL_Core.dir/DependInfo.cmake" is newer than depender "/home/jeremie/CLibraries/CGAL-4.8/build/src/CGAL_Core/CMakeFiles/CGAL_Core.dir/depend.internal". 
Dependee "/home/jeremie/CLibraries/CGAL-4.8/build/src/CGAL_Core/CMakeFiles/CMakeDirectoryInformation.cmake" is newer than depender "/home/jeremie/CLibraries/CGAL-4.8/build/src/CGAL_Core/CMakeFiles/CGAL_Core.dir/depend.internal". 
Scanning dependencies of target CGAL_Core 
make[2]: Leaving directory '/home/jeremie/CLibraries/CGAL-4.8/build' 
make -f src/CGAL_Core/CMakeFiles/CGAL_Core.dir/build.make src/CGAL_Core/CMakeFiles/CGAL_Core.dir/build 
make[2]: Entering directory '/home/jeremie/CLibraries/CGAL-4.8/build' 
[ 50%] Building CXX object src/CGAL_Core/CMakeFiles/CGAL_Core.dir/all_files.cpp.o 
cd /home/jeremie/CLibraries/CGAL-4.8/build/src/CGAL_Core && /usr/bin/c++ -DCGAL_Core_EXPORTS -DCGAL_USE_GMP -DCGAL_USE_MPFR -I/home/jeremie/CLibraries/CGAL-4.8/build/include -I/home/jeremie/CLibraries/CGAL-4.8/include -isystem /usr/include/x86_64-linux-gnu -frounding-math -O3 -DNDEBUG -fPIC -o CMakeFiles/CGAL_Core.dir/all_files.cpp.o -c /home/jeremie/CLibraries/CGAL-4.8/build/src/CGAL_Core/all_files.cpp 
[ 66%] Linking CXX shared library ../../lib/libCGAL_Core.so 
cd /home/jeremie/CLibraries/CGAL-4.8/build/src/CGAL_Core && /home/jeremie/CMake/cmake-3.5.2-Linux-x86_64/bin/cmake -E cmake_link_script CMakeFiles/CGAL_Core.dir/link.txt --verbose=1 
/usr/bin/c++ -fPIC -frounding-math -O3 -DNDEBUG -shared -Wl,-soname,libCGAL_Core.so.11 -o ../../lib/libCGAL_Core.so.11.0.2 CMakeFiles/CGAL_Core.dir/all_files.cpp.o -L/home/jeremie/CLibraries/CGAL-4.8/build/lib -lmpfr -lgmp ../../lib/libCGAL.so.11.0.2 -lboost_thread -lboost_system -lboost_chrono -lboost_date_time -lboost_atomic -lmpfr -lgmp -lboost_thread -lboost_system -lboost_chrono -lboost_date_time -lboost_atomic -Wl,-rpath,/home/jeremie/CLibraries/CGAL-4.8/build/lib: 
cd /home/jeremie/CLibraries/CGAL-4.8/build/src/CGAL_Core && /home/jeremie/CMake/cmake-3.5.2-Linux-x86_64/bin/cmake -E cmake_symlink_library ../../lib/libCGAL_Core.so.11.0.2 ../../lib/libCGAL_Core.so.11 ../../lib/libCGAL_Core.so 
make[2]: Leaving directory '/home/jeremie/CLibraries/CGAL-4.8/build' 
[ 66%] Built target CGAL_Core 
make -f src/CGAL_ImageIO/CMakeFiles/CGAL_ImageIO.dir/build.make src/CGAL_ImageIO/CMakeFiles/CGAL_ImageIO.dir/depend 
make[2]: Entering directory '/home/jeremie/CLibraries/CGAL-4.8/build' 
cd /home/jeremie/CLibraries/CGAL-4.8/build && /home/jeremie/CMake/cmake-3.5.2-Linux-x86_64/bin/cmake -E cmake_depends "Unix Makefiles" /home/jeremie/CLibraries/CGAL-4.8 /home/jeremie/CLibraries/CGAL-4.8/src/CGAL_ImageIO /home/jeremie/CLibraries/CGAL-4.8/build /home/jeremie/CLibraries/CGAL-4.8/build/src/CGAL_ImageIO /home/jeremie/CLibraries/CGAL-4.8/build/src/CGAL_ImageIO/CMakeFiles/CGAL_ImageIO.dir/DependInfo.cmake --color= 
Dependee "/home/jeremie/CLibraries/CGAL-4.8/build/src/CGAL_ImageIO/CMakeFiles/CGAL_ImageIO.dir/DependInfo.cmake" is newer than depender "/home/jeremie/CLibraries/CGAL-4.8/build/src/CGAL_ImageIO/CMakeFiles/CGAL_ImageIO.dir/depend.internal". 
Dependee "/home/jeremie/CLibraries/CGAL-4.8/build/src/CGAL_ImageIO/CMakeFiles/CMakeDirectoryInformation.cmake" is newer than depender "/home/jeremie/CLibraries/CGAL-4.8/build/src/CGAL_ImageIO/CMakeFiles/CGAL_ImageIO.dir/depend.internal". 
Scanning dependencies of target CGAL_ImageIO 
make[2]: Leaving directory '/home/jeremie/CLibraries/CGAL-4.8/build' 
make -f src/CGAL_ImageIO/CMakeFiles/CGAL_ImageIO.dir/build.make src/CGAL_ImageIO/CMakeFiles/CGAL_ImageIO.dir/build 
make[2]: Entering directory '/home/jeremie/CLibraries/CGAL-4.8/build' 
[ 83%] Building CXX object src/CGAL_ImageIO/CMakeFiles/CGAL_ImageIO.dir/all_files.cpp.o 
cd /home/jeremie/CLibraries/CGAL-4.8/build/src/CGAL_ImageIO && /usr/bin/c++ -DCGAL_ImageIO_EXPORTS -DCGAL_USE_GMP -DCGAL_USE_MPFR -DCGAL_USE_ZLIB -I/home/jeremie/CLibraries/CGAL-4.8/build/include -I/home/jeremie/CLibraries/CGAL-4.8/include -isystem /usr/include/x86_64-linux-gnu -isystem /home/jeremie/CLibraries/CGAL-4.8/src/CGAL_ImageIO/. -frounding-math -O3 -DNDEBUG -fPIC -o CMakeFiles/CGAL_ImageIO.dir/all_files.cpp.o -c /home/jeremie/CLibraries/CGAL-4.8/build/src/CGAL_ImageIO/all_files.cpp 
[100%] Linking CXX shared library ../../lib/libCGAL_ImageIO.so 
cd /home/jeremie/CLibraries/CGAL-4.8/build/src/CGAL_ImageIO && /home/jeremie/CMake/cmake-3.5.2-Linux-x86_64/bin/cmake -E cmake_link_script CMakeFiles/CGAL_ImageIO.dir/link.txt --verbose=1 
/usr/bin/c++ -fPIC -frounding-math -O3 -DNDEBUG -shared -Wl,-soname,libCGAL_ImageIO.so.11 -o ../../lib/libCGAL_ImageIO.so.11.0.2 CMakeFiles/CGAL_ImageIO.dir/all_files.cpp.o -L/home/jeremie/CLibraries/CGAL-4.8/build/lib -lmpfr -lgmp ../../lib/libCGAL.so.11.0.2 -lboost_thread -lboost_system -lboost_chrono -lboost_date_time -lboost_atomic -lGLU -lGL -lz -lmpfr -lgmp -lboost_thread -lboost_system -lboost_chrono -lboost_date_time -lboost_atomic -Wl,-rpath,/home/jeremie/CLibraries/CGAL-4.8/build/lib: 
cd /home/jeremie/CLibraries/CGAL-4.8/build/src/CGAL_ImageIO && /home/jeremie/CMake/cmake-3.5.2-Linux-x86_64/bin/cmake -E cmake_symlink_library ../../lib/libCGAL_ImageIO.so.11.0.2 ../../lib/libCGAL_ImageIO.so.11 ../../lib/libCGAL_ImageIO.so 
make[2]: Leaving directory '/home/jeremie/CLibraries/CGAL-4.8/build' 
[100%] Built target CGAL_ImageIO 
make[1]: Leaving directory '/home/jeremie/CLibraries/CGAL-4.8/build' 
/home/jeremie/CMake/cmake-3.5.2-Linux-x86_64/bin/cmake -E cmake_progress_start /home/jeremie/CLibraries/CGAL-4.8/build/CMakeFiles 0 

、ここでは出力されますが上エラーを明らかにする関数CGAL::assertion_failで示されているライブラリのリンクが正しくないことが原因です。実際、-lCGALフラグは表示されません。問題になるでしょうか?これを修正するために何を変更する必要がありますか?

+1

これは、丸めとは何の関係もありません、それはあなたが適切libCGALとリンクされていないことを意味する、あなたが関数assertion_failが欠落していると言います。 'make VERBOSE = 1'を実行して、コンパイラがどのように呼び出されているかを正確に調べるべきです。 –

+0

@MarcGlisse:多くのコメントを投稿しないように、質問を更新しました。メッセージありがとうございます。 –

+0

CGAL(これは正常に動作しています)のログを投稿したようですが、興味深いログはプロジェクトをビルドする際のエラーです。リンクコマンドに '-lCGAL'やそれと同等のものが存在するかどうかをチェックしたかったのです。 –

答えて

-1

問題はCMakeList.txtファイルが正しくないことが原因です。ここで動作するバージョンです。ご協力いただきありがとうござい@MarcGlisse:

cmake_minimum_required(VERSION 3.5) 
project(AGRAN) 

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") 
find_package(CGAL REQUIRED) 
include(${CGAL_USE_FILE}) 

set(SOURCE_FILES main.cpp) 
add_executable(AGRAN ${SOURCE_FILES}) 
target_link_libraries(AGRAN ${CGAL_LIBS}) 
関連する問題