Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CMake on Linux: "target platform does not support dynamic linking"

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.

like image 971
Nico Schlömer Avatar asked Sep 04 '12 13:09

Nico Schlömer


1 Answers

PROJECT sets some important variables about the plarform.

Don't call FIND_* modules before setting a name to PROJECT.

like image 58
ElusiveMan Avatar answered Sep 17 '22 03:09

ElusiveMan