I need some help compiling this project with cmake. Here is the error message.
$ ./build_avida
-- Building for: NMake Makefiles
CMake Warning at CMakeLists.txt:1 (PROJECT):
To use the NMake generator, cmake must be run from a shell that can use the
compiler cl from the command line. This environment does not contain
INCLUDE, LIB, or LIBPATH, and these must be set for the cl compiler to
work.
CMake Error: CMake was unable to find a build program corresponding to "NMake Makefiles". CMAKE_MAKE_PROGRAM is not set. You probably need to select a different build tool.
CMake Error: Error required internal CMake variable not set, cmake may be not be built correctly.
Missing variable is:
CMAKE_C_COMPILER_ENV_VAR
CMake Error: Error required internal CMake variable not set, cmake may be not be built correctly.
Missing variable is:
CMAKE_C_COMPILER
CMake Error: Could not find cmake module file:C:/Users/Desk/Dropbox/2012-2013/BCB504/AvidaProject/avidagit/avida/CMakeFiles/2.8.10.2/CMakeCCompiler.cmake
CMake Error: Error required internal CMake variable not set, cmake may be not be built correctly.
Missing variable is:
CMAKE_CXX_COMPILER_ENV_VAR
CMake Error: Error required internal CMake variable not set, cmake may be not be built correctly.
Missing variable is:
CMAKE_CXX_COMPILER
CMake Error: Could not find cmake module file:C:/Users/Desk/Dropbox/2012-2013/BCB504/AvidaProject/avidagit/avida/CMakeFiles/2.8.10.2/CMakeCXXCompiler.cmake
CMake Error: CMAKE_C_COMPILER not set, after EnableLanguage
CMake Error: CMAKE_CXX_COMPILER not set, after EnableLanguage
-- Configuring incomplete, errors occurred!
make: *** No rule to make target `install'. Stop.
Try to install gcc and gcc-c++, as Cmake works smooth with them.
RedHat-based
yum install gcc gcc-c++
Debian/Ubuntu-based
apt-get install cmake gcc g++
Then,
remove 'CMakeCache.txt'
run compilation again.
Even though I had gcc already installed, I had to run
sudo apt-get install build-essential
to get rid of that error
The approach I use is to start the "Visual Studio Command Prompt" which can be found in the Start menu. E.g. my visual studio 2010 Express install has a shortcute Visual Studio Command Prompt (2010) at Start Menu\Programs\Microsoft Visual Studio 2010\Visual Studio Tools.
This shortcut prepares an environment by calling a script vcvarsall.bat where the compiler, linker, etc. are setup from the right Visual Studio installation.
Alternatively, if you already have a prompt open, you can prepare the environment by calling a similar script:
:: For x86 (using the VS100COMNTOOLS env-var)
call "%VS100COMNTOOLS%"\..\..\VC\bin\vcvars32.bat
or
:: For amd64 (using the full path)
call C:\Program Files\Microsoft Visual Studio 10.0\VC\bin\amd64\vcvars64.bat
However:
Your output (with the '$' prompt) suggests that you are attempting to run CMake from a MSys shell. In that case it might be better to run CMake for MSys or MinGW, by explicitly specifying a makefile generator:
cmake -G"MSYS Makefiles"
cmake -G"MinGW Makefiles"
Run cmake --help to get a list of all possible generators.
Those errors :
"CMake Error: CMAKE_C_COMPILER not set, after EnableLanguage
CMake Error: CMAKE_CXX_COMPILER not set, after EnableLanguage"
means you haven't installed mingw32-base.
Go to http://sourceforge.net/projects/mingw/files/latest/download?source=files
and then make sure you select "mingw32-base"
Make sure you set up environment variables correctly in PATH section.
"C:\MinGW\bin"
After that open CMake and Select Installation --> Delete Cache.
And click configure button again. I solved the problem this way, hope you solve the problem.
Related
I need to update my project from NDK 21.4 to NDK 23.1. Upon the update, I face this error
C/C++: /usr/bin/ld.gold: fatal error: /usr/local/android-sdk/ndk/23.1.7779620/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/lib/aarch64-linux-android/21/crtbegin_so.o: unsupported ELF machine number 183
C/C++: clang++: error: linker command failed with exit code 1 (use -v to see invocation)
I change cmake version from 3.10.2 and 3.18.1 but still have similar error. I then change cmake version to 3.22.2. Now the above error goes away.
However, cmake 3.22.2 is not shipped with sdkmanager. Therefore, other developers need to install cmake 3.22.2 locally to build.
My question is: why sdkmanager does not have newer versions of cmake? More particular, does upgrade cmake to 3.22.2 a correct way to resolve the problem above? Or should I spend time on trying to solve the error with cmake versions available within sdkmanager?
I am trying to work with the Robot Operating System (ROS Melodic) on Windows 10 system, following the procedure from the ROS website.
http://wiki.ros.org/Installation/Windows
When I try to create a workspace (/catkin_ws/src) and run the catkin_make,
I run into different errors viz., CMAKE_C_COMPILER, CMAKE_CXX_COMPILER paths.
So I tried to run cmake --help to find the list of generators available, so as to give the aforementioned path of a compiler. This again creates new errors stating No CMAKELists.txt found.
I am a newbie to programming and I don't get any of these.
Can anyone explain why we need this compiler path, generator, etc to build this workspace and how to run ROS successfully on Windows?
Thanks in advance for your support.
C:\opt\catkin_ws>cmake -G "NMAKE Makefiles" CMake Error: Could not
create named generator NMAKE Makefiles
C:\opt\catkin_ws>cmake -G "MSYS Makefiles" CMake Error: CMake was
unable to find a build program corresponding to "MSYS Makefiles".
CMAKE_MAKE_PROGRAM is not set. You probably need to select a
different build tool. CMake Error: CMake was unable to find a build
program corresponding to "MSYS Makefiles". CMAKE_MAKE_PROGRAM is not
set. You probably need to select a different build tool. CMake Error:
CMAKE_C_COMPILER not set, after EnableLanguage CMake Error:
CMAKE_CXX_COMPILER not set, after EnableLanguage CMake Error: CMAKE_AR
was not found, please set to archive program.
-- Configuring incomplete, errors occurred!
I can build my projects successfully with CMake, but can I use it to install the results?
With Make I add the target install and call that from the command line. I cannot figure out if this is possible with CMake.
The final goal is to install a static library, dynamic library and corresponding header files in a platform-portable way. How I imagine it would work: On Linux, copy to /usr/include and /usr/lib. On Windows it would probably be a user-provided folder with an include and lib folder.
The install rule suggests that something like this is possible. But how do I actually use it?
Currently I do the following:
mkdir build
cd build
cmake ..
cmake --build .
Here I would expect to do something like this:
cmake --install .
You can use the command cmake --build . --target install --config Debug for installation.
CMake's build tool mode supports further arguments that are of interest in this case.
You can select the target to build by --target option, the configuration to build by --config option, and pass arguments to the underlying build tool by means of the -- option. See the documentation (Build Tool Mode) for the build-tool-mode.
In CMake 3.15 and newer, you can use the simpler cmake --install command to Install a Project:
cmake --install . --config Debug
It additionally supports --prefix, --component and --strip.
You can use the install command on your CMakeLists that will generate installation rules for your project. A basic example is shown bellow but check the cmake documentation if you need something more complex.
project (Test)
add_executable(test main.cpp)
install(TARGETS test DESTINATION bin)
Then after generate the makefiles you can ust type sudo make install and the test application will be installed on system bin folder.
I am facing a specific problem, and want advice or a way to debug it.
I am building the Allegro library from source, using: Windows 10, CMake, and Visual Studio 2015 build tools (msbuild).
Source: https://github.com/liballeg/allegro5
The problem is that when I run `cmake --build .' I am getting errors stating that the v100 toolset isn't installed, however I'm making it for Visual Studio 2015, and not 2010. If I open up the solution, or run msbuild directly, it builds perfectly fine.
Is there a way to Debug CMake that will help me see the issue?
Failing Commands:
mkdir _build
pushd _build
cmake.exe ..
cmake --build .
popd
Error:
"C:\Users\matthew\repos\allegro5_build\ALL_BUILD.vcxproj" (default
target) (1) ->
"C:\Users\matthew\repos\allegro5_build\ZERO_CHECK.vcxproj" (default
target) (2) -> (PlatformPrepareForBuild target) -> C:\Program Files
(x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Microsoft.Cpp.Platform.targets(55,5):
error MSB8020: The build tools for Visual Studio 2010 (Platform
Toolset = 'v100') cannot be found. To build using the v100 build
tools, please install Visual Studio 2010 build tools. Alternatively,
you may upgrade to the current Visual Studio tools by selecting the
Project menu or right-click the solution, and then selecting "Retarget
solution". [C:\Users\matthew\repos\allegro5
_build\ZERO_CHECK.vcxproj]
Working Commands:
mkdir _build
pushd _build
cmake.exe ..
msbuild ALLEGRO.sln
popd
I've also tried forcing it to Visual Studio 2015 with commands like:
cmake.exe -G "Visual Studio 14" ..
Note: I've built my own small project with CMake and it builds correctly using CMake --build
To me it seems like something crazy with the allegro cmake build. I have searched through the source to try and find references to v100 and MSVC_2010, but found nothing of concern.
I don't want to directly use MSBuild as a work-around because I want to include allegro with ExternalProject_Add, and that fails for the same reason as building it with cmake --build.
How can I go about solving this issue?
I had a similar problem with another library (Zipper, a C++ wrapper around minizip). I was also using CMake and ExternalProject_Add in particular. Exact same error. I spent a lot of time researching the issue. I found a similar problem with another project using Gyp (have a look at the "Known issue" section). For me, the error was occurring during the install target. Changing
BUILD_COMMAND ${CMAKE_COMMAND} --build . --config Release
to
BUILD_COMMAND ${CMAKE_COMMAND} --build . --config Release --target install
INSTALL_COMMAND ""
fixed the issue. Not sure what the problem is. It seems like the default install command CMake uses in an ExternalProject picks the wrong toolset somehow...
I tried to compile a project with cmake, but I got the following error :
mostafa#ubuntu:~/oooark$ cmake .
CMake Error at CMakeLists.txt:19 (message):
In-source builds are not allowed.
For example run:
rm CMakeCache.txt
mkdir build
cd build
cmake ..
make
-- Configuring incomplete, errors occurred!
Can anyone help me ?
Do as the help message says: remove the CMakeCache.txt file, create a subdirectory called build, change into that directory, then re-run cmake from there.
rm CMakeCache.txt
mkdir build
cd build
cmake ..
make
This is because you ran "cmake ." in the top of the source tree. The reason for preventing you running cmake in the source directory is to prevent the source tree getting build artefacts spewed all over it.