I have a fairly special setup here and I have not enough knowledge about CMake to find out what is wrong.
I am on Ubuntu 12.04.
I installed Qt5 from apt-add-repository ppa:ubuntu-sdk-team/ppa and CMake 2.8.11.2 from apt-add-repository ppa:kalakris/cmake (https://launchpad.net/~kalakris/+archive/ubuntu/cmake).
Here is the complete, minimal test-case:
daniel#omni-travis-test:~/projects/qtcmaketest$ ls
blubb.cpp CMakeLists.txt
daniel#omni-travis-test:~/projects/qtcmaketest$ cat CMakeLists.txt
cmake_minimum_required(VERSION 2.8.11)
project (qtcmaketest)
find_package (Qt5Widgets REQUIRED)
add_executable(qtcmaketest blubb.cpp)
target_link_libraries (qtcmaketest Qt5::Widgets)
daniel#omni-travis-test:~/projects/qtcmaketest$ cat blubb.cpp
#include <QWidget>
#include <QApplication>
int main (int argc, char * argv[])
{
QApplication app (argc, argv);
QWidget foo;
foo.show ();
}
daniel#omni-travis-test:~/projects/qtcmaketest$ cmake . && make
-- The C compiler identification is GNU 4.8.1
-- The CXX compiler identification is GNU 4.8.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
-- 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
-- Configuring done
-- Generating done
-- Build files have been written to: /home/daniel/projects/qtcmaketest
Scanning dependencies of target qtcmaketest
[100%] Building CXX object CMakeFiles/qtcmaketest.dir/blubb.cpp.o
/home/daniel/projects/qtcmaketest/blubb.cpp:1:19: fatal error: QWidget: No such file or directory
#include <QWidget>
^
compilation terminated.
make[2]: *** [CMakeFiles/qtcmaketest.dir/blubb.cpp.o] Error 1
make[1]: *** [CMakeFiles/qtcmaketest.dir/all] Error 2
make: *** [all] Error 2
Why is the include directory missing when find_package was successful?
I was using this guide:
http://qt-project.org/doc/qt-5/cmake-manual.html
I just noticed that, when following the instructions from the chapter "Using Qt 5 with CMake older than 2.8.9", compilation works. I added the following lines:
include_directories(${Qt5Widgets_INCLUDE_DIRS})
add_definitions(${Qt5Widgets_DEFINITIONS})
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${Qt5Widgets_EXECUTABLE_COMPILE_FLAGS}")
I know that this should work without those lines, since it runs on an Ubuntu 14.04 box (which includes the appropriate Qt and CMake versions by default). I don't expected to get a solution to this problem, but I could need some pointers on where to look for the problem.
I'm pretty sure that the problem lies in the version of Qt. I think that this early Qt 5 version does not include the CMake scripts to properly work with find_package alone.
On newer distros with newer Qt 5, it works as expected. Looks like you have to add special version checks to include or exclude the lines I mentioned as a workaround.
Additional info: Since Ubuntu 12.04 is really old, I decided not to support it as a target build platform for my project.
My initial reason was that Travis CI uses 12.04, but since it is so much trouble, I will hold my travis builds until they upgrade to 14.04, which seems to be quite a problem.
Travis tweeted to me, on December, 12th 2014:
Travis CI: We are working on it. Most pieces are there, but there is a critical issue with infrastructure. Thanks for your patience.
Here I recently had the same problem and found the following solution to install newer Qt5 versions which enables cmake to proceed properly:
sudo add-apt-repository "deb http://archive.ubuntu.com/ubuntu trusty universe"
sudo add-apt-repository "deb http://archive.ubuntu.com/ubuntu trusty main"
sudo add-apt-repository --yes ppa:kalakris/cmake
sudo apt-get update -qq
sudo apt-get install cmake
sudo apt-get install qdbus qmlscene qt5-default qt5-qmake qtbase5-dev-tools qtchooser qtdeclarative5-dev xbitmaps xterm libqt5svg5-dev qttools5-dev qtscript5-dev qtdeclarative5-folderlistmodel-plugin qtdeclarative5-controls-plugin -y
In the end I ended up using the following .travis.yml file to get things going:
https://github.com/hzdr/qutselect/blob/master/.travis.yml
Hope that also solves your problems.
Related
I am trying to build a project from cmake on CentOS 7. The project requires C++ 17 and I'm getting this error from the build:
CMake Error at nvbench/nvbench/CMakeLists.txt:86 (target_compile_features):
target_compile_features The compiler feature "cxx_std_17" is not known to
CXX compiler
"GNU"
version 4.8.5.
L86:
target_compile_features(nvbench PUBLIC cuda_std_17 PRIVATE cxx_std_17)
Naturally, CentOS 7's g++ has version 4.8.5 and doesn't support C++ 17, but I have devtoolset 9 which has g++ version 9.3.1. I've added these lines near the top CMakeLists.txt:
set(CMAKE_C_COMPILER /opt/rh/devtoolset-9/root/bin/gcc)
set(CMAKE_CXX_COMPILER /opt/rh/devtoolset-9/root/bin/g++)
but cmake still references the default compiler and not the one in the devtoolset.
Also made sure to run with scl enable devtoolset-9 'cmake ..' but that didn't work either.
How can I fix this so cmake uses g++ in the devtooset?
We are using flatbuffer v1.3.0 and seeing error building flatc compiler.
Same error for flatbuffer version v1.3.0 to v1.12.1
Build is successful for version 2.0.0
Should we use a particular version of make to build the flatc compiler? If so how to do it?
Steps
git clone https://github.com/google/flatbuffers/tree/v1.3.0
cd flatbuffers
cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release -Success
make --Error
Versions installed on MacOS BigSur Version 11.6
$ cmake --version
cmake version 3.19.4
CMake suite maintained and supported by Kitware (kitware.com/cmake).
$ make --version
GNU Make 3.81
Copyright (C) 2006 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE.
This program built for i386-apple-darwin11.3.0
$ gcc --version
Configured with: --prefix=/Library/Developer/CommandLineTools/usr --with-gxx-include-dir=/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/4.2.1
Apple clang version 13.0.0 (clang-1300.0.29.3)
Target: x86_64-apple-darwin20.6.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin
$ cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release
CMake Warning:
No source or binary directory provided. Both will be assumed to be the
same as the current working directory, but note that this warning will
become a fatal error in future CMake releases.
CMake Deprecation Warning at CMakeLists.txt:1 (cmake_minimum_required):
Compatibility with CMake < 2.8.12 will be removed from a future version of
CMake.
Update the VERSION argument <min> value or use a ...<max> suffix to tell
CMake that the project does not need compatibility with older versions.
-- The C compiler identification is AppleClang 13.0.0.13000029
-- The CXX compiler identification is AppleClang 13.0.0.13000029
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /Library/Developer/CommandLineTools/usr/bin/cc - 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: /Library/Developer/CommandLineTools/usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Configuring done
-- Generating done
-- Build files have been written to: /Users/abcd/Documents/FlatBuffer/flatbuffers
$ make
Scanning dependencies of target flatc
[ 2%] Building CXX object CMakeFiles/flatc.dir/src/idl_parser.cpp.o
In file included from /Users/abcd/Documents/FlatBuffer/flatbuffers/src/idl_parser.cpp:28:
In file included from /Users/abcd/Documents/FlatBuffer/flatbuffers/include/flatbuffers/idl.h:25:
/Users/abcd/Documents/FlatBuffer/flatbuffers/include/flatbuffers/flatbuffers.h:1086:25: error: definition of implicit copy constructor for 'TableKeyComparator<reflection::Object>' is deprecated because it has a user-declared copy assignment operator [-Werror,-Wdeprecated-copy]
TableKeyComparator& operator= (const TableKeyComparator&);
^
/Users/abcd/Documents/FlatBuffer/flatbuffers/include/flatbuffers/flatbuffers.h:1100:27: note: in implicit copy constructor for 'flatbuffers::FlatBufferBuilder::TableKeyComparator<reflection::Object>' first required here
std::sort(v, v + len, TableKeyComparator<T>(buf_));
^
/Users/abcd/Documents/FlatBuffer/flatbuffers/include/flatbuffers/flatbuffers.h:1113:12: note: in instantiation of function template specialization 'flatbuffers::FlatBufferBuilder::CreateVectorOfSortedTables<reflection::Object>' requested here
return CreateVectorOfSortedTables(v->data(), v->size());
^
/Users/abcd/Documents/FlatBuffer/flatbuffers/src/idl_parser.cpp:2008:35: note: in instantiation of function template specialization 'flatbuffers::FlatBufferBuilder::CreateVectorOfSortedTables<reflection::Object>' requested here```
Flatbuffer requires a specific version of clang to compile the 1.12.1.
Installing the required version.
sudo apt-get install clang-6.0 lld-6.0 clang-tidy-6.0
use update-alternatives to link the clang.
sudo update-alternatives --install /usr/bin/clang clang /usr/bin/clang-6.0 10
sudo update-alternatives --install /usr/bin/clang++ clang++
/usr/bin/clang++-6.0 10
I am attempting to build the ev3dev C++ bindings (see https://github.com/ddemidov/ev3dev-lang-cpp) for my EV3. But CMake isn't using my cross-compiler toolchain. I've successfully installed the code sourcery toolchain, built a simple hello world app, and run it on my brick. That works just fine. The trouble is that CMake uses my host's g++ compiler instead of the toolchain. I'm familiar with linux and cross-compilers, but I'm a total CMake noob. So I suspect CMake is where I'm going wrong.
I've added the following lines into CMakeLists.txt:
set(CMAKE_C_COMPILER "/cygdrive/c/Users/me/MentorGraphics/Sourcery_CodeBench_Lite_for_ARM_GNU_Linux/bin/arm-none-linux-gnueabi-gcc.exe")
set(CMAKE_CXX_COMPILER "/cygdrive/c/Users/me/MentorGraphics/Sourcery_CodeBench_Lite_for_ARM_GNU_Linux/bin/arm-none-linux-gnueabi-g++.exe")
Here's the host gcc compiler:
$ gcc --version
gcc (GCC) 5.4.0
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
And the target toolchain gcc compiler:
$ /cygdrive/c/Users/me/MentorGraphics/Sourcery_CodeBench_Lite_for_ARM_GNU_Linux/bin/arm-none-linux-gnueabi-gcc.exe --version
arm-none-linux-gnueabi-gcc.exe (Sourcery CodeBench Lite 2014.05-29) 4.8.3 20140320 (prerelease)
Copyright (C) 2013 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
The compilers are different versions, so they are really easy to distinguish.
Now here's the terminal session for the cmake build:
$ mkdir build
$ cd build
$ cmake ../ -DEV3DEV_PLATFORM=EV3
-- No build type selected, default to RelWithDebInfo
-- The C compiler identification is GNU 5.4.0
-- The CXX compiler identification is GNU 5.4.0
CMake Warning at /usr/share/cmake-3.6.2/Modules/Platform/CYGWIN.cmake:15 (message):
CMake no longer defines WIN32 on Cygwin!
(1) If you are just trying to build this project, ignore this warning or
quiet it by setting CMAKE_LEGACY_CYGWIN_WIN32=0 in your environment or in
the CMake cache. If later configuration or build errors occur then this
project may have been written under the assumption that Cygwin is WIN32.
In that case, set CMAKE_LEGACY_CYGWIN_WIN32=1 instead.
(2) If you are developing this project, add the line
set(CMAKE_LEGACY_CYGWIN_WIN32 0) # Remove when CMake >= 2.8.4 is required
at the top of your top-level CMakeLists.txt file or set the minimum
required version of CMake to 2.8.4 or higher. Then teach your project to
build on Cygwin without WIN32.
Call Stack (most recent call first):
/usr/share/cmake-3.6.2/Modules/CMakeSystemSpecificInformation.cmake:36 (include)
CMakeLists.txt:7 (project)
-- 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++.exe
-- Check for working CXX compiler: /usr/bin/c++.exe -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Configuring done
-- Generating done
-- Build files have been written to: /cygdrive/c/Users/me/Documents/AppProjects/ev3dev-lang-cpp/build
$
CMake is clearly using the cygwin host gcc/g++ compiler even though I've attempted to configure it to use the toolchain. Where am I going wrong?
EDIT: This is not a duplicate of cmake: problems specifying the compiler (2). I did actually use google, and the cross-compiling instructions on the CMake wiki (https://cmake.org/Wiki/CMake_Cross_Compiling) explicitly dictate using SET(). The problem turned out to be that CMake requires the compiler to be set before PROJECT(). I just moved the SET() lines up above PROJECT() and then CMake found the compiler.
I've got a DJI M100 and a Raspberry Pi connected by serial according to the onboard SDK quickstart guide.
However I've not done a lot of C/C++ stuff before and I am not sure how to even build the samples they provide. I did an apt-get install for cmake since it wasn't installed in the Raspbian distribution I am using.
I messed around a bit and ran cmake CMakeLists.txt and it started doing things and this is the output:
-- The C compiler identification is GNU 4.9.2
-- The CXX compiler identification is GNU 4.9.2
-- 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
-- Found Git: /usr/bin/git (found version "2.1.4")
cat: /etc/lsb-release: No such file or directory
CMake Error at CMakeLists.txt:70 (if):
if given arguments:
"STREQUAL" "16.04"
Unknown arguments specified
-- Configuring incomplete, errors occurred!
See also "/home/pi/Onboard-SDK-3.1/sample/Linux/Blocking/CMakeFiles/CMakeOutput.log".
Any ideas? I can figure out the coding part, but getting the environment set up is holding me up.
Thanks in advance!
The error message isn't in the C++ compiler, it fails when CMake is trying to deduce what needs to be compiled. that's why the error isn't in a .cpp file but in CmakeLists.txt line 70.
The Onboard-SDK isn't meant to work on Raspbian, you can check it on the link here - https://developer.dji.com/onboard-sdk/documentation/github-platform-docs/Linux/README.html
Maybe it was the reason here. I faced a similar thing even after installing CMAKE on Raspbian.
One simple option is to comment out line 70 or simply remove that line, it might work.
Also it is possible to get Onboard SDK working on Raspbian and I've done so myself by another method.
Here are the commands I used:
sudo apt-get install git
Downloaded and unzipped cmake-3.7.1.tar.gz from https://cmake.org/download/ on desktop
cd /home/pi/Desktop/cmake-3.7.1
./bootstrap
make
sudo make install
Copied Onboard-SDK-3.1 on desktop
cd /home/pi/Desktop/Onboard-SDK-3.1
Copied CMakeLists.txt from /home/pi/Desktop/Onboard-SDK-3.1/sample/Linux/Non-Blocking/CMakeLists.txt to /home/pi/Desktop/Onboard-SDK-3.1 replacing original file
Change Execute Permissions of /home/pi/Desktop/Onboard-SDK-3.1/scripts/build to Anyone
Remove lines 57-59 of CMakeLists.txt in /home/pi/Desktop/Onboard-SDK-3.1
./scripts/build --build-type debug --clean true --lidar-logging off
DJI has apparently added support for Raspbian in January 2017 as they created a branch called raspberrypi-support and committed some changes mostly around Makefiles.
Check out the branch and the associated commit.
I am following these tutorials:
ROS installation in Ubuntu
Create your ROS workspace.
In step catkin_make i'm getting error:
-- The C compiler identification is unknown
CMake Error at /usr/share/cmake-2.8/Modules/CMakeDetermineCCompiler.cmake:186 (configure_file):
configure_file Problem configuring file
-- The CXX compiler identification is unknown
CMake Error at /usr/share/cmake-2.8/Modules/CMakeDetermineCXXCompiler.cmake:185 (configure_file):
configure_file Problem configuring file
-- Check for working C compiler: /usr/bin/cc
CMake Error at /usr/share/cmake-2.8/Modules/CMakeTestCCompiler.cmake:47 (try_compile):
Unknown extension ".c" for file
/home/manoj/catkin_ws/build/CMakeFiles/CMakeTmp/testCCompiler.c
try_compile() works only for enabled languages. Currently these are:
C CXX
See project() command to enable other languages.
-- Check for working C compiler: /usr/bin/cc -- broken
CMake Error at /usr/share/cmake-2.8/Modules/CMakeTestCCompiler.cmake:61 (message):
The C compiler "/usr/bin/cc" is not able to compile a simple test program.
It fails with the following output:
I tried setting environment variables CC and CXX to /usr/bin/gcc and /usr/bin/g++, but to no use.
Also tried a fresh install of cmake, still no use. I am using Ubuntu on Windows Subsystem for Linux.
Help! Thanks in Advance.
try adding the following lines to your CMakeLists.txt before the catkin_package() :
set(CMAKE_C_COMPILER "/usr/bin/gcc")
set(CMAKE_CXX_COMPILER "/usr/bin/g++")
Sometimes, it's also better to clean up your build (usually by deleting the /devel and /build folders in your catkin_ws) and do a fresh catkin_make.
For the record, this approach is not recommended (see here, method 3), but it may help !
The error is with the cmake on WSL. Fix is inbound. Report, discussion & repro's over here: Bash on Windows: Bugs