2015-07-03 33 views
3

所以我有一個使用CGAL,並建有CMake的一個相當簡單的C++程序。我可以建立並沒有emscripten成功運行:使用emscripten通過CMake在一個簡單的(?)項目

cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo -G "Unix Makefiles" . 
[output looks good] 
make 
[command works] 

凡事都有不錯,我可以運行輸出,然而,當我嘗試使用Emscripten這樣的(這爲我在過去的工作)

cmake -DCMAKE_TOOLCHAIN_FILE=/home/brenden/emsdk_portable/emscripten/master/cmake/Modules/Platform/Emscripten.cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo -G "Unix Makefiles" . 
[output looks good] 
make 
main.cpp:2:10: fatal error: 'CGAL/Triangulation_3.h' file not found 
#include <CGAL/Triangulation_3.h> 
     ^
1 error generated. 
ERROR root: compiler frontend failed to generate LLVM bitcode, halting 
make[2]: *** [CMakeFiles/cgal_test.dir/main.cpp.o] Error 1 
make[1]: *** [CMakeFiles/cgal_test.dir/all] Error 2 
make: *** [all] Error 2 

這顯然是行不通的。

我的CMakeLists.txt看起來是這樣的:

cmake_minimum_required(VERSION 2.8) 
project(cgal_test) 
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") 
set(SOURCE_FILES main.cpp) 
add_executable(cgal_test ${SOURCE_FILES}) 
target_link_libraries(cgal_test CGAL gmp) 

任何想法?所有的CGAL庫和頭文件都在usr/local /中,所以我對於發生了什麼事情感到不知所措。

+0

嗯,我可以使用G ++的main.cpp -o主要-lgmp -lCGAL但我不能做EM ++的main.cpp -o主要-lgmp -lCGAL – Brenden

回答

2

嗯,所以事實證明,你不能只是鏈接到一個庫中,emscripten docs指出你「...建立庫到位碼,然後編譯庫和主程序位碼一起到JavaScript。」

聽起來很愚蠢和痛苦,但我想這就是答案。

+1

這是有道理的。您的目標是嵌入式環境,它具有自己的「機器代碼」,因此您必須交叉編譯任何庫並使用靜態鏈接,因爲它在瀏覽器中無法使用JavaScript。 –

+1

是啊,以供將來參考(如果有人關心)有試圖打包CGAL了在emscripten友好的方式,這個項目的GitHub https://github.com/marcosscriven/cgaljs – Brenden

相關問題