When building any library from sources files, is it possible to set the place where I want it to be installed? I have read about some prefix flag, but I was wondering if all aplications have that flag.
For instance, I was building OpenCV from sources and when I made make && make install the contents where installed in /usr/local/opencv but what If I want it to be installed in /other/place/opencv?
If I follow you correctly, that stuff is done during the configure phase with something like:
$ ./configure --prefix=/other/place/opencv
If the project doesn't have a configure script then it's a case of editing the Makefile directly.
Related
I cross compiled a library on Ubuntu, and I copied the build directory to my Raspberry pi. However, it won't let me do make install on raspberry pi because all the paths are according to my Ubuntu system not raspberry pi's. Is there a command to change that quickly? Thanks
it depends entirely on the build system of the library itself. if it's autotools based, you can often override specific vars like:
make install prefix=/usr bindir=/bin ...
the automake manual documents a bunch of these standard variables.
if it's not autotool based, then you'll have to read the Makefile directly to see how it can be installed. maybe it respects DESTDIR ?
make install DESTDIR=/some/other/place
I need to manually compile and install FFMPEG as one of my dependencies using Puppet manifests. I want to do this myself to customize the configuration of FFMPEG to the needs of my project.
I'm not sure as to how to structure the entire process with classes. The logic should go something like this:
If /usr/local/bin/ffmpeg doesn't exist, compile:
Install build dependencies from apt-get.
Create a directory for the library sources /tmp/ffmpeg
Download and compile the Yasm assembler
Download.
Extract.
Configure
Make
Make Install
Download and compile x264
Clone the source.
Configure.
Make
Make Install
Download and compile fdk-aac:
...
....
I can easily branch all of these out into their own modules and declare them as dependencies of FFMPEG, that's not the problem.
My main problem is understanding how to do the whole download/extract/compile process for each module only if it's not already present on the system.
How do I structure my classes to only act if the software is not already installed?
Regardless of how you go about it, you need a way to check whether your custom installation has been installed.
Common methods include
checking a file and running a command only if it is not present: http://docs.puppetlabs.com/references/latest/type.html#exec-attribute-creates
running a command only if another command returns 0: http://docs.puppetlabs.com/references/latest/type.html#exec-attribute-onlyif (alternatively, the unless attribute)
I am developing two libraries A and B with B depending on A, both managed in their own Git repositories. The libraries are built with CMake and installed in standard UNIX directories. During installation a .pc file is also installed that is used by pkg-config. Library B uses pkg-config to find library A, therefore it is necessary that either library A is installed system-wide with make install or the PKG_CONFIG_PATH is set to the appropriate directory.
Now, I use Jenkins to build library A on a remote machine. Unfortunately, library B cannot be built because the dependency is not met (pkg-config cannot find library A). Setting the paths in a pre-build step is not working because the commands are run in its own shell.
The questions are
Can I somehow make install library A? Or,
can I somehow point CMake to /var/lib/jenkins/jobs/libA/install_dir/lib?
Is there a better way to build projects with inter-dependent libraries?
To answer your questions in order:
To make install library A - You can configure the Jenkins job that builds library A to archive the library as a build artefact. Then the job to build library B can download the artefact from Jenkins at the start of the run – e.g. http:///job/libA/lastSuccessfulBuild/artifact/
Once the library B job has collected library A it can then be installed and used.
Configuring Cmake – I don't know enough about cmake so I'm afraid I can't answer that.
Is there a better way – Possibly using Rake, we use it to control a build chain with lot's of dependencies. Although I'm not sure how well it would work if library A has to be built on a remote machine. Things might be simpler to manage if both libraries are build on the same machine.
Using artifacts, as suggested by user1013341, is one of the steps that was needed to this problem. But to get it working with pkg-config we have to do a little bit more:
I setup library A's CMakeLists.txt to produce a tarball with make package_source.
After a successful build of library A, Jenkins create this tarball and stores it as an artifact.
library B uses the Copy Artifact Plugin to get the tarball and untars it. Inside of the tarball there is still built project and the .pc file pointing to the install location of library A.
In the next build step, I use the EnvInject Plugin to set the PKG_CONFIG_PATH and the LD_LIBRARY_PATH to the untarred library A.
Last but not least, the normal CMake build process can be started and the correct paths are picked up according to the environment variables.
I am writing a shared library for GNU/Linux, which will install for now with "sudo make install". I have CMake recipes to create the files and install them in '/usr/local/lib/app', and the libraries and links are created correctly.
But the library path is not updated and I must run "sudo ldconfig /usr/local/lib/app' manually to make the library available.
Several other packages on my system put their libraries in a specific folder under /usr/local/lib, so I am assuming that's proper.
How then to have CMake update the library path for the system as well as create the files and install them? What is the proper way to do this?
I'd also like it accomplished so that the library path update survives a system restart.
Thanks,
bcw
I'd also like it accomplished so that the library path update survives a system restart.
I'm not aware of any CMake-specific facility. However, you should be able to add rules such as the following in order to make the change persistent.
echo "/usr/local/bret/lib" > /etc/ld.so.conf.d/bret-i386.conf
echo "/usr/local/bret/lib64" > /etc/ld.so.conf.d/bret-x86_64.conf
/sbin/ldconfig
You'll still need to re-run the ldconfig when you overwrite files in bret/lib{,64}.
I want to install multiple versions of a package (say libX) from src. The package (libX) uses Autotools to build, so follows the ./configure , make, make install convention. The one installed by default goes to /usr/local/bin and /usr/local/lib and I want to install another version of this in /home/user/libX .
The other problem is that libX is a dependency for another package (say libY) which also uses autotools. How to I make libY point to the version installed in /home/user/libX ? There could be also a possibility that its a system package like ffmpeg and I want to use the latest svn version for my src code and hence build it from src. What do i do in that case ? What is the best practice in this case so that I do not break the system libraries?
I'm using Ubuntu 10.04 and Opensuse 10.3.
You can usually pass the --prefix option to configure to tell it to install the library in a different place. So for a personal version, you can usually run it as:
./configure --prefix=$HOME/usr/libX
and it will install in $HOME/usr/libX/bin, $HOME/usr/libX/lib, $HOME/usr/libX/etc and so on.
If you are building libY from source, the configure script usually uses the pkg-config tool to find out where a package is stored. libX should have included a .pc file in the directory $HOME/usr/libX/lib/pkgconfig which tells configure where to look for headers and library files. You will need to tell the pkg-config tool to look in your directory first.
This is done by setting the PKG_CONFIG_PATH to include your directory first.
When configuring libY, try
PKG_CONFIG_PATH=$HOME/usr/libX/lib/pkgconfig:/usr/local/lib/pkgconfig ./configure
man pkg-config should give details.