在编译Mac机器上的Swift时,创建了一个动态库libswiftDemangle.dylib。我也需要在Linux机器上创建动态库,但是,动态库不是在编译源代码之后创建的。
位于CMakeLists.txt的lib/SwiftDemangle/CMakeLists.txt文件包含:
add_swift_library(swiftDemangle SHARED
SwiftDemangle.cpp
MangleHack.cpp
LINK_LIBRARIES swiftBasic)指令,但是没有创建库。
我使用这个命令./swift/utils/build-script -R -c --build-subdir build --install-prefix /mnt/servers/swift/install -j4来构建项目,最终它运行cmake和ninja来构建项目。
有什么想法吗?
发布于 2017-01-07 13:40:30
我可以尝试解释为什么库没有构建在Linux上,即使很晚了。
包含您提到的库的主子目录是:
https://github.com/apple/swift/tree/master/lib要构建该目录中的库(组织在子目录中),需要使用以下CMakeLists.txt:
https://github.com/apple/swift/blob/master/lib/CMakeLists.txt。
在这个文件中可以清楚地看到,您提到的库仅在系统为OSX/达尔文而不是在Linux情况下构建。上述CMakeLists.txt中的相关代码是:
add_subdirectory(RemoteAST)
add_subdirectory(Sema)
add_subdirectory(Serialization)
if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
add_subdirectory(SwiftDemangle)
endif()
add_subdirectory(SIL)
add_subdirectory(SILGen) 如你所见,
if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
add_subdirectory(SwiftDemangle)
endif()防止在Linux上构建SwiftDemangle。
一种肤浅的双重检查可以是看:
https://github.com/apple/swift/blob/master/lib/SwiftDemangle/CMakeLists.txt它只安装或只安装*.dylib文件。
值得一提的是,swift-demangle工具(不同于您所要求的)
https://github.com/apple/swift/tree/master/tools/swift-demangle构建在Linux上。
https://stackoverflow.com/questions/37541331
复制相似问题