Linux上的CMake:“目标平台不支持动态链接” [英] CMake on Linux: "target platform does not support dynamic linking"

查看:333
本文介绍了Linux上的CMake:“目标平台不支持动态链接”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有非常简单的 CMakeLists.txt

  CMAKE_MINIMUM_REQUIRED( 2.8版)
FIND_PACKAGE(需要VTK)
项目(测试CXX)

那真的什么也没做。软件包VTK可以在 /usr/lib/vtk-5.8/VTKConfig.cmake 下正确找到。该文件包含许多类型的语句

  ADD_LIBRARY(foobar SHARED IMPORTED)

表示共享库 libfoobar.so 需要在可执行文件中链接。



使用上述脚本创建Makefile之后,CMake会抱怨

 位于/usr/lib/vtk-5.8/VTKTargets.cmake:244(ADD_LIBRARY)的CMake警告(dev):
使用共享选项调用ADD_LIBRARY,但目标平台不支持
动态链接。而是建立一个STATIC库。这可能会导致
出现问题。
调用堆栈(最近的调用优先):
/usr/lib/vtk-5.8/VTKConfig.cmake:200(INCLUDE)
/usr/share/cmake-2.8/Modules/FindVTK .cmake:73(FIND_PACKAGE)
CMakeLists.txt:4(FIND_PACKAGE)
此警告适用于项目开发人员。使用-Wno-dev抑制它

此警告是什么意思以及如何处理? / p>

这是具有CMake 2.8.9的Linux系统。对于所有包含 ADD_LIBRARY(foobar SHARED IMPORTED)的软件包都会出现此错误消息,此处以VTK-5.8为例。

解决方案

当CMake全局属性 TARGET_SUPPORTS_SHARED_LIBS 设置为false并使用共享库时,会出现此错误消息。请参阅CMake源中的 Source / cmAddLibraryCommand.cxx 第100行。



除非您是



我怀疑这是最新版本CMake中的错误,还是您没有正确配置CMake。


I have the very simple CMakeLists.txt

CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
FIND_PACKAGE(VTK REQUIRED)
PROJECT(test CXX)

that really doesn't do anything. The package VTK is correctly found under /usr/lib/vtk-5.8/VTKConfig.cmake. This file includes a number of statements of the type

ADD_LIBRARY(foobar SHARED IMPORTED)

to indicate that the shared library libfoobar.so will need to be linked in executables.

Upon creating Makefiles using the above script, however, CMake will complain that

CMake Warning (dev) at /usr/lib/vtk-5.8/VTKTargets.cmake:244 (ADD_LIBRARY):
  ADD_LIBRARY called with SHARED option but the target platform does not
  support dynamic linking.  Building a STATIC library instead.  This may lead
  to problems.
Call Stack (most recent call first):
  /usr/lib/vtk-5.8/VTKConfig.cmake:200 (INCLUDE)
  /usr/share/cmake-2.8/Modules/FindVTK.cmake:73 (FIND_PACKAGE)
  CMakeLists.txt:4 (FIND_PACKAGE)
This warning is for project developers.  Use -Wno-dev to suppress it

What does this warning mean and how is it dealt with?

This is a Linux system with CMake 2.8.9. While this error message appears for all packages that contain ADD_LIBRARY(foobar SHARED IMPORTED), VTK-5.8 is used as an example here.

解决方案

This error message occurs when the CMake global property TARGET_SUPPORTS_SHARED_LIBS is set false and you use a shared library. See Source/cmAddLibraryCommand.cxx line 100 in the CMake source.

This shouldn't normally occur unless you are cross compiling for a very basic system (embedded OS).

I suspect that either this is a bug in the latest version of CMake or you have not configured CMake correctly.

这篇关于Linux上的CMake:“目标平台不支持动态链接”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆