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

The output from CLion I get is as follows:

/Applications/ --build /Users/Matti/Library/Caches/CLion12/cmake/generated/cf7242d8/cf7242d8/Debug --target all -- VERBOSE=1
/Applications/ -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/ -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/ -f CMakeFiles/Makefile2 all
/Applications/ -f CMakeFiles/clion-buildfail.dir/build.make CMakeFiles/clion-buildfail.dir/depend
cd /Users/Matti/Library/Caches/CLion12/cmake/generated/cf7242d8/cf7242d8/Debug && /Applications/ -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/ -f CMakeFiles/clion-buildfail.dir/build.make CMakeFiles/clion-buildfail.dir/build
[ 50%] Building CXX object CMakeFiles/clion-buildfail.dir/main.cpp.o
/Applications/   -DQT_CORE_LIB -DQT_GUI_LIB -g -isysroot /Applications/ -iframework /Users/Matti/Qt/5.5/clang_64/lib -isystem /Users/Matti/Qt/5.5/clang_64/lib/QtGui.framework/Headers -isystem /Applications/ -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/ -E cmake_link_script CMakeFiles/clion-buildfail.dir/link.txt --verbose=1
/Applications/   -g -isysroot /Applications/ -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/ /Applications/ -Wl,-rpath,/Users/Matti/Qt/5.5/clang_64/lib
ld: can't map file, errno=22 file '/Applications/' 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.
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.

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.

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:


/usr/local/clion/bin/ $@
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.


Please sign in to leave a comment.