How do you use C++ fmt on CentOS9? - c++

I installed fmt using dnf install fmt. It was successful. But when I try to use it as #include <fmt/format.h> it says it is not found. I downloaded include from fmt git page so it finds format.h now with -I... but I have compilation errors.
undefined reference to `fmt::v8::vformat[abi:cxx11](fmt::v8::basic_string_view<char>, fmt::v8::basic_format_args<fmt::v8::basic_format_context<fmt::v8::appender, char> >)'
collect2: error: ld returned 1 exit status
I tried -lfmt but it errors with
/usr/bin/ld: cannot find -lfmt
I cant find any help for this type of use on the git.
How do you use fmt lib on CentOS9 without building fmt project manually?
EIDT: dnf install output

Fedora/RHEL/CentOS uses the following naming convention for all packages that installed shared libraries:
name - this package contains runtime shared libraries that are needed to run programs that are linked with this library.
name-devel - the "devel" packages contains header files and the symbolic links that allow you to link with the shared library when developing applications that use this library.
You need both packages to compile the code that uses the library. The devel package specifies a dependency on the main package, so dnf install name-devel is going to install both packages.
You should invest a little bit of time to learn how to build your own rpm packages. It's not that complicated. When you build your package rpmbuild will take care of analyzing the resulting binary, discovering which shared libraries it links with, then recording the appropriate dependency in your own rpm package, so installing it will pull in only the main name package.

Related

g++ ld shared library error with code::blocks

There are similar topics, but I haven't managed to find my answer in them.
I am building a test console application using the code::blocks IDE. It needs to load a DVB shared library called libhdhomerun.so (from Silicon Dust) for the HD Homerun DVB tuners. The HDHR tuner library has being installed using ./configure, ..., sudo make install, ldconfig etc and it all works with their utilities (built at the same time). So - the library is there and OK.
The library installed itself into /usr/local/lib. There is actually no symlink to it as there is with other shared libraries, but then it doesn't have any version information on the end either.
When I build the code (having explicitly included /usr/local/lib/libhdhomerun.so), the ld stage fails with
"cannot find -lhdhomerun.so"
I have tried every combination of including (/usr/local/lib/) libhdhomerun.so, hdhomerun.so, libhdhomerun, hdhomerun, creating a symlink to it etc. Nothing makes any difference.
The bizarre thing is that I have udev, mysql and libdvbv5 shared libraries included in exactly the same way, and they are fine. The only one that will not link is hdhomerun.
If I run a manual verbose link step from the command line "ld -lhdhomerun.so --verbose", it does fail - because it is trying to find libhdhomerun.so.so.
Any suggestions gratefully received - but I do need to keep using code::blocks.
To link the library properly, you need to have library path defined in your environment, and use proper library name with -l flag. Library path is defined in LD_LIBRARY_PATH environment variable. For -l flag to g++, library extension should not be provided - as you already observed, so in your case it should be like this:
-lhdhomerun

linking boost filesystem and boost iostream libraries in ubuntu 14.04

I downloaded boost 1.61 and extracted it at /usr/local/boost_1_61_0 and while installing i set the prefix path to /usr/local/ where all the boost libraries are installed. I am trying to install FRESCO tool for DNA data compression which is built using Boost c++ libraries (Downloaded from https://github.com/hubsw/FRESCO). They have given make utility to install FRESCO tool.
But when I try to run make, I get errors regarding BOOST:FILESYSTEM and BOOST:IOSTREAM libraries as follows
undefined reference to `boost::iostreams::detail::gzip_header::reset()'
undefined reference to boost::iostreams::detail::zlib_base::~zlib_base()'
undefined reference to `boost::filesystem::detail::create_directories(boost::filesystem::path const&, boost::system::error_code*)'
and many more related to boost iostream and filesystem.
In FRESCO they mentioned they require BOOST 1.51(later), boost filesystem,boost iostream, boost threading-mt.
Can someone please suggest me where I am going wrong? How to link the boost filesystem/iostream if i am using make utility of ubuntu to install FRESCO tool?
I'm trying to compile boost as dependency for my project and I get similar errors.
I see two issues for your case:
I don't use FRESCO, but from its makefile I see -lboost_system -lboost_filesystem -lboost_iostreams, so it expects a global Boost installation. You don't need to compile Boost for that, you can use the packaged versions of your system. In ubuntu they can be installed with sudo apt-get install libboost-dev libboost-filesystem-dev libboost-iostreams-dev.
If you really want to compile Boost, that error message is about a part of boost that needs extra configuration for compiling it (compression filters). It tries to link to an object with some definitions that are not compiled by default (It would probably link correctly if FRESCO didn't use compression filters). Assuming that you are compiling with Boost.Build, for Boost.Iostreams this issue is explained (not very well IMO) in https://www.boost.org/doc/libs/1_61_0/libs/iostreams/doc/installation.html :
To build with Boost.Build, run bjam from the directory libs/iostreams/build, or from the Boost root directory. If you want to use the compression filters, you may need to set several Boost.Build variables indicating where the source files or pre-built binaries are located.
EDIT
There are other alternatives to compile Boost.Iostreams:
If you have installed bzip and zlib in the system, Boost.Build autoconfigures the compilation of those compression filters. In ubuntu, do sudo apt-get install libbz2-dev zlib1g-dev (in xenial, I haven't checked if the names are different in other versions).
If you can't install zlib and libbgzip in the system, and you compiled them yourself, put this in a file tools/build/src/user-config.jam inside the downloaded folder of boost:
using zlib : 1.2.11 : <include>/path-to-your-compilation/zlib-1.2.11 <search>/path-to-your-compilation/zlib-1.2.11 ;
using bzip2 : 1.0.6 : <include>/path-to-your-compilation/bzip2-1.0.6 <search>/path-to-your-compilation/bzip2-1.0.6 ;
Just replace path-to-your-compilation.
Then, do ./bootstrap.sh --with-libraries=filesystem,iostreams and ./b2.
Documentation for this (notice I'm using Boost 1.65):
user-config.jam: https://www.boost.org/doc/libs/1_65_1/doc/html/bbv2/reference.html#bbv2.reference.tools.libraries.zlib
general Boost install: https://www.boost.org/doc/libs/1_65_1/more/getting_started/unix-variants.html#prepare-to-use-a-boost-library-binary

Linking with a newer library rather than the old one

I am trying to compile the Point Cloud Library from source (http://pointclouds.org/). After running cmake and make, I receive the following linking error:
Linking CXX executable ../../bin/pcl_convert_pcd_ascii_binary
../../lib/libpcl_io.so.1.7.2: undefined reference to `png_set_longjmp_fn'
As a newbie, I'm not sure what this error means, but I am assuming: the executable file plc_convert_pcd_ascii_binary which it is trying to build, needs to be linked to the library libpcl_io.so.1.7.2, but this library contains the function png_set_longjump_fun, and the definition of this function cannot be found?
So, I have tried looked at some similar questions on Stack Overflow, and it turns out that png_set_longjump_fun is contained in the libpng library, but was only introduced after libpng-1.4.x. After running dpkg -l | grep libpng*, I get the following output:
ii libpng12-0:amd64 1.2.50-1ubuntu2 amd64 PNG library - runtime
ii libpng12-dev 1.2.50-1ubuntu2 amd64 PNG library - development
So it looks like I need to upgrade from libpng12-dev to at least libpng14-dev. From the libpng website, I see that I can download the source for the latest version (but the latest version I can get through apt-get is only libpng12-dev). But I am worried that there may be some conflictions if I have one version installed via apt-get, and another version installed manually. However, uninstalling libpng12-dev may cause issues if there are packages which depend on this, but are not compatible with the newer version.
Therefore, what I would like to know, is whether I should uninstall/purge libpng12-dev, and then install the new version manually, or to simply install the new version whilst keeping the old version. And if I do the latter, how can I be sure that the PCL binary I am trying to compile, will link with this new library, rather than the old one?
Thanks :)
If you compile from source, you probably don't even need to install. Once you have compiled libpng, set the CMAKE_PREFIX_PATH when you compile PCL to point at the right place in the libpng build tree. This generally is what is done with cmake, so should work in this case. More information:
http://www.cmake.org/cmake/help/v3.0/variable/CMAKE_PREFIX_PATH.html
https://blogs.kde.org/2008/12/12/how-get-cmake-find-what-you-want-it
cmake - find_library - custom library location
How to point cmake at specific directory for library?

Locating Boost Libraries in Ubuntu

I want to build an autotools project which is making use of the boost libraries program_options and iostreams. Therefor I install those libraries:
sudo aptitude install libboost-iostreams-dev libboost-program_options-dev
Now ./configure is fine and the progam compiles. However the linking fails:
/usr/bin/ld: cannot find -lboost_program_options-mt
/usr/bin/ld: cannot find -lboost_iostreams-mt
This is a well documented issue and can be fixed either by fixing the autotools stuff or by linking boost_program_options to boost_program_options-mt and so forth. I choose to do the latter since this is not my project. However I am failing to locate the libraries installed in Ubuntu:
locate *boost*
returns a list of documentation and package information and some boost libraries I am not looking for. locate *program_options* is empty. The library is not under /usr/lib or /lib ... Any ideas?
For me they are under /usr/lib64 in ubuntu 13.04. But I would use boost m4
to let autotool take care of these dependencies automatically. So by including boost m4 in your configure.in, you can specify which boost modules and versions you require. Morever it would also find the required paths for you.
sometimes its impossible, especially for smaller apps and custom projects,
for future, boost includes are in /usr/include/boost ,
of course it depends on system type and distribution

missing linkers in Qt

I have downloaded this project https://github.com/owncloud/sync-qt
next i did some modification to it.
I have added this files https://github.com/frankosterfeld/qtkeychain and sqlite3.h because of a missing libraries
Now the problem is that i have got those issues:
error: cannot find -lqtkeychain
error: cannot find -lsqlite3
error: cannot find -lkparts
error: cannot find -lkdeui
error: cannot find -lkdecore
error: collect2: error: ld returned 1 exit status
My OS is Fedora 18 64bit
I am using Qt Creator 2.5.0 Based on Qt 4.8.2 (64 bit)
I think this error is that i have some missing linkers !! but i don't know how to fix that ??
It is not the "linkers" which are missing, but some (development) libraries which are required to link the final executable (the linker takes the object files produced from your sources and all required libraries and links them together to produce the final executable file).
You need to make sure that the necessary -devel packages are installed - e.g. for the kde libraries, you need to install kdelibs4-devel. Since you have been able to compile the sources, it seems like these packages are already available on your system (they also contain the #include files, so without them compilation would already fail).
It seems that fedora stores these libraries below /usr/lib/kde4/devel/ (or /usr/lib64/kde4/devel/) - check that these files are there (e.g. /usr/lib64/kde4/devel/libkdecore.so). If not, install the respective -devel package, like
# yum install kdelibs4-devel