CLion 1.2 unable to build a simple Qt 5 project on OS X 10.11

This might be a bug in CLion or just something that only fails on my system for some mysterious reason.
In any case, I'd appreciate if someone else with similar configuration could clone the project I created on
Github and confirm/refute that it fails to build. The repository is located at https://github.com/karvaporo/clion-buildfail.git

The output from CLion I get is as follows:

/Applications/CLion.app/Contents/bin/cmake/bin/cmake --build /Users/Matti/Library/Caches/CLion12/cmake/generated/cf7242d8/cf7242d8/Debug --target all -- VERBOSE=1
/Applications/CLion.app/Contents/bin/cmake/bin/cmake -H/Users/Matti/ClionProjects/clion-buildfail -B/Users/Matti/Library/Caches/CLion12/cmake/generated/cf7242d8/cf7242d8/Debug --check-build-system CMakeFiles/Makefile.cmake 0
/Applications/CLion.app/Contents/bin/cmake/bin/cmake -E cmake_progress_start /Users/Matti/Library/Caches/CLion12/cmake/generated/cf7242d8/cf7242d8/Debug/CMakeFiles /Users/Matti/Library/Caches/CLion12/cmake/generated/cf7242d8/cf7242d8/Debug/CMakeFiles/progress.marks
/Applications/Xcode.app/Contents/Developer/usr/bin/make -f CMakeFiles/Makefile2 all
/Applications/Xcode.app/Contents/Developer/usr/bin/make -f CMakeFiles/clion-buildfail.dir/build.make CMakeFiles/clion-buildfail.dir/depend
cd /Users/Matti/Library/Caches/CLion12/cmake/generated/cf7242d8/cf7242d8/Debug && /Applications/CLion.app/Contents/bin/cmake/bin/cmake -E cmake_depends "Unix Makefiles" /Users/Matti/ClionProjects/clion-buildfail /Users/Matti/ClionProjects/clion-buildfail /Users/Matti/Library/Caches/CLion12/cmake/generated/cf7242d8/cf7242d8/Debug /Users/Matti/Library/Caches/CLion12/cmake/generated/cf7242d8/cf7242d8/Debug /Users/Matti/Library/Caches/CLion12/cmake/generated/cf7242d8/cf7242d8/Debug/CMakeFiles/clion-buildfail.dir/DependInfo.cmake --color=
/Applications/Xcode.app/Contents/Developer/usr/bin/make -f CMakeFiles/clion-buildfail.dir/build.make CMakeFiles/clion-buildfail.dir/build
[ 50%] Building CXX object CMakeFiles/clion-buildfail.dir/main.cpp.o
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++   -DQT_CORE_LIB -DQT_GUI_LIB -g -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk -iframework /Users/Matti/Qt/5.5/clang_64/lib -isystem /Users/Matti/Qt/5.5/clang_64/lib/QtGui.framework/Headers -isystem /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/System/Library/Frameworks/OpenGL.framework/Headers -isystem /Users/Matti/Qt/5.5/clang_64/lib/QtCore.framework/Headers -isystem /Users/Matti/Qt/5.5/clang_64/./mkspecs/macx-clang    -fPIC -o CMakeFiles/clion-buildfail.dir/main.cpp.o -c /Users/Matti/ClionProjects/clion-buildfail/main.cpp
[100%] Linking CXX executable clion-buildfail
/Applications/CLion.app/Contents/bin/cmake/bin/cmake -E cmake_link_script CMakeFiles/clion-buildfail.dir/link.txt --verbose=1
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++   -g -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk -Wl,-search_paths_first -Wl,-headerpad_max_install_names  CMakeFiles/clion-buildfail.dir/main.cpp.o  -o clion-buildfail  /Users/Matti/Qt/5.5/clang_64/lib/QtGui.framework/QtGui /Users/Matti/Qt/5.5/clang_64/lib/QtCore.framework/QtCore /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/System/Library/Frameworks/OpenGL.framework /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/System/Library/Frameworks/AGL.framework -Wl,-rpath,/Users/Matti/Qt/5.5/clang_64/lib
ld: can't map file, errno=22 file '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/System/Library/Frameworks/OpenGL.framework' for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [clion-buildfail] Error 1
make[1]: *** [CMakeFiles/clion-buildfail.dir/all] Error 2
make: *** [all] Error 2


When I run CMake on command line, it doesn't try to link against OpenGL.framework or AGL.framework; this only happens in CLion.
4 comments
Comment actions Permalink

Did you ever get this figured out?

One thing I'd try is cleaning up your build environment in clion.  Sometimes it gets stuck with bad cmake configurations and the only thing you can do is delete the generated build files.  It happens enough that clion now has an Invalidate/Reset menu item to do it for you.

If not I can try and build this on my mac for you but I don't use clion on osx, just linux.  I can test it on the command line though to see if it works.  If it builds on command line it should build in clion (assuming the above cleared out cache).

If not, the next step is to figure out what tools/utils that clion is using to build that you are not using on the cli.

0
Comment actions Permalink

I filed a bug report about this, and it turns out that CLion doesn't interpret shell variables, so one can't just add to the default PATH like this: PATH=$PATH:/path/to/somewhere

Once I had set the system environment correctly, everything compiled as expected. Thanks for taking the time to help, and sorry for not providing my findings earlier.

0
Comment actions Permalink

Weird, I have the opposite problem.  Clion picks up my shell variables so I need a custom script (see below) to change them before I start clion.

I actually use a shell script to start my clion in linux as I need to modify some shell variables.

You could do something similar on your mac if you wanted.  Here is my script.  Mainly I need to unset my Qt logging stuff that I use in KDE to prevent excessive logging but when developing I of course want to see all the qDebug() stuff.  Here is my script if that's at all helpful for you:

#!/bin/bash 

unset QT_LOGGING_RULES
QTDIR="/usr/local/Qt"
PATH="/usr/local/Qt/bin:$PATH:/usr/local/bin"
export PATH QTDIR
/usr/local/clion/bin/clion.sh $@
0
Comment actions Permalink

I have the same behavior in the OS X version. CLion pulls in the environment variables from my .bash_profile and, in that setting, the environment variables are evaluated properly; most likely because they are evaluated by the shell at startup.

The problem I had, stemmed from not having QTDIR etc. set in .bash_profile, but passing them in CMake options (Preferences -> Build, Execution, Deployment -> CMake) and including shell variables that weren't already evaluated.

That CMake preference pane is a bit weird, though. It is never there, when I open the preferences window, but the UI contains a special "CMake Settings" button that opens it for me. Not sure whether this is some kind of a subtle feature or a bug.

0

Please sign in to leave a comment.