静态可执行文件“cmake bad ELF interpreter:没有这样的文件或目录”

时间:2014-08-01 17:09:10

标签: c++ linker makefile cmake ld

所以我试图将https://github.com/apngasm/apngasm(checkout url:https://github.com/apngasm/apngasm.git)编译为静态可执行文件,以便在其他系统上进行部署。

然而,我遇到了与cmake陷入困境。

我将以下内容添加到cli / CMakeLists.txt

SET(Boost_USE_STATIC_LIBS ON)
SET(CMAKE_FIND_LIBRARY_SUFFIXES ".a")
SET(BUILD_SHARED_LIBRARIES OFF)
set(CMAKE_EXE_LINKER_FLAGS "-static-libgcc -static-libstdc++ -static")

然后将以下内容发送到lib / CmakeLists.txt

SET(Boost_USE_STATIC_LIBS ON)
SET(CMAKE_FIND_LIBRARY_SUFFIXES ".a;.so")
SET(BUILD_SHARED_LIBRARIES OFF)
set(CMAKE_EXE_LINKER_FLAGS "-static-libgcc -static-libstdc++ -static")

并从

中的lib / CmakeLists.txt更改了以下行
ADD_LIBRARY(apngasm SHARED
  ${PROJECT_SOURCE_DIR}/src/apngasm.cpp
  ${PROJECT_SOURCE_DIR}/src/apngframe.cpp
  ${PROJECT_SOURCE_DIR}/src/spec/specreader.cpp
  ${PROJECT_SOURCE_DIR}/src/spec/specwriter.cpp
  ${PROJECT_SOURCE_DIR}/src/spec/priv/specreaderimpl.cpp
  ${PROJECT_SOURCE_DIR}/src/spec/priv/specwriterimpl.cpp
  ${PROJECT_SOURCE_DIR}/src/listener/apngasmlistener.cpp
)

ADD_LIBRARY(apngasm STATIC
  ${PROJECT_SOURCE_DIR}/src/apngasm.cpp
  ${PROJECT_SOURCE_DIR}/src/apngframe.cpp
  ${PROJECT_SOURCE_DIR}/src/spec/specreader.cpp
  ${PROJECT_SOURCE_DIR}/src/spec/specwriter.cpp
  ${PROJECT_SOURCE_DIR}/src/spec/priv/specreaderimpl.cpp
  ${PROJECT_SOURCE_DIR}/src/spec/priv/specwriterimpl.cpp
  ${PROJECT_SOURCE_DIR}/src/listener/apngasmlistener.cpp
)

它编译,但当我将可执行文件传输到目标系统时,它说:

bash: ./apngasm: /lib/ld64.so.1: bad ELF interpreter: No such file or directory

0 个答案:

没有答案