When I build shared protobuf (Version 3.15.8) libs with autogen I get libprotoc.so.26:
./autogen.sh
./configure --enable-shared
make
When I build it with cmake I get libprotobuf.so.3.15.8.0.
cd cmake && mkdir build && cd build
cmake -Dprotobuf_BUILD_SHARED_LIBS=on ..
make
Is there a way to build libprotoc.so.26 with cmake? (How can I set the SONAME there?)
You appear to be looking for the SOVERSION property of the shared library target. As far as I am aware, there is no command-line option to affect target properties, so you would need to modify the appropriate CMakeLists.txt file. You'll need to identify the CMake target name chosen for the library (a characteristic of the project, not of CMake itself), say "protobuf_lib". You would then add a command of the form
target_set_properties(protobuf_lib
PROPERTIES SOVERSION 26)
Alternatively, if there is already a target_set_properties command for the target in question, you could add the SOVERSION 26 to the property list in that command.
Related
I'm building a multi-binary project with cmake and deploying in Debian. CMakeLists.txt reduces down to something like this:
add_library(mylib SHARED lib.cpp) #creates libmylib.so
add_executable(myapp main.cpp)
target_link_libraries(myapp my-lib)
install(TARGETS mylib myapp
RUNTIME DESTINATION bin
LIBRARY DESTINATION lib
)
If I install this to (-DCMAKE_INSTALL_PREFIX=/usr) then I have no problem. But if I install to somewhere else like (-DCMAKE_INSTALL_PREFIX=/opt/myapp, or even -DCMAKE_INSTALL_PREFIX=/usr/local), then I have a problem.
When I run $ /opt/myapp/bin/myapp my application can't find the .so.
I could deploy a script with myapp which sets:
#!/bin/sh
export LD_LIBRARY_PATH=${CMAKE_INSTALL_PREFIX}/lib:$LD_LIBRARY_PATH
exec ${CMAKE_INSTALL_PREFIX}/bin/myapp $*
But this feels like a hack. Plus, the script would need to be generated at configure time with ${CMAKE_INSTALL_PREFIX}/lib.
I imagine that there's a more native way to handle this which lets me simply execute my application from /opt or /usr/local after installation. It would preferably handle this at configure, compile, or install time instead of just before runtime and preferably wouldn't require someone to modify their ~/.bashrc or ~/.profile.
Could you please tell me if there is some way to deploy the standard bin,lib structure in linux to arbitrary paths without the need for pre-runtime scripting?
You should:
use rpath (Unix) or loader_path (MacOS)
or install it in regular system path (/usr/lib or /usr/local/lib etc...)
or use LD_LIBRARY_PATH.
Example to set RPATH:
if(APPLE)
set(CMAKE_INSTALL_RPATH "#loader_path/../lib;#loader_path")
elseif(UNIX)
set(CMAKE_INSTALL_RPATH "$ORIGIN/../lib:$ORIGIN/")
endif()
note: on macos you should now use #rpath
note2: on macos you can use otool -l and otool -L to introspec.
note3: you can use ldd lib.so and objdump -p lib.so on GNU/Linux.
Note: Prefer to use GNUInstallDirs
include(GNUInstallDirs)
install(TARGETS ${PROJECT_NAME}
INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
)
I'm trying to configure GCC 4.7.2, but it's failing with configure: error: Unable to find a usable PPL
I've looked in GCC prerequisites page and PPL isn't mentioned anywhere.
I'm using CLooG 0.17.0, which uses ISL, and as such no longer requires PPL (as far as I can tell)
Is there some other requirement on PPL in GCC which means I still need PPL, or am I missing some flag from my configure line?
I am passing the following options to configure:
--enable-cloog-backend=isl
--with-cloog=$PREFIX
--with-isl=$PREFIX
--with-gmp=$PREFIX
--with-mpfr=$PREFIX
--with-mpc=$PREFIX
For completeness, my full configure line is as follows:
./configure --prefix=/hostname/tmp/syddev/sdk/gcc472/suse11/x86_64 \
--disable-multilib --enable-cloog-backend=isl \
--with-mpc=/hostname/tmp/syddev/sdk/gcc472/suse11/x86_64 \
--with-mpfr=/hostname/tmp/syddev/sdk/gcc472/suse11/x86_64 \
--with-gmp=/hostname/tmp/syddev/sdk/gcc472/suse11/x86_64 \
--with-isl=/hostname/tmp/syddev/sdk/gcc472/suse11/x86_64 \
--with-cloog=/hostname/tmp/syddev/sdk/gcc472/suse11/x86_64 \
--build=x86_64-suse-linux --with-pkgversion='SIG build 11/27/2012' \
--with-gxx-include-dir=/hostname/tmp/syddev/sdk/gcc472/suse11/x86_64/include/c++/4.7.2 \
--enable-version-specific-runtime-libs
Update:
In order to try make forward progress I decided to add PPL to my installation list, and add --with-ppl=$PREFIX to my configure line.
Configure still fails with configure: error: Unable to find a usable PPL
It seems this is a bug in the configure script: Configure fails if PPL_MINOR_VERSION < 11
With the latest version PPL_MINOR_VERSION=0 (and PPL_MAJOR_VERSION=1)
The GCC Prerequisites page jumped the gun and is showing the prerequisites for GCC 4.8.
GCC 4.7.2 still uses PPL instead of ISL, as evidenced by the lack of --with-isl=PATH in the output of configure:
Optional Packages:
--with-PACKAGE[=ARG] use PACKAGE [ARG=yes]
--without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no)
--with-build-libsubdir=DIR Directory where to find libraries for build system
--with-mpc=PATH specify prefix directory for installed MPC package.
Equivalent to --with-mpc-include=PATH/include plus
--with-mpc-lib=PATH/lib
--with-mpc-include=PATH specify directory for installed MPC include files
--with-mpc-lib=PATH specify directory for the installed MPC library
--with-mpfr-dir=PATH this option has been REMOVED
--with-mpfr=PATH specify prefix directory for installed MPFR package.
Equivalent to --with-mpfr-include=PATH/include plus
--with-mpfr-lib=PATH/lib
--with-mpfr-include=PATH
specify directory for installed MPFR include files
--with-mpfr-lib=PATH specify directory for the installed MPFR library
--with-gmp-dir=PATH this option has been REMOVED
--with-gmp=PATH specify prefix directory for the installed GMP
package. Equivalent to
--with-gmp-include=PATH/include plus
--with-gmp-lib=PATH/lib
--with-gmp-include=PATH specify directory for installed GMP include files
--with-gmp-lib=PATH specify directory for the installed GMP library
--with-host-libstdcxx=L use linker arguments L to link with libstdc++ when
linking with PPL
--with-stage1-ldflags=FLAGS
linker flags for stage1
--with-stage1-libs=LIBS libraries for stage1
--with-boot-libs=LIBS libraries for stage2 and later
--with-boot-ldflags=FLAGS
linker flags for stage2 and later
--with-ppl=PATH specify prefix directory for the installed PPL
package. Equivalent to
--with-ppl-include=PATH/include plus
--with-ppl-lib=PATH/lib
--with-ppl-include=PATH specify directory for installed PPL include files
--with-ppl-lib=PATH specify directory for the installed PPL library
--with-cloog=PATH Specify prefix directory for the installed CLooG-PPL
package. Equivalent to
--with-cloog-include=PATH/include plus
--with-cloog-lib=PATH/lib
--with-cloog-include=PATH
Specify directory for installed CLooG include files
--with-cloog-lib=PATH Specify the directory for the installed CLooG
library
--with-build-sysroot=SYSROOT
use sysroot as the system root during the build
--with-debug-prefix-map='A=B C=D ...'
map A to B, C to D ... in debug information
--with-build-config='NAME NAME2...'
use config/NAME.mk build configuration
--with-build-time-tools=PATH
use given path to find target tools during the build
It's unfortunate that they don't maintain prerequisites pages for versions prior to 4.8.
Generally to install a package on a linux-based operating system you use
./configure
make
make install
How does this work? And how do I create a package that can be installed this way?
My application uses the Qt framework and I think I'm aiming for something like "MyPackage.tar.gz"
You can create a debian package from your projects. As I understood you want to create a package intended for distibution so I would suggest creating a debian package from your project. Here is an introduction for Debian Packaging system. In the article they at some point describe how to create a "rules" file which is at the core of the build process. Here is a sample of it that I typically use for my Qt/KDE projects:
#!/usr/bin/make -f
#export DH_VERBOSE=1
# This is the debhelper compatability version to use.
#export DH_COMPAT=3
DESTDIR=$(CURDIR)/debian/project
TR_DIR=$(CURDIR)/debian/project/usr/share/qt4/translations
configure:
qmake project.pro
clean:
dh_testdir
dh_testroot
dh_clean
build: configure
dh_testdir
lrelease translations/project_en.ts
$(MAKE)
install: build
mkdir -p $(TR_DIR)
cp translations/project_en.qm $(TR_DIR)
$(MAKE) INSTALL_ROOT=$(CURDIR)/debian/project install
dh_installdirs
binary-arch: build install
dh_testdir
dh_testroot
dh_installmenu
dh_link
dh_strip
dh_compress
dh_fixperms
dh_installdeb
dh_shlibdeps
dh_gencontrol
dh_md5sums
dh_builddeb
This is normally sufficent for small projects.
configure is usually part of GNU build system (autotools), which is not in use in a typical Qt project. qmake is used instead for build file generation and it internally handles most of the tasks configure does for non-qt projects.
The typical build install process for a Qt application is
qmake
make
make install
You could create a simple ./configure script that calls qmake if you need the command names to be identical. You can also use autotools with Qt if you need it, see e.g. Qt Creator Instructions For Autotools
Qt is often used with CMake, which I highly recommend. One notable point is that it likes out-of-source-builds.
Your configure script could be
#!/bin/bash
(mkdir build; cd build; ccmake ..)
and the makefile could be
#!/bin/bash
(cd build; make)
Newer versions of debhelper support qmake. A rules file like,
#!/usr/bin/make -f
%:
dh $# --buildsystem=qmake
Is all that is needed. You need,
bar.file = foo
bar.path = install/dir
INSTALLS += bar
Inside your projects 'pro' or qmake file. qmake will create install targets and the perl file /usr/share/perl5/Debian/Debhelper/Buildsystem/qmake.pm will get called and parse the qmake file. You need to create 'debian/' files, changelog, compat, control, copyright as well the rules file.
I'm trying to install GCC into /my/custom/path/gcc
but for some reason it installs into the normal installation path.
the commands i'm using:
configure --target=i686-pc-linux-gnu --disable-nls --enable-languages=c,c++ --without-headers
make DESTDIR=/my/custom/path/gcc
make DESTDIR=/my/custom/path/gcc install
What am I doing wrong?
You should run (in a new build tree outside of the source tree)
/your/source/path/to/gcc/configure --target=i686-pc-linux-gnu --prefix=/my/custom/path/gcc ...
and then GCC will become installed in /my/custom/path/gcc/bin/ with include files in /my/custom/path/gcc/include/, libraries in /my/custom/path/gcc/lib/ etc etc
I suggest using /opt/ or $HOME/pub as your prefix and you might also be interested by the --program-suffix=-foo option
(do that in a fresh new build tree outside of the source tree; your previous one is rotten)
After successive compilation with make, you can run in your build tree
make install DESTDIR=/tmp/mygccinst/
and finally, you can copy the definitive files with something like
cp -va /tmp/mygccinst/ /
You may need to run this copy as root...
PS the installation prefix is built-in the gcc driver binary, which actually runs cc1 or cc1plus etc...
How can I store GNU make & configure files elsewhere? I have a project I am working on that I get compiled using:
./configure --prefix=/usr && make && su -c 'make install'
The thing is I don't want to pollute the current folder, which is a svn/git/hg/whatever sandbox with files generated by that command. I want to put those files in a separate location. I don't know if it's similar, but when I compile the linux kernel from source, I can specify where to put the ouput by passing the 'O' option to 'make', something like this:
make O=/home/user/linux-output
The Makefile must support this feature.
I think the autoconf generated makefiles all support the following use:
mkdir ../build
cd ../build
../configure --prefix=/usr
make
make install
(It's certainly recommended for gcc builds).
As Kristof already pointed out, GNU autotools inherently support out out-of-tree builds at the configure level.
So you can have the Makefile and built binaries out of the source tree trivially.
To get all the auto-generated artefacts out of the source tree requires much more work however.
We have a script that copies changes from a source tree into a working_copy, carefully preserving the configure script etc in the working_copy, which allows the original source tree to be pristine. However it's very inefficient, so I wouldn't recommend it.
I would recommend a normal out-of-tree build, and then explicitly excluding the remaining auto-generated files in the source tree.