As a project user, what do I need to do to make a project with Cmake? - configuration

I'm working with a project that [used to] support both Autotools and Cmake. In the past, I would:
cd project/build
...
../llvm/configure --enable-optimized --enable-cxx11 $OTHER_OPTIONS --prefix=/usr/local
make -j2
sudo make install
The project has kind of abandoned it support for Autotools, so I have to use Cmake now. Using Cmake to configure seems like it should be relatively easy.
Unfortunately, Mac OS X lacks man pages for Cmake, so I can't RTFM. And the search hits I am finding discuss how to build Cmake packages (and other stuff package maintainers would do), and not how to use it as a dumb project user.
I tried to simply use Cmake in place of Configure, but it did not work:
$ cd project/build
$ OTHER_OPTIONS=" --enable-libcpp"; cmake ../llvm --enable-optimized --enable-cxx11 "$OTHER_OPTIONS" --prefix=/usr/local
CMake Error: The source directory ".../clang-3.6/build/--prefix=/usr/local" does not exist.
Why is Cmake treating a configuration option like a directory (--prefix=/usr/local)?
How do I configure and build a project that uses Cmake as a dumb project user?

You're trying to configure a CMake project like it was autotools. The syntax of the command is;
cmake -Doptions -Dmore_options src_dir
src directory is the last argument, which is why it treats --prefix that way. You will need to know the name of the parameters available to you though. If you're new to CMake, your best bet is to run, either the Qt gui or the curses gui ( ccmake /path/to/src while your in the build directory ). Those gui tools will let you pick your options, configure then generate. Then all you need is to type make ....
Note
cmake --help
does provide info even if your man pages aren't installed. Also, if you have access to google and the internet, searching "cmake man page" should give you access the your missing man pages.

Related

How to make a HTML build from raylib

I am a beginner programmer and I was wondering how I would make an HTML build from raylib. I tried looking at the GitHub https://github.com/raysan5/raylib/wiki/Working-for-Web-(HTML5) I couldn't understand it. would you be able to write a simple step-by-step tutorial for me. please
For the very beginning you have to install emscripten SDK. As stated at the site "Emscripten is a complete compiler toolchain to WebAssembly, using LLVM, with a special focus on speed, size, and the Web platform."
Installation steps are prety easy:
git clone https://github.com/emscripten-core/emsdk.git
cd emsdk
git pull
./emsdk install latest
./emsdk activate latest
source ./emsdk_env.sh
After this steps you will have emscripten installed into the directory you've cloned it.
Then, you need to compile raylib itself to be usable in Web:
Go to the raylib/src directory and open Makefile, find where EMSDK_PATH variable is being defined and edit it accordingly to your setup. If you downloaded emscripten into /home/user/emsdk directory then put it in there:
EMSDK_PATH ?= /home/user/emsdk
Fix PYTHON_PATH definition as well.
then launch execute make:
make -e PLATFORM=PLATFORM_WEB -B
Notice -e option. That option allows to propagate and override environment variables to makefile.
Generated libraylib.a is placed in raylib\src\libraylib.a directory.
After that you can cd into raylib/examples/, fix Makefile as described above and launch make -e PLATFORM=PLATFORM_WEB -B again.
After that you would be able to start python3 -m http.server in that directory, navigate to http://0.0.0.0:8000/ in your browser and see examples.

Conda and conda-forge to install commands available from all conda environments

I'd like to install programs with conda in one particular conda environment and to be able to use the associated commands from all conda environments.
My goal is to allow students to install Mercurial (plus few Mercurial extensions and related utilities like Meld and TortoiseHg) on any platforms (especially Windows) with one simple command (or few simple commands), and of course without compilation.
Of course the hg command should be available in the terminal from any conda environments (anaconda prompt on Windows). The Mercurial packages cannot be installed in the base environment because Mercurial still works better in Python 2.7 (anyway, it wouldn't be clean).
Now Mercurial and the extensions we need can be installed on all platforms with something like:
conda create -n py27_mercurial -c conda-forge python=2.7 mercurial dulwich ipaddress
conda activate py27_mercurial
pip install hg-evolve hg-git
Working a bit with conda-forge and a conda meta-package, it won't be difficult to do that with one very simple command. Moreover, it should not be difficult to create conda packages for Meld and TortoiseHg.
From this stage, the hg command is available when the environment is activated (and it is very simple to install other Mercurial extensions). To make it available from other environment (and in the base environment), one need to append the path of the directory containing hg to the environment variable PATH or on Unix to create a symbolic link (I don't know Windows enough to know if something similar would work). Both solutions are not straightforward and the commands are not platform independent.
I didn't find a command to do something like this in conda but sometimes conda experts are able to do impressive things! What would be an elegant solution to this issue?
It would also be nice to create icons somewhere (in the Anaconda launcher?) for the graphical applications (Meld and TortoiseHg). Is it possible?
Edit: Conda applications
I discovered that there is a way to specify in the meta.yaml file that a package is an application: https://docs.conda.io/projects/conda-build/en/latest/resources/define-metadata.html#app-section
It may help to solve the issue.
Edit after a first answer based on a bash function:
Of course, I'm looking for a solution involving very small work (and understanding) for the users and with cross-platform commands.
Note that for Linux and Bash, one can just do:
CONDA_APP_DIR=$HOME/.local/bin/bin-conda-app/
mkdir -p $CONDA_APP_DIR
echo -e "\nexport PATH=\$PATH:$CONDA_APP_DIR\n" >> ~/.bashrc
ln -s $(which hg) $CONDA_APP_DIR/hg
No need to activate/deactivate the environment each time hg is used...
Of course, such solutions dependent of the system and the shell are not satisfactory. It should be possible to do such things with cross-platform conda-like commands (see https://github.com/conda/conda/issues/8556), something like
conda config --add channels conda-forge
conda install conda-app
conda-app install mercurial
Now, I just have to implement conda-app 🙂
One can always create a shell function/alias and shove it in their shell's runtime configuration file. For example, for your use case, I'd add the following in my ~/.bashrc:
hg() {
(conda activate py27_mercurial
command hg "$#"
_hg_exit_code=$?
conda deactivate
exit $_hg_exit_code)
}
Then, regardless of which environment you are in, you always run hg from the environment it was installed in. To make sure that this function is loaded for you shell in a new session, one can always take a look at the output for: type -a hg
I do this one-time-setup for all the tools (some are custom compiled) and have an alias/shell function for each. This way I can happily switch b/w environments without having to worry much.
The solution https://stackoverflow.com/a/55900964/1779806 is buggy for scripts using command hg ... and too inefficient for this case (installation of a command-line application). See https://github.com/conda/conda/issues/8556#issuecomment-488703716
I created a tiny Python package conda-app (https://pypi.org/project/conda-app/) to improve this situation.
This should now works on Unix systems (with Bash and Fish):
conda activate base
conda config --add channels conda-forge
pip install conda-app
conda-app install mercurial
It should not be difficult to improve conda-app to also support Windows.
For the time being, Windows users can install Mercurial and important extensions by installing TortoiseHG.

How do I make Octave see installed Shogun libraries in Ubuntu 16.04?

I copied the commands (from these instructions: http://www.shogun-toolbox.org/install#ubuntu) into the terminal and they seem to have worked, but there is no documentation on how to make Octave find the libraries. I have tried modshogun and init_shogun but Octave cannot find them. I do have the libraries in usr/lib, and I have put that directory on PATH. I have even set usr/lib as my working directory in Octave and that did not help. As far as I have found, there is no Shogun documentation on what to do at this point.
I have also tried compiling Shogun from source, but configure couldn't find GCC. Apparently, this is a known problem with newer versions of GCC. I decided to ask for help with the former method because at least I have the libraries with that.
Edit: I am following the instructions here http://www.shogun-toolbox.org/install#manual-basics
When i do cd build and then "cmake -DINTERFACE_OCTAVE=ON" it tells me there is no cmakelists.txt. There is one in in the above folder, but when I go to that directory and do "cmake -DINTERFACE_OCTAVE=ON" again, it tells me "Shogun can only be built with GPL codes if the source files are in /home/derose/shogun/src/shogun/src/gpl. Please download or disable with LICENSE_GPL_SHOGUN=OFF."
However, when I add -LICENSE_GPL_SHOGUN=OFF as an option, i get the error "CMake Error: The source directory "/home/derose/shogun/src/shogun/-LICENSE_GPL_SHOGUN=OFF" does not exist."
You've linked to the Ubuntu install instructions. From there
These currently do contain the C++ library and Python bindings..
No word that this would include the GNU Octave binding. See below on the same page:
The native C++ interface is always included. The cmake options for building interfaces are -DINTERFACE_PYTHON=ON -DINTERFACE_R .. etc. For example, replace the cmake step above by cmake -DINTERFACE_PYTHON=ON...
So you have to grab the source and fire up cmake with something like -DINTERFACE_OCTAVE=ON
Steps to build the bleeding edge of shogun (the github repo) and the Octave interface:
git clone https://github.com/shogun-toolbox/shogun && cd shogun
git submodule update --init
mkdir build && cd build
cmake .. -DINTERFACE_OCTAVE=ON
make -j4

should I recompile all clang project when I want to add a new checker in Clang StaticAnalyzer?

I follow the steps in the section Checker Registration
in the manual page of clang static analyzer one by one and can not find my checker from the output of the command
clang -cc1 -help | grep "analyzer"
So, I wonder if I should recompile the whole project? That is a burdensome job which I need almost several hours to compile it.
You should be using a build system like ninja or make when compiling llvm/clang. The build system automatically decides which parts need to be recompiled and which parts do not.
As an example, if you follow the steps to build clang here, step number 7 says to run the following commands:
mkdir build (in-tree build is not supported)
cd build
cmake -G "Unix Makefiles" ../llvm
make
From that point forward every time you make changes you only need to re-run the make command from your build folder and make will automatically compile anything that needs to be recompiled.
If you want slightly faster recompile times you can install the ninja build system and use cmake -G "Ninja" ../llvm when first building the project and use the ninja command instead of make from that point forward.

Compiling MySQL 5.7.20 in CentOS 7 Issues (A Lot)

I am trying to setup a MySQL server using CentOS (No GUI) and I need to switch to OpenSSL instead of YaSSL in order to have access to the encryption tools.
The issues happen when runing the cmake. At first I got the error that cmake was not able to find boost, I fixed this adding the parameter -DWITH_BOOST.
The cmake line is as follows.
cmake . -DWITH_READLINE=ON -DWITH_SSL=system -DWITH_BOOST=/usr/local/src/mysql-5.7.20/boost/
After the adjustment I ran again the CMAKE the I got several errors.
SSL Error, cmake can not find the OpenSSL files. I checked if the library was installed, I also downloaded the tar.gz file and decompress it and pointed the cmake to the folder, none of this worked.
Can not find NUMA libraries, again I checked and it is installed, at this point I ran the system update to check for everything but this did not solve the issue.
Can not find the ncurses, the same thing, is on the system but for some reason cmake is not able to find those.
Can not fin libaio, I didn't have this one installed, I installed, ran cmake again, and again cmake was not able to find it.
I been looking around, trying to figure out all this issues, I've been joining information from different websites but still not able to figure out this.
Thanks ahead to everyone for the help.
You're facing the dependencies hell with MySQL. If you don't really need to compile from the sources, you still can install with the RPM which is much easier. The RPM method is described here : https://dev.mysql.com/doc/mysql-yum-repo-quick-guide/en/
As you're asking a ready-to-go install from the sources, this is what I just did and it worked, on a fresh CentOS 7.4 minimal, 2 vcpus 3Gb :
yum group install -y 'Development Tools'
yum install -y cmake ncurses-devel curl
curl -Ovk https://cdn.mysql.com/Downloads/MySQL-5.7/mysql-5.7.20.tar.gz
tar zxf mysql-5.7.20.tar.gz
cd mysql-5.7.20
cmake . -DDOWNLOAD_BOOST=1 -DWITH_BOOST=$HOME/boost -DENABLE_DOWNLOADS=1
make -j2
make install
After that you need to configure it, add the startup scripts, and of course secure it. Here are some additional docs :
http://howtolamp.com/lamp/mysql/5.6/installing/
https://dev.mysql.com/doc/refman/5.7/en/mysql-secure-installation.html
Perhaps try make clean; cmake clean; ldconfig then run your cmake command. Sometimes the system can't find the shared libraries, and ldconfig refreshes the library search path. This helped once when I was compiling something (emscripten?) which required a lot of libraries which I was installing as compilation errors arose.
The make clean; cmake clean will ensure that the compiler isn't looking at the old library search path when you recompile.