2017-07-01 22 views
0

私はv8のC++ライブラリを使ってプロジェクトを進めていましたが、私はこれをMakefileでコンパイルしましたが、CLionを使用していて、私はCMakeLists.txtファイルを使用しなければならなかった。cmakeを使ってv8ライブラリでC++プログラムをコンパイルする

私が持っている問題はcmakeのMakefileのが動作していることですが、ない...

は、ここでのMakefileです:

NAME \t = project 
 

 
SRC \t = src/main.cpp 
 

 
OBJ \t = $(SRC:.cpp=.o) 
 

 
CXXFLAGS = -Iv8/include -std=c++11 
 

 
LIBV8 = -Lv8/out/native/obj.target/third_party/icu/. -Lv8/out/native/obj.target/src/. -Wl,--start-group -lv8_base -lv8_libbase -lv8_external_snapshot -lv8_libplatform -lv8_libsampler -licuuc -licui18n -Wl,--end-group 
 

 
all: $(NAME) 
 

 
$(NAME): $(OBJ) 
 
\t g++ -pthread -lSDL2 $^ -o [email protected] $(CXXFLAGS) $(LIBV8) -lrt -ldl

そして、ここでは私が作ったCMakeのバージョンがあります:

cmake_minimum_required(VERSION 2.8.4) 
 
project(Project CXX) 
 

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

 
include_directories(${CMAKE_SOURCE_DIR}/v8/include) 
 
include_directories(/usr/include/SDL2) 
 

 
set(SDL2_LIBRARY /usr/lib/x86_64-linux-gnu/libSDL2.a) 
 

 
find_package(Threads) 
 

 
set(LIBV8 
 
     v8_base 
 
     v8_libbase 
 
     v8_external_snapshot 
 
     v8_libplatform 
 
     v8_libsampler 
 
     icuuc 
 
     icui18n 
 
     rt 
 
     dl 
 
     ) 
 
link_directories(
 
     ${CMAKE_SOURCE_DIR}/v8/out/native/obj.target/src/ 
 
     ${CMAKE_SOURCE_DIR}/v8/out/native/obj.target/third_party/icu/ 
 
     ${CMAKE_SOURCE_DIR}/v8/build/linux/debian_jessie_amd64-sysroot/usr/lib/x86_64-linux-gnu/ 
 
) 
 

 
file(GLOB_RECURSE SOURCES 
 
     ${CMAKE_SOURCE_DIR}/src/main.cpp 
 
     ) 
 

 
add_executable(project ${SOURCES}) 
 
target_link_libraries(project ${CMAKE_THREAD_LIBS_INIT} ${SDL2_LIBRARY} ${LIBV8})

私はすべての必要なライブラリを正しくリンクしていると思いますが、CMakeのバージョンでコンパイルすると、それらのエラーがたくさんあります(端末には多すぎますので、 "参照indéfinieVERS" "未定義の参照")を意味します

../third_party/icu/source/i18n/choicfmt.cpp:(.text._ZN6icu_5912ChoiceFormatC2EPKdPKaPKNS_13UnicodeStringEi+0x43): référence indéfinie vers « icu_59::MessagePattern::MessagePattern(UErrorCode&) » 
 
/home/xobtah/v8_Build/v8/out/native/obj.target/icui18n/third_party/icu/source/i18n/choicfmt.o: dans la fonction « icu_59::ChoiceFormat::ChoiceFormat(icu_59::ChoiceFormat const&) »: 
 
../third_party/icu/source/i18n/choicfmt.cpp:(.text._ZN6icu_5912ChoiceFormatC2ERKS0_+0x3f): référence indéfinie vers « icu_59::MessagePattern::MessagePattern(icu_59::MessagePattern const&) » 
 
/home/xobtah/v8_Build/v8/out/native/obj.target/icui18n/third_party/icu/source/i18n/choicfmt.o: dans la fonction « icu_59::ChoiceFormat::ChoiceFormat(icu_59::UnicodeString const&, UParseError&, UErrorCode&) »: 
 
../third_party/icu/source/i18n/choicfmt.cpp:(.text._ZN6icu_5912ChoiceFormatC2ERKNS_13UnicodeStringER11UParseErrorR10UErrorCode+0x35): référence indéfinie vers « icu_59::MessagePattern::MessagePattern(UErrorCode&) » 
 
/home/xobtah/v8_Build/v8/out/native/obj.target/icui18n/third_party/icu/source/i18n/choicfmt.o: dans la fonction « icu_59::ChoiceFormat::operator==(icu_59::Format const&) const »: 
 
../third_party/icu/source/i18n/choicfmt.cpp:(.text._ZNK6icu_5912ChoiceFormateqERKNS_6FormatE+0x3a): référence indéfinie vers « icu_59::MessagePattern::operator==(icu_59::MessagePattern const&) const » 
 
/home/xobtah/v8_Build/v8/out/native/obj.target/icui18n/third_party/icu/source/i18n/choicfmt.o: dans la fonction « icu_59::ChoiceFormat::operator=(icu_59::ChoiceFormat const&) »: 
 
../third_party/icu/source/i18n/choicfmt.cpp:(.text._ZN6icu_5912ChoiceFormataSERKS0_+0x39): référence indéfinie vers « icu_59::MessagePattern::operator=(icu_59::MessagePattern const&) » 
 
/home/xobtah/v8_Build/v8/out/native/obj.target/icui18n/third_party/icu/source/i18n/choicfmt.o: dans la fonction « icu_59::ChoiceFormat::~ChoiceFormat() »: 
 
../third_party/icu/source/i18n/choicfmt.cpp:(.text._ZN6icu_5912ChoiceFormatD2Ev+0x13): référence indéfinie vers « icu_59::MessagePattern::~MessagePattern() » 
 
/home/xobtah/v8_Build/v8/out/native/obj.target/icui18n/third_party/icu/source/i18n/choicfmt.o: dans la fonction « icu_59::ChoiceFormat::~ChoiceFormat() »: 
 
../third_party/icu/source/i18n/choicfmt.cpp:(.text._ZN6icu_5912ChoiceFormatD0Ev+0x13): référence indéfinie vers « icu_59::MessagePattern::~MessagePattern() » 
 
/home/xobtah/v8_Build/v8/out/native/obj.target/icui18n/third_party/icu/source/i18n/choicfmt.o: dans la fonction « icu_59::ChoiceFormat::applyPattern(icu_59::UnicodeString const&, UErrorCode&) »: 
 
../third_party/icu/source/i18n/choicfmt.cpp:(.text._ZN6icu_5912ChoiceFormat12applyPatternERKNS_13UnicodeStringER10UErrorCode+0x17): référence indéfinie vers « icu_59::MessagePattern::parseChoiceStyle(icu_59::UnicodeString const&, UParseError*, UErrorCode&) » 
 
/home/xobtah/v8_Build/v8/out/native/obj.target/icui18n/third_party/icu/source/i18n/choicfmt.o: dans la fonction « icu_59::ChoiceFormat::applyPattern(icu_59::UnicodeString const&, UParseError&, UErrorCode&) »: 
 
../third_party/icu/source/i18n/choicfmt.cpp:(.text._ZN6icu_5912ChoiceFormat12applyPatternERKNS_13UnicodeStringER11UParseErrorR10UErrorCode+0x12): référence indéfinie vers « icu_59::MessagePattern::parseChoiceStyle(icu_59::UnicodeString const&, UParseError*, UErrorCode&) » 
 
/home/xobtah/v8_Build/v8/out/native/obj.target/icui18n/third_party/icu/source/i18n/choicfmt.o: dans la fonction « icu_59::ChoiceFormat::format(double, icu_59::UnicodeString&, icu_59::FieldPosition&) const »: 
 
../third_party/icu/source/i18n/choicfmt.cpp:(.text._ZNK6icu_5912ChoiceFormat6formatEdRNS_13UnicodeStringERNS_13FieldPositionE+0x8e): référence indéfinie vers « icu_59::MessagePattern::getNumericValue(icu_59::MessagePattern::Part const&) const » 
 
../third_party/icu/source/i18n/choicfmt.cpp:(.text._ZNK6icu_5912ChoiceFormat6formatEdRNS_13UnicodeStringERNS_13FieldPositionE+0x144): référence indéfinie vers « icu_59::MessageImpl::appendSubMessageWithoutSkipSyntax(icu_59::MessagePattern const&, int, icu_59::UnicodeString&) » 
 
/home/xobtah/v8_Build/v8/out/native/obj.target/icui18n/third_party/icu/source/i18n/choicfmt.o: dans la fonction « icu_59::ChoiceFormat::findSubMessage(icu_59::MessagePattern const&, int, double) »: 
 
../third_party/icu/source/i18n/choicfmt.cpp:(.text._ZN6icu_5912ChoiceFormat14findSubMessageERKNS_14MessagePatternEid+0x6e): référence indéfinie vers « icu_59::MessagePattern::getNumericValue(icu_59::MessagePattern::Part const&) const » 
 
/home/xobtah/v8_Build/v8/out/native/obj.target/icui18n/third_party/icu/source/i18n/choicfmt.o: dans la fonction « icu_59::ChoiceFormat::parseArgument(icu_59::MessagePattern const&, int, icu_59::UnicodeString const&, icu_59::ParsePosition&) »: 
 
../third_party/icu/source/i18n/choicfmt.cpp:(.text._ZN6icu_5912ChoiceFormat13parseArgumentERKNS_14MessagePatternEiRKNS_13UnicodeStringERNS_13ParsePositionE+0x5d): référence indéfinie vers « icu_59::MessagePattern::getNumericValue(icu_59::MessagePattern::Part const&) const » 
 
/home/xobtah/v8_Build/v8/out/native/obj.target/icui18n/third_party/icu/source/i18n/choicfmt.o: dans la fonction « icu_59::ChoiceFormat::clone() const »: 
 
../third_party/icu/source/i18n/choicfmt.cpp:(.text._ZNK6icu_5912ChoiceFormat5cloneEv+0x4d): référence indéfinie vers « icu_59::MessagePattern::MessagePattern(icu_59::MessagePattern const&) » 
 
collect2: error: ld returned 1 exit status 
 
CMakeFiles/project.dir/build.make:95: recipe for target 'project' failed 
 
make[2]: *** [project] Error 1 
 
CMakeFiles/Makefile2:67: recipe for target 'CMakeFiles/project.dir/all' failed 
 
make[1]: *** [CMakeFiles/project.dir/all] Error 2 
 
Makefile:83: recipe for target 'all' failed 
 
make: *** [all] Error 2

は、私はそれを感謝し、ご静聴ありがとうございました!

EDIT: [ 50%] Linking CXX executable project /opt/cmake-3.7.1-Linux-x86_64/bin/cmake -E cmake_link_script CMakeFiles/project.dir/link.txt --verbose=1 /usr/bin/c++ -std=c++11 CMakeFiles/project.dir/src/main.cpp.o -o project -L/home/xobtah/Project/v8/out/native/obj.target/src -L/home/xobtah/Project/v8/out/native/obj.target/third_party/icu -L/home/xobtah/Project/v8/build/linux/debian_jessie_amd64-sysroot/usr/lib/x86_64-linux-gnu -Wl,-rpath,/home/xobtah/Project/v8/out/native/obj.target/src:/home/xobtah/Project/v8/out/native/obj.target/third_party/icu:/home/xobtah/Project/v8/build/linux/debian_jessie_amd64-sysroot/usr/lib/x86_64-linux-gnu -rdynamic -lpthread -Wl,-Bstatic -lSDL2 -Wl,-Bdynamic -lv8_base -lv8_libbase -lv8_external_snapshot -lv8_libplatform -lv8_libsampler -licuuc -licui18n -lrt -ldl

+0

正確なリンカーコマンドラインを見るには、 'make VERBOSE = 1'を試してみてください。 – arrowd

+0

あなたの答えをありがとう、リンカーの行を追加するために私の投稿を編集しました – Xobtah

答えて

1

をあなたのtarget_link_libraries()で実際のV8ライブラリ周り-Wl,--start-group-Wl,--end-groupが必要になる場合があります。VERBOSE = 1がリンクすることを可能にします。

あなたの目的がMakefileを複製することであれば、Makefile "LIBV8"のライブラリはあなたのCMake "LIBV8"のライブラリと同じではありません。

+1

ライブラリのセットの前後に-Wl、 - start-groupと-Wl、end-groupを追加していただきありがとうございます。 SDL2ライブラリにも問題がありましたが、これで解決しました。https://brendanwhitfield.wordpress.com/2015/02/26/using-cmake-with-sdl2/ – Xobtah

関連する問題