CMake with clang shows undefined symbol, and with cl links correctly - c++

TLDR
Im building a static library and linking it to an executable. Im generating makefiles with cmake. When I generate the makefile for cl (The compiler from visual studio) I have no problems, but when I generate the makefile for clang I get an undefined symbol.
Versions:
cmake version 3.18.1
clang version 11.0.0
Target: x86_64-pc-windows-msvc
Thread model: posix
cl version 19.26.28806 for x64
Minimal Example
I have the following structure for the proyect:
Proyect Root
│ CMakeLists.txt
│ foo.cpp
│ foo.hpp
│ main.cpp
│
└───bin
And this are the contents of the files:
foo.hpp
namespace foo {
void do_stuff(void);
}
foo.cpp
#include <foo.hpp>
namespace foo {
void do_stuff(void) {}
}
main.cpp
#include <foo.hpp>
int main(void) {
foo::do_stuff();
return 0;
}
And CMakeLists.txt
cmake_minimum_required(VERSION 3.0.0)
project(CompileAndLinkLib)
include_directories(".")
file(GLOB FOO_SRC "foo.cpp")
add_library(foo STATIC ${FOO_SRC})
add_executable(main "main.cpp")
target_link_libraries(main foo)
Correct linking
First I call vcvarsall.bat. I generate a nmake file with the following command:
cmake .. -G "NMake Makefiles"
And compile with:
nmake
The project compiles and links correctly
The undefined symbol
I generate the make file with the following command:
cmake .. -G "Unix Makefiles" -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++
And when I compile with make I get the following output:
Scanning dependencies of target foo
[ 25%] Building CXX object CMakeFiles/foo.dir/foo.cpp.obj
[ 50%] Linking CXX static library foo.lib
[ 50%] Built target foo
Scanning dependencies of target main
[ 75%] Building CXX object CMakeFiles/main.dir/main.cpp.obj
[100%] Linking CXX executable main.exe
lld-link: error: undefined symbol: void __cdecl foo::do_stuff(void)
>>> referenced by C:\Users\pabsa\temp\main.cpp:4
>>> CMakeFiles/main.dir/main.cpp.obj:(main)
clang++: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [main.exe] Error 1
make[1]: *** [CMakeFiles/main.dir/all] Error 2
make: *** [all] Error 2
Im not sure if im doing something wrong, like if im missing something, or if this is an error with the makefile generated by cmake.

I just had the same problem, but with Clang 13. It could be solved with specifying clang as compiler in the CMakeLists, instead of letting CMake determine it automatically.
set(CMAKE_CXX_COMPILER "clang++")
(And yes, I read your original question correct, using this:
-DCMAKE_CXX_COMPILER=clang++
as an additional argument for cmake did not work for me as well, even if it looks like it should behave the same as setting it in CMakeLists.txt)

I tested again with:
clang version 12.0.0
Target: x86_64-pc-windows-msvc
Thread model: posix
And it worked corretly. Seems like it was a problem with clang 11

You're overcomplicating things imo. What about just "cmake .. -T ClangCL && cmake --build ."? Builds fine for me:
C:\Users\vital\test\_build>cmake .. -T ClangCL
-- Building for: Visual Studio 17 2022
-- Selecting Windows SDK version 10.0.20348.0 to target Windows 10.0.22000.
-- The C compiler identification is Clang 14.0.5 with MSVC-like command-line
-- The CXX compiler identification is Clang 14.0.5 with MSVC-like command-line
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/Llvm/x64/bin/clang-cl.exe - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/Llvm/x64/bin/clang-cl.exe - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Configuring done
-- Generating done
-- Build files have been written to: C:/Users/vital/test/_build
C:\Users\vital\test\_build>cmake --build .
MSBuild version 17.3.1+2badb37d1 for .NET Framework
Checking Build System
Building Custom Rule C:/Users/vital/test/CMakeLists.txt
foo.vcxproj -> C:\Users\vital\test\_build\Debug\foo.lib
Building Custom Rule C:/Users/vital/test/CMakeLists.txt
main.vcxproj -> C:\Users\vital\test\_build\Debug\main.exe
Building Custom Rule C:/Users/vital/test/CMakeLists.txt
C:\Users\vital\test\_build>

Related

Conan Cross-build from Linux:x86_64 to Linux:armv7hf test_package build fails

I have a C++ library packaged with conan and it contains a test_package with a conanfile.py that uses the new conan 2.0 self.requries(self.tested_reference_str) and test_type = "explicit".
When not cross-building everything runs fine. I can build the library using conan build . and build and run the consumer test_package.
In case of cross-building, the main library can be built without issues. However, the build of the test_package fails with:
----Running------
> . "/work/tests/test_package/build/generators/conanbuild.sh" && cmake -G "Unix Makefiles" -DCMAKE_TOOLCHAIN_FILE="/work/tests/test_package/build/generators/conan_toolchain.cmake" -DCMAKE_POLICY_DEFAULT_CMP0091="NEW" -DCMAKE_BUILD_TYPE="Release" "/work/tests/test_package/."
-----------------
-- Using Conan toolchain: /work/tests/test_package/build/generators/conan_toolchain.cmake
-- The CXX compiler identification is GNU 11.3.0
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - failed
-- Check for working CXX compiler: /opt/poky/4.0.5/sysroots/x86_64-pokysdk-linux/usr/bin/arm-poky-linux-gnueabi/arm-poky-linux-gnueabi-g++
-- Check for working CXX compiler: /opt/poky/4.0.5/sysroots/x86_64-pokysdk-linux/usr/bin/arm-poky-linux-gnueabi/arm-poky-linux-gnueabi-g++ - broken
CMake Error at /opt/poky/4.0.5/sysroots/x86_64-pokysdk-linux/usr/share/cmake-3.22/Modules/CMakeTestCXXCompiler.cmake:62 (message):
The C++ compiler
"/opt/poky/4.0.5/sysroots/x86_64-pokysdk-linux/usr/bin/arm-poky-linux-gnueabi/arm-poky-linux-gnueabi-g++"
is not able to compile a simple test program.
It fails with the following output:
Change Dir: /work/tests/test_package/build/Release/CMakeFiles/CMakeTmp
Run Build Command(s):/usr/bin/gmake -f Makefile cmTC_8ea64/fast && /usr/bin/gmake -f CMakeFiles/cmTC_8ea64.dir/build.make CMakeFiles/cmTC_8ea64.dir/build
gmake[1]: Entering directory '/work/tests/test_package/build/Release/CMakeFiles/CMakeTmp'
Building CXX object CMakeFiles/cmTC_8ea64.dir/testCXXCompiler.cxx.o
/opt/poky/4.0.5/sysroots/x86_64-pokysdk-linux/usr/bin/arm-poky-linux-gnueabi/arm-poky-linux-gnueabi-g++ -O2 -pipe -g -feliminate-unused-debug-types -stdlib=libstdc++ -o CMakeFiles/cmTC_8ea64.dir/testCXXCompiler.cxx.o -c /work/tests/test_package/build/Release/CMakeFiles/CMakeTmp/testCXXCompiler.cxx
arm-poky-linux-gnueabi-g++: error: unrecognized command-line option ‘-stdlib=libstdc++’
gmake[1]: *** [CMakeFiles/cmTC_8ea64.dir/build.make:78: CMakeFiles/cmTC_8ea64.dir/testCXXCompiler.cxx.o] Error 1
gmake[1]: Leaving directory '/work/tests/test_package/build/Release/CMakeFiles/CMakeTmp'
gmake: *** [Makefile:127: cmTC_8ea64/fast] Error 2
CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
CMakeLists.txt:2 (project)
host profile:
[settings]
os=Linux
arch=armv7hf
compiler=clang
compiler.version=14
# Tried also with libc++
compiler.libcxx=libstdc++11
build_type=Release
build profile:
[settings]
os=Linux
arch=x86_64
compiler=gcc
compiler.version=11
# Without the following the error becomes:
# arm-poky-linux-gnueabi-g++: error: unrecognized command-line option ‘-stdlib=libc++’
compiler.libcxx=libstdc++11
build_type=Release
[env]
CC=gcc-11
CXX=g++-11
Any idea why cross compiling works for the library itself but the test_package fails?
Edit: I looked into conaninfo.txt, CMakeCache.txt, for both: the library generated files and the test_package generated files. Conan specifies the clang compiler in both cases (library build and test_package) but CMake uses anyway the GNU compiler for the test_package. It seems the CMAKE_CXX_COMPILER is not passed correctly to CMake in case of the test_package. A conan install inside the test_package folder also results in the wrong compiler (GNU) being used.

cmake generated header causes double build

A very simple scenario - I need to generate header, include it and if generated header is updated while cmake build, all dependent cpp units also must be rebuilt.
A simplified example:
add_custom_command(
OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/test.h
COMMAND ...
DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/test.in"
add_custom_target(test_target DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/test.h)
add_executable(test_exe
${CMAKE_CURRENT_SOURCE_DIR}/main.cpp
)
add_dependencies(test_exe test_target)
main.cpp is just:
#include "test.h"
int main()
{
return 0;
}
When I do a full rebuild, everything goes fine. But when I change test.in, run just cmake.exe --build . --target all only test.h is regenerated, but main.cpp is not recompiled. But when I run cmake.exe --build . --target all again(second time), main.cpp is recompiled and test_exe is relinked.
What do I wrong?
P.S. If I explicitly use OBJECT_DEPENDS, there is no issue, rebuild works fine, but the docs say it's not required anymore - https://cmake.org/cmake/help/v3.20/prop_sf/OBJECT_DEPENDS.html
Update:
I use Windows 10, CMake 3.19.2 and Ninja 1.10.2
Solution:
Use build directory inside your project dir, then there is no the problem. But if the build directory is outside of our project directory, then there is the problem.
Posting as an answer to be able to show full example
CMakeLists.txt
cmake_minimum_required(VERSION 3.15)
project(example)
add_custom_command(
OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/test.h
COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_CURRENT_SOURCE_DIR}/test.in" ${CMAKE_CURRENT_SOURCE_DIR}/test.h
DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/test.in")
add_custom_target(test_target DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/test.h)
add_executable(test_exe
${CMAKE_CURRENT_SOURCE_DIR}/main.cpp
)
add_dependencies(test_exe test_target)
main.cpp
#include "stdio.h"
#include "test.h"
int main()
{
printf("The value is %d\n", FOO);
return 0;
}
test.in
#define FOO 4
This works on windows with CMake 3.19.2 and Ninja 1.10.2, one can change the FOO define in test.in after an initial build and see the resultant executable be rebuilt and see it's value changed.
The commands used to test
$ cmake -B build -G Ninja
-- The C compiler identification is Clang 11.0.0 with GNU-like command-line
-- The CXX compiler identification is Clang 11.0.0 with GNU-like command-line
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: C:/Program Files/LLVM/bin/clang.exe - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: C:/Program Files/LLVM/bin/clang++.exe - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Configuring done
-- Generating done
-- Build files have been written to: <some_path>
$ cmake --build build
[3/3] Linking CXX executable test_exe.exe
$ ./build/test_exe.exe
The value is 4
$ echo "#define FOO 3" > test.in
$ cmake --build build
[3/3] Linking CXX executable test_exe.exe
$ ./build/test_exe.exe
The value is 3

cmake: why doesn't CMAKE_CXX_STANDARD seem to work with check_cxx_source_compiles

Here's an MCVE:
cmake_minimum_required(VERSION 3.1)
Project(Test)
include(CheckCXXSourceCompiles)
set (CMAKE_CXX_FLAGS "-std=c++11 ${CMAKE_CXX_FLAGS}")
#set (CMAKE_CXX_STANDARD_REQUIRED TRUE)
#set (CMAKE_CXX_STANDARD 11)
#set (CMAKE_CXX_EXTENSIONS FALSE)
check_cxx_source_compiles("
#include <atomic>
int main() {
std::atomic<int> u{5};
return u;
}" HAVE_STDLIB_ATOMIC)
if (NOT HAVE_STDLIB_ATOMIC)
message(FATAL_ERROR "Did not find std::atomic support!")
endif()
When I use the CMAKE_CXX_FLAGS version, it works fine, but when I use the new CMAKE_CXX_STANDARD flags which we are supposed to use now, it doesn't work, I get the following build errors:
$ cmake ..
-- The C compiler identification is GNU 5.4.1
-- The CXX compiler identification is GNU 5.4.1
-- 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
-- Detecting C compile features
-- Detecting C compile features - 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
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Performing Test HAVE_STDLIB_ATOMIC
-- Performing Test HAVE_STDLIB_ATOMIC - Failed
CMake Error at CMakeLists.txt:20 (message):
Did not find std::atomic support!
-- Configuring incomplete, errors occurred!
See also "/home/chris/cmake_test/build/CMakeFiles/CMakeOutput.log".
See also "/home/chris/cmake_test/build/CMakeFiles/CMakeError.log".
The error log indicates it's not using the -std=c++11 flag:
$ cat /home/chris/cmake_test/build/CMakeFiles/CMakeError.log
Performing C++ SOURCE FILE Test HAVE_STDLIB_ATOMIC failed with the following output:
Change Dir: /home/chris/cmake_test/build/CMakeFiles/CMakeTmp
Run Build Command:"/usr/bin/make" "cmTC_42a05/fast"
/usr/bin/make -f CMakeFiles/cmTC_42a05.dir/build.make CMakeFiles/cmTC_42a05.dir/build
make[1]: Entering directory '/home/chris/cmake_test/build/CMakeFiles/CMakeTmp'
Building CXX object CMakeFiles/cmTC_42a05.dir/src.cxx.o
/usr/bin/c++ -DHAVE_STDLIB_ATOMIC -o CMakeFiles/cmTC_42a05.dir/src.cxx.o -c /home/chris/cmake_test/build/CMakeFiles/CMakeTmp/src.cxx
In file included from /usr/include/c++/5/atomic:38:0,
from /home/chris/cmake_test/build/CMakeFiles/CMakeTmp/src.cxx:2:
/usr/include/c++/5/bits/c++0x_warning.h:32:2: error: #error This file requires compiler and library support for the ISO C++ 2011 standard. This support must be enabled with the -std=c++11 or -std=gnu++11 compiler options.
#error This file requires compiler and library support \
^
/home/chris/cmake_test/build/CMakeFiles/CMakeTmp/src.cxx: In function ‘int main()’:
/home/chris/cmake_test/build/CMakeFiles/CMakeTmp/src.cxx:5:3: error: ‘atomic’ is not a member of ‘std’
std::atomic<int> u{5};
^
/home/chris/cmake_test/build/CMakeFiles/CMakeTmp/src.cxx:5:15: error: expected primary-expression before ‘int’
std::atomic<int> u{5};
^
/home/chris/cmake_test/build/CMakeFiles/CMakeTmp/src.cxx:6:10: error: ‘u’ was not declared in this scope
return u;
^
CMakeFiles/cmTC_42a05.dir/build.make:65: recipe for target 'CMakeFiles/cmTC_42a05.dir/src.cxx.o' failed
make[1]: *** [CMakeFiles/cmTC_42a05.dir/src.cxx.o] Error 1
make[1]: Leaving directory '/home/chris/cmake_test/build/CMakeFiles/CMakeTmp'
Makefile:126: recipe for target 'cmTC_42a05/fast' failed
make: *** [cmTC_42a05/fast] Error 2
Source file was:
#include <atomic>
int main() {
std::atomic<int> u{5};
return u;
}
My cmake version is:
$ cmake --version
cmake version 3.5.1
CMake suite maintained and supported by Kitware (kitware.com/cmake).
I can't figure out why cmake doesn't use the std=c++11 flag here, according to the docu, CMAKE_CXX_STANDARD is supposed to work since version 3.1.
Anyone know what's wrong here?
What's the most appropriate workaround? Should I use CMAKE_CXX_FLAGS adjustments for the tests, and CMAKE_CXX_STANDARD for the targets? It seems to me that the exact same configuration should be used for the tests and the targets, otherwise what's the point of the tests :/
According to documentation, you can set CMAKE_REQUIRED_FLAGS to make try_compile use C++11 flag.
Since CMake 3.8, you can add
cmake_policy(SET CMP0067 NEW)
(you do need CMAKE_CXX_STANDARD_REQUIRED=ON). See the CMake doc on CMP0067

How can I make a library find Eigen with CMake in macOS?

I am trying to compile my project with CMake which includes the Ceres Solver library. I'm using macOS Sierra with Xcode 8.1 dev tools.
I installed the library with Homebrew (brew install ceres-solver). I downloaded and tested the binary manually (http://ceres-solver.org/building.html#mac-os-x), and that works just fine. But I can't include it in my own project because it can't seem to find Eigen. Here is a complete example:
ceres-test/CMakeLists.txt:
cmake_minimum_required(VERSION 2.8)
project(CeresTest)
find_package(ceres REQUIRED)
add_executable(
TestCeres
src/test_ceres.cpp
)
target_link_libraries(
TestCeres
ceres
)
ceres-test/src/test_ceres.cpp
#include <iostream>
#include "ceres/ceres.h"
int main(int argc, char** argv) {
std::cout << "Works." << std::endl;
return 0;
}
How I compile it:
mkdir build
cd build
cmake ..
make
Full output:
me: ceres-test $ mkdir build
me: ceres-test $ cd build/
cmake
me: build $ cmake ..
-- The C compiler identification is AppleClang 8.0.0.8000042
-- The CXX compiler identification is AppleClang 8.0.0.8000042
-- Check for working C compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc
-- Check for working C compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++
-- Check for working CXX compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found required Ceres dependency: Eigen version 3.2.10 in /usr/local/include/eigen3
-- Found required Ceres dependency: Glog in /usr/local/include
-- Found Ceres version: 1.11.0 installed in: /usr/local
-- Configuring done
-- Generating done
-- Build files have been written to: /Users/me/Tests/ceres-test/build
make
me: build $ make
Scanning dependencies of target TestCeres
[ 50%] Building CXX object CMakeFiles/TestCeres.dir/src/test_ceres.cpp.o
In file included from /Users/me/Tests/ceres-test/src/test_ceres.cpp:3:
In file included from /usr/local/include/ceres/ceres.h:37:
In file included from /usr/local/include/ceres/autodiff_cost_function.h:132:
In file included from /usr/local/include/ceres/internal/autodiff.h:145:
/usr/local/include/ceres/jet.h:165:10: fatal error: 'Eigen/Core' file not found
#include "Eigen/Core"
^
1 error generated.
make[2]: *** [CMakeFiles/TestCeres.dir/src/test_ceres.cpp.o] Error 1
make[1]: *** [CMakeFiles/TestCeres.dir/all] Error 2
make: *** [all] Error 2
I have no idea how to resolve this. None of the solutions I found online helped. CMake seems to be finding the Eigen library just fine, so I'm not sure how to add it in.
On a side note I cannot include "Eigen/Core" directly either, but the tests that I was able to compile do include it and those are fine. I'm not familiar how to deal with these kinds of problems with CMake.
Edit: I can get it to compile if I include it as "eigen3/Eigen/Core" but I can't change the source code for Ceres.
Fixed with
include_directories(${EIGEN_INCLUDE_DIR})
in the CMakeLists....
For my mac mini m1.
I found the eigen library through
brew link --overwrite eigen.
It's located on
/opt/homebrew/Cellar/eigen/3.4.0_1/include/eigen3

CMake "clang++ is not able compile a simple test program" (Fedora 20)

So I tried to install clang + cmake to compile a simple C++ program and I'm getting the following error:
-- The C compiler identification is GNU 4.8.3
-- The CXX compiler identification is Clang 3.5.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/local/bin/clang++
-- Check for working CXX compiler: /usr/local/bin/clang++ -- broken
CMake Error at /usr/share/cmake/Modules/CMakeTestCXXCompiler.cmake:54 (message):
The C++ compiler "/usr/local/bin/clang++" is not able to compile a simple
test program.
It fails with the following output:
Change Dir: /home/jtcwang/tmp/CMake/CMake/CMakeFiles/CMakeTmp
Run Build Command:/usr/bin/gmake "cmTryCompileExec697180971/fast"
/usr/bin/gmake -f CMakeFiles/cmTryCompileExec697180971.dir/build.make
CMakeFiles/cmTryCompileExec697180971.dir/build
gmake[1]: Entering directory
`/home/jtcwang/tmp/CMake/CMake/CMakeFiles/CMakeTmp'
/usr/bin/cmake -E cmake_progress_report
/home/jtcwang/tmp/CMake/CMake/CMakeFiles/CMakeTmp/CMakeFiles 1
Building CXX object
CMakeFiles/cmTryCompileExec697180971.dir/testCXXCompiler.cxx.o
/usr/local/bin/clang++ -o
CMakeFiles/cmTryCompileExec697180971.dir/testCXXCompiler.cxx.o -c
/home/jtcwang/tmp/CMake/CMake/CMakeFiles/CMakeTmp/testCXXCompiler.cxx
Linking CXX executable cmTryCompileExec697180971
/usr/bin/cmake -E cmake_link_script
CMakeFiles/cmTryCompileExec697180971.dir/link.txt --verbose=1
/usr/local/bin/clang++
CMakeFiles/cmTryCompileExec697180971.dir/testCXXCompiler.cxx.o -o
cmTryCompileExec697180971 -rdynamic
/usr/bin/ld: cannot find -lstdc++
clang: error: linker command failed with exit code 1 (use -v to see
invocation)
gmake[1]: Leaving directory
`/home/jtcwang/tmp/CMake/CMake/CMakeFiles/CMakeTmp'
gmake[1]: *** [cmTryCompileExec697180971] Error 1
gmake: *** [cmTryCompileExec697180971/fast] Error 2
It's not even compiling my program because it fails to compile a test program.
Looks like the important line is here:
/usr/bin/ld: cannot find -lstdc++
However, I have checked that libstdc++ is installed and up to date, so at this point I'm quite lost.
Other things I've tried:
Using prebuilt binaries instead of sudo yum install clang
remove and reinstall
Tried clang++ hello.cpp (hello world program). It says <iostreams> is not found. Is clang missing a standard library? EDIT: changing to <iostream> gives me the same linker error above.
I'm not familiar with the clang, cmake and C++ scene in general, so I'd appreciate any pointers. Thanks!
You need the development libraries and headers for C++ library, try
yum install libstdc++-devel
Your /home/gnu/bin/c++ seem to require additional flag to link things properly and CMake doesn't know about that.
To use /usr/bin/c++ as your compiler run cmake with -DCMAKE_CXX_COMPILER=/usr/bin/c++.
Also, CMAKE_PREFIX_PATH variable sets destination dir where your project' files should be installed. It has nothing to do with CMake installation prefix and CMake itself already know this.