MantisBT - CMake
View Issue Details
0013765CMakeCMakepublic2012-11-30 15:022013-07-01 09:38
Jean-Christophe Fillion-Robin 
Brad King 
highmajoralways
closedfixed 
CMake 2.8.10.2 
CMake 2.8.11CMake 2.8.11 
0013765: Failed to link against framework in /Library/Framework when CMAKE_OSX_* variables are set
Failed to link against framework in /Library/Framework when CMAKE_OS_* variables are set

The problem occurs when using:
  - CMake 2.8.10.2
  - mac OSX 10.8
  - XCode Version 4.5.2 (4G2008a)
  - g++ --version i686-apple-darwin11-llvm-g++-4.2 (GCC) 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2336.11.00)

After installing qt 4.7.4: ftp://ftp.qt.nokia.com/qt/source/qt-mac-opensource-4.7.4.dmg [^]

This small project allows to reproduce the problem.

$ git clone git://github.com/jcfr/CMakeWithQtFramework.git [^]
$ mkdir CMakeWithQtFramework-build
$ cd CMakeWithQtFramework-build
$ cmake ../
[…]

$ make VERBOSE=1
[…]
Linking CXX executable foo
"/Volumes/Dashboards/Support/CMake 2.8-10.app/Contents/bin/cmake" -E cmake_link_script CMakeFiles/foo.dir/link.txt --verbose=1
/usr/bin/c++ -arch x86_64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk -mmacosx-version-min=10.8 -Wl,-search_paths_first -Wl,-headerpad_max_install_names CMakeFiles/foo.dir/main.cpp.o -o foo -framework QtWebKit -framework QtXmlPatterns -framework QtGui -framework QtNetwork -framework QtCore
ld: framework not found QtWebKit
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [foo] Error 1
make[1]: *** [CMakeFiles/foo.dir/all] Error 2
make: *** [all] Error 2



By manually adding -F /Library/Frameworks to the build line, it succeed.

 /usr/bin/c++ -arch x86_64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk -mmacosx-version-min=10.8 -Wl,-search_paths_first -Wl,-headerpad_max_install_names CMakeFiles/foo.dir/main.cpp.o -o foo -framework QtWebKit -framework QtXmlPatterns -framework QtGui -framework QtNetwork -framework QtCore -F /Library/Frameworks/

I would assume that CMake should automatically add the "-F /Library/Frameworks/"
No tags attached.
Issue History
2012-11-30 15:02Jean-Christophe Fillion-RobinNew Issue
2012-11-30 15:18Brad KingNote Added: 0031786
2012-11-30 15:38Jean-Christophe Fillion-RobinNote Added: 0031789
2012-11-30 15:43Brad KingNote Added: 0031790
2012-11-30 15:53Jean-Christophe Fillion-RobinNote Added: 0031791
2012-12-03 09:22Brad KingNote Edited: 0031791bug_revision_view_page.php?bugnote_id=31791#r956
2012-12-03 09:23Brad KingTarget Version => CMake 2.8.11
2012-12-03 09:23Brad KingSummaryFailed to link against framework in /Library/Framework when CMAKE_OS_* variables are set => Failed to link against framework in /Library/Framework when CMAKE_OSX_* variables are set
2012-12-03 09:23Brad KingDescription Updatedbug_revision_view_page.php?rev_id=958#r958
2012-12-03 09:30Brad KingNote Added: 0031817
2012-12-03 17:52Jean-Christophe Fillion-RobinNote Added: 0031824
2012-12-03 17:53Jean-Christophe Fillion-RobinNote Edited: 0031824bug_revision_view_page.php?bugnote_id=31824#r960
2012-12-04 08:12Brad KingNote Added: 0031826
2012-12-05 12:12Jean-Christophe Fillion-RobinNote Edited: 0031824bug_revision_view_page.php?bugnote_id=31824#r967
2013-01-30 06:01Dimitri MerejkowskyNote Added: 0032177
2013-01-30 09:09Brad KingNote Added: 0032178
2013-01-30 09:09Brad KingAssigned To => Brad King
2013-01-30 09:09Brad KingStatusnew => resolved
2013-01-30 09:09Brad KingResolutionopen => fixed
2013-01-30 09:09Brad KingFixed in Version => CMake 2.8.11
2013-01-30 09:11Brad KingNote Added: 0032179
2013-02-15 12:01Jean-Christophe Fillion-RobinNote Added: 0032289
2013-02-15 12:01Jean-Christophe Fillion-RobinStatusresolved => feedback
2013-02-15 12:01Jean-Christophe Fillion-RobinResolutionfixed => reopened
2013-02-15 12:51Brad KingNote Added: 0032290
2013-02-15 13:35Jean-Christophe Fillion-RobinNote Added: 0032292
2013-02-15 13:35Jean-Christophe Fillion-RobinStatusfeedback => assigned
2013-02-15 13:37Steve PieperNote Added: 0032293
2013-02-15 13:42Jean-Christophe Fillion-RobinNote Added: 0032294
2013-02-15 13:47Steve PieperNote Added: 0032295
2013-02-15 14:01Jean-Christophe Fillion-RobinNote Added: 0032296
2013-02-15 14:10Steve PieperNote Added: 0032297
2013-02-15 15:25Greg SharpNote Added: 0032298
2013-02-17 11:41Jean-Christophe Fillion-RobinNote Added: 0032318
2013-02-18 08:25Brad KingNote Added: 0032322
2013-02-18 08:25Brad KingStatusassigned => resolved
2013-02-18 08:25Brad KingResolutionreopened => fixed
2013-02-25 11:37Jean-Christophe Fillion-RobinNote Added: 0032378
2013-02-25 11:37Jean-Christophe Fillion-RobinStatusresolved => feedback
2013-02-25 11:37Jean-Christophe Fillion-RobinResolutionfixed => reopened
2013-02-25 11:58Brad KingNote Added: 0032379
2013-02-25 11:58Brad KingStatusfeedback => resolved
2013-02-25 11:58Brad KingResolutionreopened => fixed
2013-07-01 09:38Robert MaynardNote Added: 0033434
2013-07-01 09:38Robert MaynardStatusresolved => closed

Notes
(0031786)
Brad King   
2012-11-30 15:18   
You're asking the build to use a given SDK but that SDK does not provide the frameworks you're using. On older Mac versions e.g. 10.6 the SDKs had a symlink to make /Library/Frameworks available. CMake needs to account for the lack of this symlink in newer versions.
(0031789)
Jean-Christophe Fillion-Robin   
2012-11-30 15:38   
As a workaround, to create the symlinks, should I use something like:

for file in `ls -1 /Library/Frameworks/`; do sudo ln -s /Library/Frameworks/$file /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/$file; done

.. or is there a simpler way ?
(0031790)
Brad King   
2012-11-30 15:43   
Re 0013765:0031789: I think adding "-F /Library/Frameworks" to CMAKE_EXE_LINKER_FLAGS, CMAKE_SHARED_LINKER_FLAGS, and CMAKE_MODULE_LINKER_FLAGS in your build tree is the simplest workaround. Don't hack your system files for this.
(0031791)
Jean-Christophe Fillion-Robin   
2012-11-30 15:53   
(edited on: 2012-12-03 09:22)
Since I would like to be able to build Slicer with superbuild VTK, CTK (superbuilding itself PythonQt, QTTesting ...) .. it gonna be a painful process to ensure the flag is properly added in all the project relying on Qt. I would have to patch all these projects ...

The time being, I think I will simply create the symlinks ...

(0031817)
Brad King   
2012-12-03 09:30   
Re 0013765:0031791: If you create the symlinks then you should do something like

 mkdir /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/Library
 ln -s /Library/Frameworks /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/Library/

instead. I think just that one link will be enough.
(0031824)
Jean-Christophe Fillion-Robin   
2012-12-03 17:52   
(edited on: 2012-12-05 12:12)
Just tried the single symlink approach and it wasn't successful.

Using this approach works:

cd /Library/Frameworks

for file in Qt*; do sudo ln -s /Library/Frameworks/$file /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.7.sdk/System/Library/Frameworks/$file; done

for file in Qt*; do sudo ln -s /Library/Frameworks/$file /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/$file; done

Also need to create link for phonon framework

(0031826)
Brad King   
2012-12-04 08:12   
Add "-Wl,-v" to the link line by hand to get verbose output about the framework search path in use.
(0032177)
Dimitri Merejkowsky   
2013-01-30 06:01   
Maybe related : when using the following file:

cmake_minimum_required(VERSION 2.8.10)
project(two_frameworks)

list(APPEND CMAKE_FRAMEWORK_PATH
    /Users/dmerejkowsky/.local/share/qi/toolchains/mac64/ogre/)


list(APPEND CMAKE_FRAMEWORK_PATH
  /Users/dmerejkowsky/.local/share/qi/toolchains/mac64/ogre/)


find_library(OGRE_LIBRARIES NAMES Ogre)
find_library(QT_LIBRARIES NAMES QtCore)

add_executable(foo foo.cpp)
target_link_libraries(foo ${OGRE_LIBRARIES} ${QT_LIBRARIES})


and building, you can see the generated command line looks like:

/usr/bin/c++ -Wl,-search_paths_first -Wl,-headerpad_max_install_names CMakeFiles/foo.dir/foo.cpp.o -o foo -F/Users/dmerejkowsky/.local/share/qi/toolchains/mac64/ogre -F/Users/dmerejkowsky/.local/share/qi/toolchains/mac64/qt -framework Ogre -framework QtCore


Note the lack of -F/Users/dmerejkowsky/.local/share/qi/toolchains/mac64/qt

The problem did not occur in CMake 2.8.9, and I can reproduce this with CMake 2.8.10
(0032178)
Brad King   
2013-01-30 09:09   
Oops, I forgot to update this issue when I fixed it here:

 http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=cc676c3a [^]
(0032179)
Brad King   
2013-01-30 09:11   
Other recent commits should fix the behavior described in 0013765:0032177:

 http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=ba58d0c0 [^]
 http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=f0d93854 [^]
 http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=2bc22bda [^]
(0032289)
Jean-Christophe Fillion-Robin   
2013-02-15 12:01   
From Steve Pieper - See http://na-mic.org/Bug/view.php?id=2954 [^]

On mac os 10.8 with xcode 4.6 and cmake version 2.8.10.20130215-g57833 (the latest next branch as of today).

Trying to build a module results in the following kind of error:

[ 5%] Building CXX object Logic/CMakeFiles/vtkSlicerNewModuleModuleLogic.dir/vtkSlicerNewModuleLogic.cxx.o
Linking CXX shared library ../lib/Slicer-4.2/qt-loadable-modules/libvtkSlicerNewModuleModuleLogic.dylib
ld: framework not found QtScript
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [lib/Slicer-4.2/qt-loadable-modules/libvtkSlicerNewModuleModuleLogic.dylib] Error 1
make[1]: *** [Logic/CMakeFiles/vtkSlicerNewModuleModuleLogic.dir/all] Error 2
make: *** [all] Error 2
(0032290)
Brad King   
2013-02-15 12:51   
Re 0013765:0032289: Can this be reproduced on a simple example project outside the Slicer superbuild?
(0032292)
Jean-Christophe Fillion-Robin   
2013-02-15 13:35   
Here is a project: https://github.com/jcfr/CMakeWithQtFramework [^]

@Steve, Daniel: Can you reproduce the problem using this toy project ?
(0032293)
Steve Pieper   
2013-02-15 13:37   
I had no problem building the simple example.

0000010 CMakeWithQtFramework-build (master>)$ cmake --version
cmake version 2.8.10.20130215-g57833

#11 CMakeWithQtFramework-build (master>)$ cmake ../CMakeWithQtFramework
-- Setting OSX_ARCHITECTURES to 'x86_64' as none was specified.
-- Setting OSX_DEPLOYMENT_TARGET to '10.8' as none was specified.
-- Setting OSX_SYSROOT to '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk' as none was specified.
-- The C compiler identification is Clang 4.0.0
-- The CXX compiler identification is Clang 4.0.0
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Looking for Q_WS_X11
-- Looking for Q_WS_X11 - not found
-- Looking for Q_WS_WIN
-- Looking for Q_WS_WIN - not found
-- Looking for Q_WS_QWS
-- Looking for Q_WS_QWS - not found
-- Looking for Q_WS_MAC
-- Looking for Q_WS_MAC - found
-- Looking for QT_MAC_USE_COCOA
-- Looking for QT_MAC_USE_COCOA - found
-- Found Qt4: /usr/bin/qmake (found version "4.8.3")
-- Configuring done
-- Generating done
-- Build files have been written to: /tmp/CMakeWithQtFramework-build

0000012 CMakeWithQtFramework-build (master %>)$ make
Scanning dependencies of target foo
[100%] Building CXX object CMakeFiles/foo.dir/main.cpp.o
Linking CXX executable foo
[100%] Built target foo
(0032294)
Jean-Christophe Fillion-Robin   
2013-02-15 13:42   
@Steve: Do you confirm that the QT_QMAKE_EXECUTABLE variable from the CMakeCache.txt points to Qt having Frameworks ? If it points to a Qt you built yourself, the problem wouldn't occur.
(0032295)
Steve Pieper   
2013-02-15 13:47   
Both slicer and the CMakeWithQtFramework are using /usr/bin/qmake, which is:

0000019 NewModule-build (master %>)$ qmake --version
QMake version 2.01a
Using Qt version 4.8.3 in /Library/Frameworks

0000020 NewModule-build (master %>)$ which qmake
/usr/bin/qmake
(0032296)
Jean-Christophe Fillion-Robin   
2013-02-15 14:01   
In that case, it seems to be specific to Slicer. Could you provide remote access to Brad ?
(0032297)
Steve Pieper   
2013-02-15 14:10   
I only have the issue with my laptop right now. Let me see if I can replicate it on a machine with a public IP where I can give him an account.

But I agree this is something specific to building slicer loadable modules.
(0032298)
Greg Sharp   
2013-02-15 15:25   
The cmake nightly solved this problem for me.

OSX 10.7
xcode 4.6 (4H127)
cmake-2.8.10.20130213-g7665b (built from source)

However, I had infinite loop instead, linked here in case it is related.

http://www.cmake.org/Bug/view.php?id=13926 [^]
(0032318)
Jean-Christophe Fillion-Robin   
2013-02-17 11:41   
@Greg: I did some experiment and CMake version "2.8.10.20130121-g92bd8" is known to work. See http://slicer-devel.65872.n3.nabble.com/How-to-build-Slicer-on-10-8-tp4027602p4027604.html [^]

On the other hand, I was able to reproduce the hang using version "cmake-2.8.10.20130215-g4c900".

I suggest we close this issue.
(0032322)
Brad King   
2013-02-18 08:25   
Re 0013765:0032318: Okay, this issue is fixed and 0013926 records a separate remaining issue.
(0032378)
Jean-Christophe Fillion-Robin   
2013-02-25 11:37   
While it is possible to build Slicer without any trouble. There is issue to build Slicer extensions against Slicer build tree.

The experiment has been documented here: http://na-mic.org/Mantis/view.php?id=2954#c8038 [^]

If needed, I could:
 1) Provide access to the machine with a build tree
 2) Provide the complete link command
(0032379)
Brad King   
2013-02-25 11:58   
This issue is resolved AFAICT. Please do not re-open it unless you have a minimal example project that reproduces it on more than one computer. Keep the discussion over in Slicer's issue until you've identified that it is really a CMake problem and narrowed it down to a minimal example. The details of narrowing the case from Slicer's build process to a small example are not of interest to this issue.
(0033434)
Robert Maynard   
2013-07-01 09:38   
Closing resolved issues that have not been updated in more than 4 months.