luabind compiling error occurs - gcc

I am trying to compile luabind which I got from this link. After I do
mkdir build
cmake ..
make VERBOSE=1
"cmake .." produces these lines,
-- The C compiler identification is GNU
-- The CXX compiler identification is GNU
-- Check for working C compiler: /usr/bin/gcc
-- Check for working C compiler: /usr/bin/gcc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/g++-4.7
-- Check for working CXX compiler: /usr/bin/g++-4.7 -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Boost version: 1.53.0
-- Found Lua52: /usr/lib/i386-linux-gnu/liblua5.2.so;/usr/lib/i386-linux-gnu/libm.so
-- Configuring done
-- Generating done
-- Build files have been written to: /home/mwh/Desktop/Downloads/luabind-master/build
"make VERBOSE=1" produces following errors.
/usr/bin/cmake -H/home/mwh/Desktop/Downloads/luabind-master -B/home/mwh/Desktop/Downloads/luabind-master/build --check-build-system CMakeFiles/Makefile.cmake 0
/usr/bin/cmake -E cmake_progress_start /home/mwh/Desktop/Downloads/luabind-master/build/CMakeFiles /home/mwh/Desktop/Downloads/luabind-master/build/CMakeFiles/progress.marks
make -f CMakeFiles/Makefile2 all
make[1]: Entering directory `/home/mwh/Desktop/Downloads/luabind-master/build'
make -f src/CMakeFiles/luabind.dir/build.make src/CMakeFiles/luabind.dir/depend
make[2]: Entering directory `/home/mwh/Desktop/Downloads/luabind-master/build'
cd /home/mwh/Desktop/Downloads/luabind-master/build && /usr/bin/cmake -E cmake_depends "Unix Makefiles" /home/mwh/Desktop/Downloads/luabind-master /home/mwh/Desktop/Downloads/luabind-master/src /home/mwh/Desktop/Downloads/luabind-master/build /home/mwh/Desktop/Downloads/luabind-master/build/src /home/mwh/Desktop/Downloads/luabind-master/build/src/CMakeFiles/luabind.dir/DependInfo.cmake --color=
make[2]: Leaving directory `/home/mwh/Desktop/Downloads/luabind-master/build'
make -f src/CMakeFiles/luabind.dir/build.make src/CMakeFiles/luabind.dir/build
make[2]: Entering directory `/home/mwh/Desktop/Downloads/luabind-master/build'
/usr/bin/cmake -E cmake_progress_report /home/mwh/Desktop/Downloads/luabind-master/build/CMakeFiles 2
[ 1%] Building CXX object src/CMakeFiles/luabind.dir/class.cpp.o
cd /home/mwh/Desktop/Downloads/luabind-master/build/src && /usr/bin/g++-4.7 -I/usr/local/include -I/usr/include/lua5.2 -I/home/mwh/Desktop/Downloads/luabind-master -o CMakeFiles/luabind.dir/class.cpp.o -c /home/mwh/Desktop/Downloads/luabind-master/src/class.cpp
In file included from /home/mwh/Desktop/Downloads/luabind-master/luabind/object.hpp:38:0,
from /home/mwh/Desktop/Downloads/luabind-master/luabind/scope.hpp:28,
from /home/mwh/Desktop/Downloads/luabind-master/luabind/class.hpp:92,
from /home/mwh/Desktop/Downloads/luabind-master/src/class.cpp:30:
/home/mwh/Desktop/Downloads/luabind-master/luabind/detail/policy.hpp: In member function ‘T luabind::detail::enum_converter::apply(lua_State*, luabind::detail::by_value<T>, int)’:
/home/mwh/Desktop/Downloads/luabind-master/luabind/detail/policy.hpp:498:21: error: ‘underlying_type’ in namespace ‘std’ does not name a type
/home/mwh/Desktop/Downloads/luabind-master/luabind/detail/policy.hpp:499:47: error: expected type-specifier before ‘integral_t’
/home/mwh/Desktop/Downloads/luabind-master/luabind/detail/policy.hpp:499:47: error: expected ‘>’ before ‘integral_t’
/home/mwh/Desktop/Downloads/luabind-master/luabind/detail/policy.hpp:499:47: error: expected ‘(’ before ‘integral_t’
/home/mwh/Desktop/Downloads/luabind-master/luabind/detail/policy.hpp:499:47: error: ‘integral_t’ was not declared in this scope
/home/mwh/Desktop/Downloads/luabind-master/luabind/detail/policy.hpp:499:83: error: expected ‘)’ before ‘;’ token
make[2]: *** [src/CMakeFiles/luabind.dir/class.cpp.o] Error 1
make[2]: Leaving directory `/home/mwh/Desktop/Downloads/luabind-master/build'
make[1]: *** [src/CMakeFiles/luabind.dir/all] Error 2
make[1]: Leaving directory `/home/mwh/Desktop/Downloads/luabind-master/build'
make: *** [all] Error 2
What shall I do to correct this problem? I am using gcc 4.7.3, boost 1.53, Lua 5.2 in Ubuntu 12.04. Please help.

I just checked out the project at revision 05c84a034e and built it on Mac OS X. Here's what CMake told me at configure time:
-- The CXX compiler identification is GNU 4.7.3
-- Checking whether CXX compiler has -isysroot - yes
-- Checking whether CXX compiler supports OSX deployment target flag - yes
-- Check for working CXX compiler: /opt/local/bin/g++ -- works
-- Detecting CXX compiler ABI info - done
-- Boost version: 1.53.0
-- Found Lua52: /opt/local/lib/liblua.dylib;
So I have GCC 4.7.3, Boost 1.53, and Lua 5.2. I see you have GCC 4.7.3 also, but what about Boost and Lua?
Edit: Here's my compilation line from make VERBOSE=1 for the first file:
g++ -Wall -std=c++11 -pedantic -Wall -Wextra -Wcast-align -Wcast-qual -Wctor-dtor-privacy -Wdisabled-optimization -Wformat=2 -Winit-self -Wlogical-op -Wmissing-declarations -Wmissing-include-dirs -Wnoexcept -Wold-style-cast -Woverloaded-virtual -Wredundant-decls -Wshadow -Wsign-conversion -Wsign-promo -Wstrict-null-sentinel -Wstrict-overflow=5 -Wno-deprecated-declarations -o CMakeFiles/luabind.dir/class.cpp.o -c class.cpp
You on the other hand show this:
g++-4.7 -o CMakeFiles/luabind.dir/class.cpp.o -c class.cpp
So the question is, where did all your compiler flags go? The top-level CMakeLists.txt should contain this:
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -std=c++11")
And a bunch more. Since you aren't getting those flags set, you need to figure out why. You might try adding some message("I am here") debug statements in your CMakeLists.txt and running cmake again from scratch to see if the expected parts of the configuration are being executed at all. The key thing here is that your compilation line lacks -std=c++11--that's why you get the error you have.

Related

Cross-compile for Windows from macOS? - i686-w64-mingw32-ld: Error: unable to disambiguate: -search_paths_first (did you mean --search_paths_first ?)

Trying to cross compile, here is the minimal example CMakeLists.txt
cmake_minimum_required(VERSION 3.0)
project(hello VERSION 0.0.0 LANGUAGES C)
set(src "${CMAKE_CURRENT_BINARY_DIR}/src/main.c")
file(WRITE "${src}" "int main(){}")
add_executable(${PROJECT_NAME} "${src}")
$ brew install mingw-w64
$ mkdir 'cmake-build-win64-debug' && cd "$_"
$ cmake .. \
-DCMAKE_BUILD_TYPE='Debug' \
-DCMAKE_C_COMPILER='i686-w64-mingw32-gcc' \
-DCMAKE_CXX_COMPILER='i686-w64-mingw32-g++'
-- The C compiler identification is GNU 10.3.0
-- The CXX compiler identification is GNU 10.3.0
-- Checking whether C compiler has -isysroot
-- Checking whether C compiler has -isysroot - yes
-- Checking whether C compiler supports OSX deployment target flag
-- Checking whether C compiler supports OSX deployment target flag - no
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - failed
-- Check for working C compiler: /usr/local/bin/i686-w64-mingw32-gcc
-- Check for working C compiler: /usr/local/bin/i686-w64-mingw32-gcc - broken
CMake Error at /usr/local/Cellar/cmake/3.20.1/share/cmake/Modules/CMakeTestCCompiler.cmake:66 (message):
The C compiler
"/usr/local/bin/i686-w64-mingw32-gcc"
is not able to compile a simple test program.
It fails with the following output:
Change Dir: cmake-build-win64-debug/CMakeFiles/CMakeTmp
Run Build Command(s):/usr/bin/make -f Makefile cmTC_f30ca/fast && /Applications/Xcode.app/Contents/Developer/usr/bin/make -f CMakeFiles/cmTC_f30ca.dir/build.make CMakeFiles/cmTC_f30ca.dir/build
Building C object CMakeFiles/cmTC_f30ca.dir/testCCompiler.c.o
/usr/local/bin/i686-w64-mingw32-gcc -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk -o CMakeFiles/cmTC_f30ca.dir/testCCompiler.c.o -c cmake-build-win64-debug/CMakeFiles/CMakeTmp/testCCompiler.c
Linking C executable cmTC_f30ca
/usr/local/Cellar/cmake/3.20.1/bin/cmake -E cmake_link_script CMakeFiles/cmTC_f30ca.dir/link.txt --verbose=1
/usr/local/bin/i686-w64-mingw32-gcc -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk -Wl,-search_paths_first -Wl,-headerpad_max_install_names CMakeFiles/cmTC_f30ca.dir/testCCompiler.c.o -o cmTC_f30ca
/usr/local/Cellar/mingw-w64/8.0.0_4/toolchain-i686/bin/i686-w64-mingw32-ld: Error: unable to disambiguate: -search_paths_first (did you mean --search_paths_first ?)
collect2: error: ld returned 1 exit status
make[1]: *** [cmTC_f30ca] Error 1
make: *** [cmTC_f30ca/fast] Error 2
CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
CMakeLists.txt:3 (project)
-- Configuring incomplete, errors occurred!
See also "cmake-build-win64-debug/CMakeFiles/CMakeOutput.log".
See also "cmake-build-win64-debug/CMakeFiles/CMakeError.log".
So I tried https://stackoverflow.com/a/54482619, specifically with
-DCMAKE_CXX_LINK_FLAGS='' \
-DHAVE_FLAG_SEARCH_PATHS_FIRST=0
But that didn't fix it. How do I build for Windows from macOS?

Gcc offload compilation options

I'm trying to build the simplest OpenMP or OpenACC C++ program with GPU offload using gcc-10, CUDA 11 on Ubuntu 18.04 and this CMakeLists.txt file (or OpenMP version):
cmake_minimum_required(VERSION 3.18)
project(hello VERSION 0.1.0)
find_package(OpenACC REQUIRED)
add_executable(hello main.cpp)
target_compile_options(hello PRIVATE -O3 -fopenacc -foffload=nvptx-none)
target_link_libraries (hello OpenACC::OpenACC_CXX)
The build fails with:
[build] [100%] Linking CXX executable hello
[build] /usr/local/bin/cmake -E cmake_link_script CMakeFiles/hello.dir/link.txt --verbose=1
[build] /usr/bin/g++-10 -O3 -DNDEBUG -fopenacc CMakeFiles/hello.dir/main.cpp.o -o hello
[build] ptxas fatal : Value 'sm_30' is not defined for option 'gpu-name'
[build] nvptx-as: ptxas returned 255 exit status
[build] mkoffload: fatal error: /usr/bin/x86_64-linux-gnu-accel-nvptx-none-gcc-10 returned 1 exit status
[build] compilation terminated.
I suspect that a flag defining GPU architecture is missing, but I can't find relevant documentation. Offloading Support in GCC: Compilation options don't have Nvidia example and when I try my best guess -foffload="-arch=sm_75" or -foffload=nvidia-"-arch=sm_75", I get:
[build] [ 50%] Building CXX object CMakeFiles/hello.dir/main.cpp.o
[build] /usr/local/bin/cmake -E time /usr/bin/g++-10 -DFMT_LOCALE -O3 -DNDEBUG -O3 -fopenacc -foffload=nvptx-none -foffload=\"-arch=sm_75\" -std=gnu++2a -o CMakeFiles/hello.dir/main.cpp.o -c /home/paul/st/hello/main.cpp
[build] g++-10: fatal error: GCC is not configured to support "-arch as offload target
[build] compilation terminated.
Any clues or relevant links will be highly appreciated.

How to read stracktrace with CMake and Gfortran error

I'm required to install the Dune library for my "Partial Differential Equation" lecture and am stuck. I'm on a MacBook and we received an installation script (for Linux), but I always get an error that my Gfortran and g++ compiler is not compatible.
I've researched similar errors and some could be fixed by deleting the CMake cache, but I'm not sure and don't want to screw up the folder structure.
The error code looks like this:
matthias#MacBookPro ~/Documents/studium_matthias/semester_7/num_2/dune$ ./buildmodules.sh
build common
----- using default flags $CMAKE_FLAGS from /Users/matthias/Documents/studium_matthias/semester_7/num_2/dune/release.opts -----
--- going to build dune-common ---
--- calling all for dune-common ---
--- calling vcsetup for dune-common ---
--- calling configure for dune-common ---
cmake -DDUNE_BUILD_DIRECTORY_ROOT_PATH='/Users/matthias/Documents/studium_matthias/semester_7/num_2/dune/release-build' -DCMAKE_C_COMPILER='/usr/bin/gcc' -DCMAKE_CXX_COMPILER='/usr/bin/g++' -DCMAKE_Fortran_COMPILER='/usr/local/bin/gfortran' -DCMAKE_CXX_FLAGS_RELEASE='-O3 -DNDEBUG -g0 -funroll-loops -ftemplate-depth=5120 -march=native -Wa,-q' -DHDF5_ROOT=/Users/matthias/Documents/studium_matthias/semester_7/num_2/dune/external/hdf5 -DFFTW3_ROOT_DIR=/Users/matthias/Documents/studium_matthias/semester_7/num_2/dune/external/fftw3 -DCMAKE_BUILD_TYPE=Release -DDUNE_SYMLINK_TO_SOURCE_TREE=1 "/Users/matthias/Documents/studium_matthias/semester_7/num_2/dune/dune-common"
CMake Error at /usr/local/Cellar/cmake/3.15.5/share/cmake/Modules/FortranCInterface.cmake:383 (message):
The Fortran compiler:
/usr/local/bin/gfortran
and the CXX compiler:
/usr/bin/g++
failed to compile a simple test project using both languages. The output
was:
Change Dir: /Users/matthias/Documents/studium_matthias/semester_7/num_2/dune/release-build/dune-common/CMakeFiles/FortranCInterface/VerifyCXX
Run Build Command(s):/usr/bin/make VerifyFortranC && /usr/local/Cellar/cmake/3.15.5/bin/cmake -S/usr/local/Cellar/cmake/3.15.5/share/cmake/Modules/FortranCInterface/Verify -B/Users/matthias/Documents/studium_matthias/semester_7/num_2/dune/release-build/dune-common/CMakeFiles/FortranCInterface/VerifyCXX --check-build-system CMakeFiles/Makefile.cmake 0
/Library/Developer/CommandLineTools/usr/bin/make -f CMakeFiles/Makefile2 VerifyFortranC
/usr/local/Cellar/cmake/3.15.5/bin/cmake -S/usr/local/Cellar/cmake/3.15.5/share/cmake/Modules/FortranCInterface/Verify -B/Users/matthias/Documents/studium_matthias/semester_7/num_2/dune/release-build/dune-common/CMakeFiles/FortranCInterface/VerifyCXX --check-build-system CMakeFiles/Makefile.cmake 0
/usr/local/Cellar/cmake/3.15.5/bin/cmake -E cmake_progress_start /Users/matthias/Documents/studium_matthias/semester_7/num_2/dune/release-build/dune-common/CMakeFiles/FortranCInterface/VerifyCXX/CMakeFiles 6
/Library/Developer/CommandLineTools/usr/bin/make -f CMakeFiles/Makefile2 CMakeFiles/VerifyFortranC.dir/all
/Library/Developer/CommandLineTools/usr/bin/make -f CMakeFiles/VerifyFortran.dir/build.make CMakeFiles/VerifyFortran.dir/depend
cd /Users/matthias/Documents/studium_matthias/semester_7/num_2/dune/release-build/dune-common/CMakeFiles/FortranCInterface/VerifyCXX && /usr/local/Cellar/cmake/3.15.5/bin/cmake -E cmake_depends "Unix Makefiles" /usr/local/Cellar/cmake/3.15.5/share/cmake/Modules/FortranCInterface/Verify /usr/local/Cellar/cmake/3.15.5/share/cmake/Modules/FortranCInterface/Verify /Users/matthias/Documents/studium_matthias/semester_7/num_2/dune/release-build/dune-common/CMakeFiles/FortranCInterface/VerifyCXX /Users/matthias/Documents/studium_matthias/semester_7/num_2/dune/release-build/dune-common/CMakeFiles/FortranCInterface/VerifyCXX /Users/matthias/Documents/studium_matthias/semester_7/num_2/dune/release-build/dune-common/CMakeFiles/FortranCInterface/VerifyCXX/CMakeFiles/VerifyFortran.dir/DependInfo.cmake
Scanning dependencies of target VerifyFortran
/Library/Developer/CommandLineTools/usr/bin/make -f CMakeFiles/VerifyFortran.dir/build.make CMakeFiles/VerifyFortran.dir/build
[ 16%] Building Fortran object CMakeFiles/VerifyFortran.dir/VerifyFortran.f.o
/usr/local/bin/gfortran -DVERIFY_CXX -I/Users/matthias/Documents/studium_matthias/semester_7/num_2/dune/release-build/dune-common/CMakeFiles/FortranCInterface/VerifyCXX -O3 -DNDEBUG -O3 -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk -c /usr/local/Cellar/cmake/3.15.5/share/cmake/Modules/FortranCInterface/Verify/VerifyFortran.f -o CMakeFiles/VerifyFortran.dir/VerifyFortran.f.o
[ 33%] Linking Fortran static library libVerifyFortran.a
/usr/local/Cellar/cmake/3.15.5/bin/cmake -P CMakeFiles/VerifyFortran.dir/cmake_clean_target.cmake
/usr/local/Cellar/cmake/3.15.5/bin/cmake -E cmake_link_script CMakeFiles/VerifyFortran.dir/link.txt --verbose=1
/usr/bin/ar qc libVerifyFortran.a CMakeFiles/VerifyFortran.dir/VerifyFortran.f.o
/usr/bin/ranlib libVerifyFortran.a
[ 33%] Built target VerifyFortran
/Library/Developer/CommandLineTools/usr/bin/make -f CMakeFiles/VerifyFortranC.dir/build.make CMakeFiles/VerifyFortranC.dir/depend
cd /Users/matthias/Documents/studium_matthias/semester_7/num_2/dune/release-build/dune-common/CMakeFiles/FortranCInterface/VerifyCXX && /usr/local/Cellar/cmake/3.15.5/bin/cmake -E cmake_depends "Unix Makefiles" /usr/local/Cellar/cmake/3.15.5/share/cmake/Modules/FortranCInterface/Verify /usr/local/Cellar/cmake/3.15.5/share/cmake/Modules/FortranCInterface/Verify /Users/matthias/Documents/studium_matthias/semester_7/num_2/dune/release-build/dune-common/CMakeFiles/FortranCInterface/VerifyCXX /Users/matthias/Documents/studium_matthias/semester_7/num_2/dune/release-build/dune-common/CMakeFiles/FortranCInterface/VerifyCXX /Users/matthias/Documents/studium_matthias/semester_7/num_2/dune/release-build/dune-common/CMakeFiles/FortranCInterface/VerifyCXX/CMakeFiles/VerifyFortranC.dir/DependInfo.cmake
Scanning dependencies of target VerifyFortranC
/Library/Developer/CommandLineTools/usr/bin/make -f CMakeFiles/VerifyFortranC.dir/build.make CMakeFiles/VerifyFortranC.dir/build
[ 50%] Building C object CMakeFiles/VerifyFortranC.dir/main.c.o
/usr/bin/gcc -DVERIFY_CXX -I/Users/matthias/Documents/studium_matthias/semester_7/num_2/dune/release-build/dune-common/CMakeFiles/FortranCInterface/VerifyCXX -O3 -DNDEBUG -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk -o CMakeFiles/VerifyFortranC.dir/main.c.o -c /usr/local/Cellar/cmake/3.15.5/share/cmake/Modules/FortranCInterface/Verify/main.c
[ 66%] Building C object CMakeFiles/VerifyFortranC.dir/VerifyC.c.o
/usr/bin/gcc -DVERIFY_CXX -I/Users/matthias/Documents/studium_matthias/semester_7/num_2/dune/release-build/dune-common/CMakeFiles/FortranCInterface/VerifyCXX -O3 -DNDEBUG -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk -o CMakeFiles/VerifyFortranC.dir/VerifyC.c.o -c /usr/local/Cellar/cmake/3.15.5/share/cmake/Modules/FortranCInterface/Verify/VerifyC.c
[ 83%] Building CXX object CMakeFiles/VerifyFortranC.dir/VerifyCXX.cxx.o
/usr/bin/g++ -DVERIFY_CXX -I/Users/matthias/Documents/studium_matthias/semester_7/num_2/dune/release-build/dune-common/CMakeFiles/FortranCInterface/VerifyCXX -std=c++17 -O3 -DNDEBUG -g0 -funroll-loops -ftemplate-depth=5120 -march=native -Wa,-q -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk -o CMakeFiles/VerifyFortranC.dir/VerifyCXX.cxx.o -c /usr/local/Cellar/cmake/3.15.5/share/cmake/Modules/FortranCInterface/Verify/VerifyCXX.cxx
clang: error: unsupported argument '-q' to option 'Wa,'
make[3]: *** [CMakeFiles/VerifyFortranC.dir/VerifyCXX.cxx.o] Error 1
make[2]: *** [CMakeFiles/VerifyFortranC.dir/all] Error 2
make[1]: *** [CMakeFiles/VerifyFortranC.dir/rule] Error 2
make: *** [VerifyFortranC] Error 2
Call Stack (most recent call first):
cmake/modules/DuneMacros.cmake:710 (FortranCInterface_VERIFY)
CMakeLists.txt:17 (dune_project)
-- Configuring incomplete, errors occurred!
See also "/Users/matthias/Documents/studium_matthias/semester_7/num_2/dune/release-build/dune-common/CMakeFiles/CMakeOutput.log".
See also "/Users/matthias/Documents/studium_matthias/semester_7/num_2/dune/release-build/dune-common/CMakeFiles/CMakeError.log".
--- Failed to build dune-common ---
Terminating dunecontrol due to previous errors!
How can I approach this?
As #squareskittles pointed out in the comments, the error arised from the unsupported argument -q to Wa,. This tells the compiler (gcc!) to pass the option -q to the assembler.
This option is not supported by clang. which gcc told me gcc was installed and located at /usr/bin/gcc but further inspection showed that it was just a symlink to clang - even though I had gcc installed via homebrew (located at /usr/local/bin/gcc-9).
In the installation file I was able to change the path of used compiler to the gcc installation (g++ was linked to clang, and I replaced it as well). From that point on the -q argument to Wa was valid the installation process went without further errors.
it will fine install dune core modules using homebrew package manager for your system. From now is available 2.7.1. https://github.com/dune-copasi/homebrew-tap

How to fix broken gcc compiler in conda

I am trying to compile some software that contains a compile.sh shell script. When I run the script, the software fails to compile due to what it reports as a broken C compiler.
I have tried reinstalling C compilers, both within and outside of conda, to no avail.
Below, please find the output of running the compile shell script
(base) userA#server:~/SPAdes-3.13.0-dev$ ./spades_compile.sh
-- The C compiler identification is GNU 7.3.0
-- The CXX compiler identification is GNU 7.3.0
-- Check for working C compiler: /home/userA/anaconda3/bin/x86_64-conda_cos6-linux-gnu-cc
-- Check for working C compiler: /home/userA/anaconda3/bin/x86_64-conda_cos6-linux-gnu-cc -- broken
CMake Error at /home/userA/anaconda3/share/cmake-3.14/Modules/CMakeTestCCompiler.cmake:60 (message):
The C compiler
"/home/userA/anaconda3/bin/x86_64-conda_cos6-linux-gnu-cc"
is not able to compile a simple test program.
It fails with the following output:
Change Dir: /home/userA/SPAdes-3.13.0-dev/build_spades/CMakeFiles/CMakeTmp
Run Build Command(s):/usr/bin/make cmTC_708f4/fast
/usr/bin/make -f CMakeFiles/cmTC_708f4.dir/build.make CMakeFiles/cmTC_708f4.dir/build
make[1]: Entering directory '/home/userA/SPAdes-3.13.0-dev/build_spades/CMakeFiles/CMakeTmp'
Building C object CMakeFiles/cmTC_708f4.dir/testCCompiler.c.o
/home/userA/anaconda3/bin/x86_64-conda_cos6-linux-gnu-cc -march=nocona -mtune=haswell -ftree-vectorize -fPIC -fstack-protector-strong -fno-plt -O2 -ffunction-sections -pipe -o CMakeFiles/cmTC_708f4.dir/testCCompiler.c.o -c /home/userA/SPAdes-3.13.0-dev/build_spades/CMakeFiles/CMakeTmp/testCCompiler.c
Linking C executable cmTC_708f4
/home/userA/anaconda3/bin/cmake -E cmake_link_script CMakeFiles/cmTC_708f4.dir/link.txt --verbose=1
/home/userA/anaconda3/bin/x86_64-conda_cos6-linux-gnu-cc -march=nocona -mtune=haswell -ftree-vectorize -fPIC -fstack-protector-strong -fno-plt -O2 -ffunction-sections -pipe -Wl,-O2 -Wl,--sort-common -Wl,--as-needed -Wl,-z,relro -Wl,-z,now -Wl,--disable-new-dtags -Wl,--gc-sections -rdynamic CMakeFiles/cmTC_708f4.dir/testCCompiler.c.o -o cmTC_708f4
/home/userA/anaconda3/bin/x86_64-conda_cos6-linux-gnu-ld: cannot find crtbeginS.o: No such file or directory
/home/userA/anaconda3/bin/x86_64-conda_cos6-linux-gnu-ld: cannot find -lgcc
/home/userA/anaconda3/bin/x86_64-conda_cos6-linux-gnu-ld: cannot find -lgcc
collect2: error: ld returned 1 exit status
CMakeFiles/cmTC_708f4.dir/build.make:86: recipe for target 'cmTC_708f4' failed
make[1]: *** [cmTC_708f4] Error 1
make[1]: Leaving directory '/home/userA/SPAdes-3.13.0-dev/build_spades/CMakeFiles/CMakeTmp'
Makefile:121: recipe for target 'cmTC_708f4/fast' failed
make: *** [cmTC_708f4/fast] Error 2
CMake will not be able to correctly generate this project.
Expected result: properly compiled software
Actual result: report of a broken C compiler

Linker Error: g++ 5.4 Ubuntu 16.04

The error I have is :
-- The C compiler identification is GNU 5.4.0
-- The CXX compiler identification is GNU 5.4.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
-- 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
-- Boost version: 1.58.0
-- Found MLPACK: /usr/local/include
-- Configuring done
-- Generating done
-- Build files have been written to: /home/cortana/ClionProjects/hmmClassification/build
Scanning dependencies of target hmm
[ 50%] Building CXX object CMakeFiles/hmm.dir/source/main.cpp.o
[100%] Linking CXX executable hmm
/usr/bin/ld: CMakeFiles/hmm.dir/source/main.cpp.o: undefined reference to symbol '_ZN5boost15program_options3argB5cxx11E'
//usr/lib/x86_64-linux-gnu/libboost_program_options.so.1.58.0: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
CMakeFiles/hmm.dir/build.make:95: recipe for target 'hmm' failed
make[2]: *** [hmm] Error 1
CMakeFiles/Makefile2:67: recipe for target 'CMakeFiles/hmm.dir/all' failed
make[1]: *** [CMakeFiles/hmm.dir/all] Error 2
Makefile:94: recipe for target 'all' failed
make: *** [all] Error 2
I have included the --std=c++11 tag in CMakeLists.txt
Here is the cmake :
cmake_minimum_required(VERSION 3.3)
project(hmm)
set(PROJECT_VERSION "0.0.1")
# Default configuration values. These must be before the project command or
# they won't work in Windows.
# If no build type is specified, default to "Release"
if (NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release CACHE STRING
"None Debug Release RelWithDebInfo MinSizeRel"
FORCE)
endif()
# Install to "dist" directory in Windows for testing and as a staging directory
# for the installer.
if (WIN32 AND NOT CMAKE_INSTALL_PREFIX)
set(CMAKE_INSTALL_PREFIX dist CACHE STRING "Install path prefix.")
endif()
if (NOT MSVC)
# Enable the C++11 standard
set(CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS} -std=c++11)
endif()
set(CMAKE_BUILD_TYPE "Debug")
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake")
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
find_package(Boost REQUIRED)
find_package(MLPACK REQUIRED)
include_directories(${Boost_INCLUDE_DIRS})
link_directories(${Boost_LIBRARY_DIRS})
add_definitions(${Boost_DEFINITIONS})
include_directories(${MLPACK_INCLUDE_DIRS})
link_directories(${MLPACK_LIBRARY_DIRS})
add_definitions(${MLPACK_DEFINITIONS})
# Global CMake options
set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(CMAKE_AUTOMOC ON)
# Testing configuration
enable_testing()
#add_subdirectory(source)
file(GLOB SOURCE_FILES
source/main.cpp)
add_executable(${CMAKE_PROJECT_NAME} ${SOURCE_FILES})
target_link_libraries(${CMAKE_PROJECT_NAME}
${Boost_LIBRARIES}
${MLPACK_LIBRARIES})
I dont understand the problem here. Boost and MLPack (required in the code) are properly installed. Also i have used the --std=c++11 tag that was the solution to this problem in previous answers. How do I fix this problem?
Edit:
Output of verbose cmake :
/usr/bin/c++ -I/home/cortana/ClionProjects/hmmClassification/build -I/home/cortana/ClionProjects/hmmClassification -I/usr/local/include -std=c++11 -std=c++11 -g -o CMakeFiles/hmm.dir/source/main.cpp.o -c /home/cortana/ClionProjects/hmmClassification/source/main.cpp
[100%] Linking CXX executable hmm
/usr/bin/cmake -E cmake_link_script CMakeFiles/hmm.dir/link.txt --verbose=1
/usr/bin/c++ -std=c++11 -std=c++11 -g CMakeFiles/hmm.dir/source/main.cpp.o -o hmm -L/usr/local/lib -rdynamic /usr/local/lib/libmlpack.so -Wl,-rpath,/usr/local/lib
/usr/bin/ld: CMakeFiles/hmm.dir/source/main.cpp.o: undefined reference to symbol '_ZN5boost15program_options3argB5cxx11E'
//usr/lib/x86_64-linux-gnu/libboost_program_options.so.1.58.0: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
CMakeFiles/hmm.dir/build.make:98: recipe for target 'hmm' failed
make[2]: *** [hmm] Error 1
make[2]: Leaving directory '/home/cortana/ClionProjects/hmmClassification/build'
CMakeFiles/Makefile2:70: recipe for target 'CMakeFiles/hmm.dir/all' failed
make[1]: *** [CMakeFiles/hmm.dir/all] Error 2
make[1]: Leaving directory '/home/cortana/ClionProjects/hmmClassification/build'
Makefile:97: recipe for target 'all' failed
make: *** [all] Error 2
The project tree is (if its relevant) :
.
├── cmake
│   └── FindMLPACK.cmake
├── CMakeLists.txt
└── source
├── CMakeLists.txt
├── HMMEval.h
├── HMMExperiments.h
├── hmm.h
├── hmm_impl.h
├── HMMPredict.h
├── HMMTrain.h
└── main.cpp
Although you are calling find_package(Boost REQUIRED), you are not specifying any components of Boost to be found, so ${Boost_LIBRARIES} ends up containing nothing, and even though you specify
target_link_libraries(hmm
${MLPACK_LIBRARIES}
${Boost_LIBRARIES})
it doesn't work. So the solution is to add the required components of Boost to the call to find_package():
find_package(Boost COMPONENTS program_options REQUIRED)
Ideally I think that your CMake script FindMLPACK.cmake should find the Boost dependencies too and append them to ${MLPACK_LIBRARIES}, but that is a different issue.
according to this question, have you tried to link with the bost libraries after the MLPack ones?
I believe you could do it by permuting the last two lines in your cmake file.

Resources