I'm trying to install some programme on an Amazon Linux 2 distribution and for some reason, I've to compile a bunch of tools from source.
It was my understanding I should do:
cd my_source_code
./configure
make
make install
The intent would be:
./configure will check if I have all tools needed
make: will compile the source files into binaries that I can then use
make install: will place that said binaries in an accessible place
All of that tools ask me to do different stuff, for example:
./bootstrap
make
make install
or
./bootstrap.sh
./b2
./b2 install
or
cmake .
make
make install
I guess the ./boostrap is just the ./configure script with a different name. Is that right?
For the cmake, why do I have to do both cmake and make? Aren't they the same?
I a bit lost with all that possibilities.
Yes, cmake . is a configuration step and corresponds to ./configure from Autotools. In result of running this command you get whatever build files you have requested - Makefiles of various sorts, Visual Studio projects, etc.
After that you need to actually build them. In case of Makefiles you run make and in case of Visual Studio you open it in the IDE and click "Build" (or run msbuild, if you want console).
CMake has --build flag to automatically invoke underlying build system, so you can also do
# configure
cmake .
# build
cmake --build .
CMake is equivalent to running ./configure but is autoconf and automake combined into a single program. It is automake which generates the Makefiles. CMake started on Windows and can not only generate Unix Makefiles but also Visual Studio projects and some other targets.
Make is very low level and doesn't directly support a recursive build that traverses a directory structure. CMake and Automake are Makefile generators that provide a higher level of abstraction and provide a mechanism to create a recursive build.
./bootstrap in general has the steps to create the configure script which is usually not in the git repo because it is generated. When a source tarball is created the configure script is included for convenience.
Related
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.
So.
Coming from
OpenJPEG installation
The build method maintained by OpenJPEG is CMake.
UNIX/LINUX - MacOS (terminal) - WINDOWS (cygwin, MinGW)
To build the library, type from source tree directory:`
mkdir build
cd build
cmake .. -DCMAKE_BUILD_TYPE=Release
make
https://github.com/uclouvain/openjpeg/blob/master/INSTALL.md
After properly getting Cmake to build, mingw-get to get msys-make (and also msys 1.0) to even have a proper response from MingW64, no matter what I do, I am stuck in the same error.
Downloaded first from the openjpeg-v2.3.1-windowsx64 link which the above proceeding seems to do nothing, as there is no CMakeList file there, then from the 'Source Code' openjpeg-2.3.1 which I can build from but that's it.
Can't make, can't install, can't use.
Considered 'source tree folder' the downloaded folder itself, the src folder inside of it and even a src folder of a IntelliJ project.
What am I missing?
PATH VARIABLE: %USERPROFILE%\AppData\Local\Microsoft\WindowsApps;
%IntelliJ IDEA Community Edition%;
C:\Users\Ajna\Desktop\jar2app\jar2app\jar2app_basefiles;
C:\Program Files\CMake\bin;
C:\Program Files\Git\mingw64\bin;
C:\MinGW\bin;
C:\Program Files\ffmpeg-4.2.1-win64-static\bin;
C:\msys\1.0\bin;
I've spent quite a while with this myself today. Here's what worked for me.
Download the whole code folder (green download code button) from
https://github.com/uclouvain/openjpeg
The downloaded folder is called "openjpeg-master". Save it in your downloads folder.
Install MinGW from https://www.ics.uci.edu/~pattis/common/handouts/mingweclipse/mingw.html
Install msys from
https://sourceforge.net/projects/mingw/files/MSYS/Base/msys-core/msys-1.0.11/MSYS-1.0.11.exe/download?use_mirror=altushost-swe
Open windows command line.
Navigate to the location of the "openjpeg-master" folder
e.g.
cd C:\#insert_location_of_your_downloads_folder#\Downloads\openjpeg-master
To specify the use of MinGW makefiles on windows use the following command
mkdir build
cd build
cmake -G "MinGW Makefiles" .. -DCMAKE_BUILD_TYPE=Release
make
The default for cmake on Windows is to use a Visual Studio generator: it generates project files for use with Visual Studio, not makefiles.
If you want it to generate makefiles you have to tell it specifically:
cmake -G 'Unix Makefiles' .. -DCMAKE_BUILD_TYPE=Release
You probably want to file an issue with the project and ask them to update their INSTALL file to have proper instructions.
I want to compile my program on our university HCP server, I created it as a CMake project on my laptop but the server does not have CMake installed and I can not install it (limited storage).
How do I compile the project on the server without CMake and only make?
I ran cmake command on my laptop and then transferred the sources and generated Makfile to the server, but when I execute make on the server it complains about cmake missing:
make: /usr/local/bin/cmake: Command not found
make: *** [cmake_check_build_system] Error 127
Is it possible to generate a Makefile that can run only make and does not need CMake installed?
This is not possible, for two major reasons:
As pointed out in the comments, the generated Makefiles will again attempt to call CMake during the build.
Besides that, Makefiles generated by CMake are not supposed to be portable. A Makefile generated on one machine is likely to break when copied to another.
Note that CMake has no mandatory external dependencies, so you should be able to quickly build a local copy from source on the server and use that to build your project. If that is for whatever reason not feasible, you cannot use CMake and will have to rely on a different method for building, like writing your own ad-hoc Makefile from scratch.
I'm evaluating CLion 1.2.1 on an existing project which is already using CMake. The project is made up of a few library modules and a single executable.
I have an install target which I use to collect the executable and a configuration file together in a bin folder for debugging:
...
install(TARGETS ${PROJECT_NAME} DESTINATION ${CMAKE_BINARY_DIR}/bin/)
install(FILES config.xml DESTINATION ${CMAKE_BINARY_DIR}/bin/)
When building on the command line I'd just run:
make install
which as expected builds the binaries and if successful then runs the above install commands.
My problem is that I can't get CLion to run the 'install' target. I expected to be able to create a new Run/Debug configuration but the Target: dropdown only contains those targets added using add_executable() and add_library().
I also tried adding 'install' to the Build options in the Settings dialog. That however runs install for every target now including 'clean' which is not right.
UPDATE: As of 2018.1 EAP, build 181.3741.16, CLion supports running cmake install if your project defines install targets:
(source: cloudfront.net)
Original Answer:
I don't think that CLion implements this feature yet. However, you can work around this limitation by adding a CMake "custom target" (using add_custom_target()) that will execute the make install command:
add_custom_target(install_${PROJECT_NAME}
$(MAKE) install
DEPENDS ${PROJECT_NAME}
COMMENT "Installing ${PROJECT_NAME}")
Now, all you have to do is "build" the install_YOUR_PROJECT_NAME target from the "targets" menu in CLion.
Update:
A more cross-platform technique might be the following:
add_custom_target(install_${PROJECT_NAME}
"${CMAKE_COMMAND}" --build "${CMAKE_BINARY_DIR}" --target install
DEPENDS ${PROJECT_NAME}
COMMENT "Installing ${PROJECT_NAME}")
#maddouri 's comment already addresses your question. Alternatively, Under Settings -> Build, Execution, Deployment -> CMake, you can also set Build Option for Debug or Release build type to something like -j 2 install. With this setting, whenever CLion builds the code, it will install your targets, too!
How can I integrate SCIP with MinGW and Msys?
Whilst you are waiting for a real answer, I can already guide you to this page from the official site on how to build SCIP (see below). For actual integration there is a pointer in the faq:
How do I construct a problem instance in SCIP?
First you have to create a SCIP object via SCIPcreate(), then you
start to build the problem via SCIPcreateProb(). Then you create
variables via SCIPcreateVar() and add them to the problem via
SCIPaddVar(). The same has to be done for the constraints. For
example, if you want to fill in the rows of a general MIP, you have to
call SCIPcreateConsLinear(), SCIPaddConsLinear() and additionally
SCIPreleaseCons() after finishing. If all variables and constraints
are present, you can initiate the solution process via SCIPsolve().
Make sure to also call SCIPreleaseVar() if you do not need the
variable pointer anymore. For an explanation of creating and releasing
objects, please see the doxygen documentation.
NOTE: See the directories "examples/MIPsolver/" and "examples/Queens/" for simple examples
Remarks on Building/Installing under Windows using MinGW (from http://scip.zib.de/doc/html/INSTALL.php)
To build your own Windows binaries under Windows, we recommend using
the MinGW-Compiler with MSYS from mingw.org
First install MSYS, then MinGW to the mingw folder inside the msys
folder. Now you need to install the following packages to the mingw
folder:
- zlib (or use ZLIB=false ZIMPL=false since zlib is needed for ZIMPL and ZIMPL-support in SCIP)
- pcre (or use ZIMPL=false since pcre is needed for ZIMPL and ZIMPL-support in SCIP)
- gmplib (or use ZIMPL=false since gmplib is needed for ZIMPL and ZIMPL-support in SCIP)
(After calling "make clean" in the ZIMPL folder you will also need
flex and bison to remake ZIMPL. We recommend NOT to use "make clean"
inside the ZIMPL-folder if you do not have these packages installed.)
You can download these additional packages as precompiled binaries for
example from: http://gnuwin32.sourceforge.net/packages.html
(zlib&pcre) http://cs.nyu.edu/exact/core/gmp/ (gmplib) or compile the
source on your own from the project homepages: http://www.zlib.net/
http://www.pcre.org/ http://www.gmplib.org/ (The command "./configure
--prefix=/mingw ; make ; make install" should succeed without problems and installs the packages into the mingw folder.)
Now "make READLINE=false" should be compiling without errors. Please
note that we do NOT support creating the doxygen documentation or
readline-usage under Windows.
Since there are no real symlinks in MSYS, the include and library
files of SoPlex and ZIMPL are actually copied into the
SCIP-lib-folder. When you recompile ZIMPL or SoPlex after compiling
SCIP you have to copy the libraries manually into the SCIP-lib-folder
and recompile SCIP afterwards.