成功构建iOS后没有libclang.a?

时间:2015-10-26 04:51:21

标签: c++ clang llvm

我已经为3.7版本提取了官方llvm / clang来源,做了一些小修补(cmake ../llvm_37_ios \ -DCMAKE_INSTALL_PREFIX=/Volumes/Transcend/dev/src/llvm_37_ios_armv7_installed \ -DLLVM_ENABLE_TERMINFO=OFF \ -DLLVM_ENABLE_THREADS=OFF \ -DCMAKE_OSX_SYSROOT=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk \ -DCMAKE_C_FLAGS="-stdlib=libc++ -arch armv7 -mios-version-min=8.0 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk" \ -DCMAKE_CXX_FLAGS="-stdlib=libc++ -arch armv7 -mios-version-min=8.0 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk" \ -DCMAKE_CROSSCOMPILING=True \ -DLLVM_TABLEGEN=/Volumes/Transcend/dev/src/llvm_37_local_build/bin/llvm-tblgen \ -DCLANG_TABLEGEN=/Volumes/Transcend/dev/src/llvm_37_local_build/bin/clang-tblgen \ -DCMAKE_BUILD_TYPE=Release \ -DLLVM_TARGETS_TO_BUILD="ARM;X86" ),使用cmake为iOS配置和构建:

libclang.a

但是我找不到libclang*.a但找到了另一个MBA-Anton:llvm_37_ios_armv7_build asmirnov$ find . -name "libclang.a" MBA-Anton:llvm_37_ios_armv7_build asmirnov$ find . -name "libclang*.a" ./lib/libclangBasic.a ./lib/libclangLex.a ./lib/libclangASTMatchers.a ./lib/libclangParse.a ./lib/libclangDynamicASTMatchers.a ./lib/libclangAnalysis.a ./lib/libclangEdit.a ./lib/libclangRewrite.a ./lib/libclangAST.a ./lib/libclangDriver.a ./lib/libclangCodeGen.a ./lib/libclangSerialization.a ./lib/libclangRewriteFrontend.a ./lib/libclangSema.a ./lib/libclangFrontendTool.a ./lib/libclangARCMigrate.a ./lib/libclangToolingCore.a ./lib/libclangFrontend.a ./lib/libclangIndex.a ./lib/libclangTooling.a ./lib/libclangFormat.a ./lib/libclangStaticAnalyzerFrontend.a ./lib/libclangStaticAnalyzerCore.a ./lib/libclangStaticAnalyzerCheckers.a 库:

Linking CXX executable ../../../../bin/clang
[ 98%] Building CXX object tools/clang/tools/libclang/CMakeFiles/libclang.dir/CIndexDiagnostic.cpp.o
[ 98%] Building CXX object tools/clang/tools/libclang/CMakeFiles/libclang.dir/CIndexHigh.cpp.o
[ 98%] Built target clang
[ 98%] Building CXX object tools/clang/tools/libclang/CMakeFiles/libclang.dir/CIndexInclusionStack.cpp.o
[ 98%] Building CXX object tools/clang/tools/libclang/CMakeFiles/libclang.dir/CIndexUSRs.cpp.o
[ 98%] Building CXX object tools/clang/tools/libclang/CMakeFiles/libclang.dir/CIndexer.cpp.o
[ 98%] Building CXX object tools/clang/tools/libclang/CMakeFiles/libclang.dir/CXComment.cpp.o
[ 98%] Building CXX object tools/clang/tools/libclang/CMakeFiles/libclang.dir/CXCursor.cpp.o
[ 98%] Building CXX object tools/clang/tools/libclang/CMakeFiles/libclang.dir/CXCompilationDatabase.cpp.o
[ 98%] Building CXX object tools/clang/tools/libclang/CMakeFiles/libclang.dir/CXLoadedDiagnostic.cpp.o
[100%] Building CXX object tools/clang/tools/libclang/CMakeFiles/libclang.dir/CXSourceLocation.cpp.o
[100%] Building CXX object tools/clang/tools/libclang/CMakeFiles/libclang.dir/CXStoredDiagnostic.cpp.o
[100%] Building CXX object tools/clang/tools/libclang/CMakeFiles/libclang.dir/CXString.cpp.o
[100%] Building CXX object tools/clang/tools/libclang/CMakeFiles/libclang.dir/CXType.cpp.o
[100%] Building CXX object tools/clang/tools/libclang/CMakeFiles/libclang.dir/IndexBody.cpp.o
[100%] Building CXX object tools/clang/tools/libclang/CMakeFiles/libclang.dir/IndexDecl.cpp.o
[100%] Building CXX object tools/clang/tools/libclang/CMakeFiles/libclang.dir/IndexTypeSourceInfo.cpp.o
[100%] Building CXX object tools/clang/tools/libclang/CMakeFiles/libclang.dir/Indexing.cpp.o
[100%] Building CXX object tools/clang/tools/libclang/CMakeFiles/libclang.dir/IndexingContext.cpp.o
Linking CXX shared library ../../../../lib/libclang.dylib
[100%] Built target libclang

由于某种原因,共享库已创建但静态不是:

UITableViewController

我是否错过了某些内容或它的铿锵配置错误?

1 个答案:

答案 0 :(得分:5)

libclang默认构建为共享库,因为它使用FFI或类似机制简化了其他语言(如Python)的使用。

要构建静态库,请使用LIBCLANG_BUILD_STATIC中定义的clang/tools/libclang/CMakeLists.txt CMake选项:

option(LIBCLANG_BUILD_STATIC
  "Build libclang as a static library (in addition to a shared one)" OFF)

您可以按如下方式使用它:

cmake -DLIBCLANG_BUILD_STATIC=ON ...