What's the difference between the various kernel-debug*.rpm files created after rpmbuild? - linux

I build Fedora Linux kernel (rpmbuild -bb --target=`uname -m` kernel.spec) according to this guide, and now I have among others:
kernel-debug-debuginfo-3.18.6-100.myself.fc20.x86_64.rpm (~360MB)
kernel-debuginfo-3.18.6-100.myself.fc20.x86_64.rpm (~360MB)
kernel-debuginfo-common-x86_64-3.18.6-100.myself.fc20.x86_64.rpm (~51MB)
kernel-debug-3.18.6-100.myself.fc20.x86_64.rpm (~67MB)
kernel-debug-devel-3.18.6-100.pae_sw_tal.fc20.x86_64.rpm (~10MB)
some others...
What's the difference between them and which one should I install if I want a development (debug-able build) version?

Basically you can find following information on rpmfind.net
just put kernel-debug-debuginfo in the search and it will tell you what it is.
Similarly for other packages.
for e.g.
kernel-debug-debuginfo-3.18.6-100.myself.fc20.x86_64.rpm
This package provides debug information for package kernel-debug. This is required to use SystemTap with kernel-debug-3.18.6-100.myself.fc20.x86_64.rpm
And I think you need kernel-debug-3.18.6-100.myself.fc20.x86_64.rpm (~67MB)
look at the options of rpmbuild for creating less files. Options like --without devel --without debuginfo

Related

How to build libcurl-gnutls.so from source code

Where can I find the source code and instructions for building libcurl-gnutls.so?
I'm working on a project that needs libcurl-gnutls.so. I am required to build it from source code - I am not allowed to simply install it with "apt-get install libcurl". Unfortunately, my google-fu is failing me and I can't find a source code repository or instructions to build libcurl-gnutls.so anywhere.
Here's what I have found:
Linux-from-scratch has well-documented instructions for building libcurl.so, here: https://www.linuxfromscratch.org/blfs/view/svn/basicnet/curl.html. That lets me build libcurl.so with gnutls, but not libcurl-gnutls.so.
The curl website (curl.se), has detailed instructions on its various options here: https://curl.se/docs/install.html. Those show me how to build libcurl with gnutls, but the end product is still libcurl.so, not libcurl-gnutls.so.
When I run ldd -r on my project, it identifies the functions it needs (curl_easy_init, curl_easy_setopt, curl_easy_perform, and curl_easy_cleanup). I can find those symbols in both libcurl.so and a pre-built libcurl-gnutls.so. This leads me to suspect that libcurl-gnutls.so is libcurl.so, published under a different name. However, renaming libcurl.so to libcurl-gnutls.so is not sufficient to meet the dependency requirements. I could try altering the libcurl project to set its name and version to libcurl-gnutls (not that I know how to do it - I would poke around until I figure it out), but I don't know how appropriate that would be.
I found one other question on Stack Overflow about libcurl-gnutls (How to create lib curl-gnutls.so.4), but the answers to that are to install a pre-built version via apt-get install, which I am not allowed to do.
libcurl-gnutls.so actually just comes from a cURL built with gnutls support. You can find the repository here: https://github.com/curl/curl
Check out the docs/INSTALL.md. It has all the information you need to build cURL, specifically the part about Building from git.
Here is a snippet you might need:
./configure --with-openssl [--with-gnutls --with-wolfssl]
make
make test (optional)
make install
Here's a complete answer cobbled together from everyone's input (Thanks especially to Knud Larsen and Wassim Dhif):
libcurl-gnutls.so is just libcurl.so built with gnutls support. Archives for the project are here: https://curl.se/download
Change the SONAME that libcurl.so is built with by editing ltmain.sh to change:
if test -n "$soname_spec";
then eval soname=\"$soname_spec\"
To:
if test -n "$soname_spec"; then
soname=libcurl-gnutls.so.4
I'm sure there's a more elegant way to do it, but this works and I need to move on.
Alternatively, you can modify the the SONAME after libcurl.so is built with:
patchelf –set-soname libcurl-gnutls.so.4 libcurl.so
Check your client (the program or shared library that requires libcurl-gnutls.so as a dependency), to see if it requires version information.
For instance, when I run objdump -p myprogram, I get this:
Version References:
required from libcurl-gnutls.so.4:
0x0b103d23 0x00 14 CURL_GNUTLS_3
To build libcurl-gnutls.so with this version information:
2a. Set the version information to version 3:
In lib/libcurl.vers.in change:
CURL_#CURL_LT_SHLIB_VERSIONED_FLAVOUR#4
To:
CURL_#CURL_LT_SHLIB_VERSIONED_FLAVOUR#3
2b. Use --enable-versioned-symbols when configuring the libcurl project. This adds the required version information.
./configure --with-gnutls --enable-versioned-symbols [other arguments as needed]
The final product may be named libcurl.so, but can be renamed. It will have its SONAME set to libcurl-gnutls.so.4 and will have the required version information.

arm-none-eabi-objdump: error while loading shared libraries: libdebuginfod.so.1: cannot open shared object file

If you have an answer for this, or further information, I'd welcome it. I'm following advice from here, to offer some unsolicited help by posting this question then an answer I've already found for it.
I have a bare-metal ARM board for which I'm building a cross-toolchain, from sources for GNU binutils, gcc and gdb, and for SourceWare's Newlib. I got those four working and cross-built a DoNothing.c into an ELF file - but I couldn't disassemble it with this:
$ arm-none-eabi-objdump -S DoNothing.elf
The error was:
$ arm-none-eabi-objdump: error while loading shared libraries: libdebuginfod.so.1: cannot open shared object file: No such file or directory
I'll follow up with a solution.
The error was correct - my system didn't have libdebuginfod.so.1 installed - but I have another cross-binutils, installed from binary for a different target, and its objdump -S works fine on the same host. Why would one build of objdump complain about missing that shared library, when clearly not all builds of objdump need it?
First I tried rebuilding cross binutils, specifying --without-debuginfod as a configure option. No change, which seems odd: surely that should build tools that not only don't use debuginfod but which don't depend on it in any way. (If someone can answer that, or point out what I've misunderstood, it may help people.)
Next I figured debuginfod was inescapable (for my cross-tools built from source at least), so I'd install it to get rid of the error. It's a component of the elfutils package, but installing the latest elfutils available for my Ubuntu 20.04 system didn't bring libdebuginfod.so.1 with it.
I found a later one, for Arch Linux, whose package contents suggested it would - but its package format doesn't match Ubuntu's and installing it was going to involve a lot of work. Instead I opted to build it from the Arch Linux source package. However, running ./configure on that gave a couple of infuriatingly similar errors:
configure: checking libdebuginfod dependencies, --disable-libdebuginfod or --enable-libdebuginfo=dummy to skip
...
configure: error: dependencies not found, use --disable-libdebuginfod to disable or --enable-libdebuginfod=dummy to build a (bootstrap) dummy library.
No combination of those suggestions would allow configure for elfutils-0.182 to run to completion.
The problem of course was my own lack of understanding. The solution came from the Linux From Scratch project: what worked was to issue configure with both of the suggested options, like this:
$ ./configure --prefix=/usr \
--disable-debuginfod \
--enable-libdebuginfod=dummy \
--libdir=/lib
That gave a clean configure; make worked first time, as did make check and then sudo make install which of course installed libdebuginfod.so.1 as required. I then had an arm-none-eabi-objdump which disassembles cross-compiled ELF files without complaining.

Trouble compiling ncurses-st-menu for BSD

I found a package on github (https://github.com/okbob/ncurses-st-menu) and am having trouble compile it for BSD platforms like NetBSD or OpenBSD. The instructions say to do ./autogen.sh, ./configure, and then make. So I install the autoconf, autotools, libtool, gettext, and any other necessary packages and run ./autogen.sh. It works without spitting out any errors. But ./configure says it doesn't support "OS x86_64-unknown-netbsd9.0" if for example on NetBSD. Can someone else try to compile this program? Because if this was done by autotools, it certainly should support any of the four major BSD operating systems.
I created a port for FreeBSD here, maybe it will help you get it running on NetBSD. The most important part is the removal of the AC_MSG_ERROR(["OS $host_os is not supported"]) line from tools/ax_pdcurses.m4, then touching config.make, calling autogen.sh to re-generate the configure script. It's also important to set CFLAGS properly and have the appropriate dependencies installed. Also, I used gmake rather than patch the Makefile since I didn't feel motivated to fix it completely.
I don't know the autogen/config tools,
but if you look the configure file:
https://github.com/okbob/ncurses-st-menu/blob/master/configure
lines 4245-4269 only checks for linux,cygwin,mingw.
For other OS gives the error: OS $host_os is not supported

How to tell Autotools Build System (Guile 1.8.8) Where Libtool is Installed?

I am trying to build Guile 1.8.8 from source. I am stuck at the point where the build system is looking for libtool. I have installed it in a non-standard location.
I have already built Guile 2.0.11. In 2.0.11 build system, there is an explicit flag to configure --with-libltdl-prefix, which I think tells the build system where libtool is installed.
For Guile 1.8.8, I have Libtool installed in a non-standard location. How do I tell the build system where it is installed?
I am specifically getting error messages like:
libguile/Makefile.am:40: Libtool library used but `LIBTOOL' is undefined
libguile/Makefile.am:40: The usual way to define `LIBTOOL' is to add `LT_INIT'
I think in general this is a question regarding one or more of the autotools and how the build system finds programs / headers / libraries in non-standard locations.
This link is informative: How to point autoconf/automake to non-standard packages
Find the directory where *.m4 exists, which corresponds to libtool, or package which is in non-standard location.
export ACLOCAL_PATH=/path/to/m4/file
cd /path/to/configure.[in,ac]
autoreconf -if
./configure

How do I configure Qt for cross-compilation from Linux to Windows target?

I want to cross compile the Qt libraries (and eventually my application) for a Windows x86_64 target using a Linux x86_64 host machine. I feel like I am close, but I may have a fundamental misunderstanding of some parts of this process.
I began by installing all the mingw packages on my Fedora machine and then modifying the win32-g++ qmake.conf file to fit my environment. However, I seem to be getting stuck with some seemingly obvious configure options for Qt: -platform and -xplatform. Qt documentation says that -platform should be the host machine architecture (where you are compiling) and -xplatform should be the target platform for which you wish to deploy. In my case, I set -platform linux-g++-64 and -xplatform linux-win32-g++ where linux-win32-g++ is my modified win32-g++ configuration.
My problem is that, after executing configure with these options, I see that it invokes my system's compiler instead of the cross compiler (x86_64-w64-mingw32-gcc). If I omit the -xplatform option and set -platform to my target spec (linux-win32-g++), it invokes the cross compiler but then errors when it finds some Unix related functions aren't defined.
Here is some output from my latest attempt: http://pastebin.com/QCpKSNev.
Questions:
When cross-compiling something like Qt for Windows from a Linux host, should the native compiler ever be invoked? That is, during a cross compilation process, shouldn't we use only the cross compiler? I don't see why Qt's configure script tries to invoke my system's native compiler when I specify the -xplatform option.
If I'm using a mingw cross-compiler, when will I have to deal with a specs file? Spec files for GCC are still sort of a mystery to me, so I am wondering if some background here will help me.
In general, beyond specifying a cross compiler in my qmake.conf, what else might I need to consider?
Just use M cross environment (MXE). It takes the pain out of the whole process:
Get it:
$ git clone https://github.com/mxe/mxe.git
Install build dependencies
Build Qt for Windows, its dependencies, and the cross-build tools;
this will take about an hour on a fast machine with decent internet access;
the download is about 500MB:
$ cd mxe && make qt
Go to the directory of your app and add the cross-build tools to the PATH environment variable:
$ export PATH=<mxe root>/usr/bin:$PATH
Run the Qt Makefile generator tool then build:
$ <mxe root>/usr/i686-pc-mingw32/qt/bin/qmake && make
You should find the binary in the ./release directory:
$ wine release/foo.exe
Some notes:
Use the master branch of the MXE repository; it appears to get a lot more love from the development team.
The output is a 32-bit static binary, which will work well on 64-bit Windows.
(This is an update of #Tshepang's answer, as MXE has evolved since his answer)
Building Qt
Rather than using make qt to build Qt, you can use MXE_TARGETS to control your target machine and toolchain (32- or 64-bit). MXE started using .static and .shared as a part of the target name to show which type of lib you want to build.
# The following is the same as `make qt`, see explanation on default settings after the code block.
make qt MXE_TARGETS=i686-w64-mingw32.static # MinGW-w64, 32-bit, static libs
# Other targets you can use:
make qt MXE_TARGETS=x86_64-w64-mingw32.static # MinGW-w64, 64-bit, static libs
make qt MXE_TARGETS=i686-w64-mingw32.shared # MinGW-w64, 32-bit, shared libs
# You can even specify two targets, and they are built in one run:
# (And that's why it is MXE_TARGET**S**, not MXE_TARGET ;)
# MinGW-w64, both 32- and 64-bit, static libs
make qt MXE_TARGETS='i686-w64-mingw32.static x86_64-w64-mingw32.static'
In #Tshepang's original answer, he did not specify an MXE_TARGETS, and the default is used. At the time he wrote his answer, the default was i686-pc-mingw32, now it's i686-w64-mingw32.static. If you explicitly set MXE_TARGETS to i686-w64-mingw32, omitting .static, a warning is printed because this syntax is now deprecated. If you try to set the target to i686-pc-mingw32, it will show an error as MXE has removed support for MinGW.org (i.e. i686-pc-mingw32).
Running qmake
As we changed the MXE_TARGETS, the <mxe root>/usr/i686-pc-mingw32/qt/bin/qmake command will no longer work. Now, what you need to do is:
<mxe root>/usr/<TARGET>/qt/bin/qmake
If you didn't specify MXE_TARGETS, do this:
<mxe root>/usr/i686-w64-mingw32.static/qt/bin/qmake
Update: The new default is now i686-w64-mingw32.static
Another way to cross-compile software for Windows on Linux is the MinGW-w64 toolchain on Archlinux. It is easy to use and maintain, and it provides recent versions of the compiler and many libraries. I personally find it easier than MXE and it seems to adopt newer versions of libraries faster.
First, you will need an arch-based machine (virtual machine or docker container will suffice). It does not have to be Arch Linux, derivatives will do as well. I used Manjaro Linux.
Most of the MinGW-w64 packages are not available at the official Arch repositories, but there is plenty in AUR. The default package manager for Arch (Pacman) does not support installation directly from AUR, so you will need to install and use an AUR wrapper like yay or yaourt. Then installing MinGW-w64 version of Qt5 and Boost libraries is as easy as:
yay -Sy mingw-w64-qt5-base mingw-w64-boost
#yaourt -Sy mingw-w64-qt5-base mingw-w64-qt5-boost #if you use yaourt
This will also install the MinGW-w64 toolchain (mingw-w64-gcc) and other dependencies.
Cross-compiling a Qt project for windows (x64) is then as simple as:
x86_64-w64-mingw32-qmake-qt5
make
To deploy your program you will need to copy corresponding dlls from /usr/x86_64-w64-mingw32/bin/. For example, you will typically need to copy /usr/x86_64-w64-mingw32/lib/qt/plugins/platforms/qwindows.dll to program.exe_dir/platforms/qwindows.dll.
To get a 32bit version you simply need to use i686-w64-mingw32-qmake-qt5 instead. Cmake-based projects work just as easily with x86_64-w64-mingw32-cmake.
This approach worked extremely well for me, was the easiest to set-up, maintain, and extend.
It also goes well with continuous integration services. There are docker images available too.
For example, let's say I want to build QNapi subtitle downloader GUI. I could do it in two steps:
Start the docker container:
sudo docker run -it burningdaylight/mingw-arch:qt /bin/bash
Clone and compile QNapi
git clone --recursive 'https://github.com/QNapi/qnapi.git'
cd qnapi/
x86_64-w64-mingw32-qmake-qt5
make
That's it! In many cases, it will be that easy. Adding your own libraries to the package repository (AUR) is also straightforward. You would need to write a PKBUILD file, which is as intuitive as it can get, see mingw-w64-rapidjson, for example.
Ok I think I've got it figured out.
Based in part on https://github.com/mxe/mxe/blob/master/src/qt.mk and https://www.videolan.org/developers/vlc/contrib/src/qt4/rules.mak
It appears that "initially" when you run configure (with -xtarget, etc.), it configures then runs your "hosts" gcc to build the local binary file ./bin/qmake
./configure -xplatform win32-g++ -device-option CROSS_COMPILE=$cross_prefix_here -nomake examples ...
then you run normal "make" and it builds it for mingw
make
make install
so
yes
only if you need to use something other than msvcrt.dll (its default). Though I have never used anything else so I don't know for certain.
https://stackoverflow.com/a/18792925/32453 lists some configure params.
In order to compile Qt, one must run it's configure script, specifying the host platform with -platform (e.g. -platform linux-g++-64 if you're building on a 64-bit linux with the g++ compiler) and the target platform with -xplatform (e.g. -xplatform win32-g++ if you're cross compiling to windows).
I've also added this flag:
-device-option CROSS_COMPILE=/usr/bin/x86_64-w64-mingw32-
which specifies the prefix of the toolchain I'm using, which will get prepended to 'gcc' or 'g++' in all the makefiles that are building binaries for windows.
Finally, you might get problems while building icd, which apparently is something that is used to add ActiveX support to Qt. You can avoid that by passing the flag -skip qtactiveqt to the configure script. I've got this one out of this bug report: https://bugreports.qt.io/browse/QTBUG-38223
Here's the whole configure command I've used:
cd qt_source_directory
mkdir my_build
cd my_build
../configure \
-release \
-opensource \
-no-compile-examples \
-platform linux-g++-64 \
-xplatform win32-g++ \
-device-option CROSS_COMPILE=/usr/bin/x86_64-w64-mingw32- \
-skip qtactiveqt \
-v
As for yout questions:
1 - Yes. The native compiler will be called in order to build some tools that are needed in the build process. Maybe things like qconfig or qmake, but I'm not entirely sure which tools, exactly.
2 - Sorry. I have no idea what specs files are in the context of compilers =/ . But as far as I know, you wouldn't have to deal with that.
3 - You can specify the cross compiler prefix in the configure command line instead of doing it in the qmake.conf file, as mentioned above. And there's also that problem with idc, whose workaround I've mentioned as well.

Resources