conda-forge/gnuradio-feedstock

Cmake can't find log4cpp library

NicolasCaseau opened this issue · 18 comments

Hello,

I'm trying to create an OOT module for GNU Radio in a conda environnement and I have an issue with the cmake. It seems that cmake is unable to find the log4cpp librairy as you can see below :

(base) [Nicolas@cst ~]$ cd gr-howto/
(base) [Nicolas@cst gr-howto]$ cd build/
(base) [Nicolas@cst build]$ cmake -DCMAKE_INSTALL_PREFIX=anaconda3/lib/python3.8/site_packages ../
-- The CXX compiler identification is GNU 4.8.5
-- The C compiler identification is GNU 4.8.5
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Build type not specified: defaulting to release.
-- Looked for LOG4CPP libraries named log4cpp.
CMake Error at /home/Nicolas/anaconda3/envs/gnuradio/lib/cmake/gnuradio/FindLOG4CPP.cmake:47 (message):
Could NOT find LOG4CPP library
Call Stack (most recent call first):
/home/Nicolas/anaconda3/share/cmake-3.18/Modules/CMakeFindDependencyMacro.cmake:47 (find_package)
/home/Nicolas/anaconda3/envs/gnuradio/lib/cmake/gnuradio/GnuradioConfig.cmake:13 (find_dependency)
CMakeLists.txt:77 (find_package)

-- Configuring incomplete, errors occurred!
See also "/home/Nicolas/gr-howto/build/CMakeFiles/CMakeOutput.log".

I find this weird because log4cpp is installed in anaconda (I even tried to reinstall it using conda install -c conda-forge log4cpp).

I don't know if this is the best place to post this issue. If not could you please tell me where I could find my answers ?

Thank you and have a good day :)

Nicolas

Try adding some additional CMake arguments like these:

-DCMAKE_PREFIX_PATH=$CONDA_PREFIX
-DCMAKE_INSTALL_PREFIX=$CONDA_PREFIX
-DLIB_SUFFIX=""
-DPYTHON_EXECUTABLE=python
-DBoost_NO_BOOST_CMAKE=ON
-DGR_PYTHON_DIR=`python -c 'import sysconfig; print(sysconfig.get_paths()["purelib"])'`

Often you need to give CMake a little more guidance when working with a conda environment.

Oh, you might also need to install the cxx-compiler package to ensure binary compatibility with the other conda things. Right now I see it has found and will use your system compiler, which may or may not cause incompatibilities.

Thank you for the quick answer, I will try to add the Cmake arguments like you said. I'll keep you posted on my advancement !

I put these instructions up on the GNU Radio wiki at https://wiki.gnuradio.org/index.php/CondaInstall. Let me know if something doesn't work and they need modification!

I tried adding the Cmake arguments as you said but it doesn't seem to be working. I'm not really clear on what I should put on the arguments for the $CONDA_PREFIX.

I also found out that FindLOG4CPP is not in the cmake module list so I tried adding it in the CMakeLists.txt but without success.

I tried this out myself on gr-ecss and made some modifications to the instructions on the wiki to make it work. Basically, it's easier to install the following packages to your conda environment:

conda install cmake cxx-compiler ninja pkg-config

Then re-activate your environment after just installing cxx-compiler

conda activate $CONDA_DEFAULT_ENV

Clear out any existing build directory you have and start fresh:

rm -r build
mkdir build
cd build

Then the CMake command is simpler:

cmake -G Ninja -DCMAKE_INSTALL_PREFIX=$CONDA_PREFIX -DCMAKE_PREFIX_PATH=$CONDA_PREFIX ..

You can skip ninja and use make, I just did it this way to help make things more uniform across platforms. Also closely inspect the CMake output to see if you are missing any libraries or if some are found outside of your conda prefix. If they are, you'll need to install them with conda and re-run the whole thing cleanly from scratch.

I'm not really clear on what I should put on the arguments for the $CONDA_PREFIX.

I'm not quite sure what you mean here. If you are working within an activated conda environment, then it will have set the CONDA_PREFIX environment variable. You can verify that it says the right thing with echo $CONDA_PREFIX. You can just type $CONDA_PREFIX as I have it written in the instructions and it will be filled in with the correct path.

I also found out that FindLOG4CPP is not in the cmake module list so I tried adding it in the CMakeLists.txt but without success.

GNU Radio knows to find log4cpp itself, so the OOT shouldn't have to add that. If CMake is failing to find log4cpp, it's not because FindLOG4CPP is missing.

I tried doing what you said on gr-ecss, however I'm still not able to make it work. Maybe I'm doing something wrong, can you tell me if the steps I did are correct ?

  • I first cloned the git of gr-ecss with https://github.com/FlaReSS/gr-ecss.git
  • Once in the "gr-ecss" folder, I did mkdir build and cd build
  • I then tried to type the following command and I got the following errors :

cmake -DCMAKE_INSTALL_PREFIX=$CONDA_PREFIX -DCMAKE_PREFIX_PATH=$CONDA_PREFIX ..
-- Build type not specified: defaulting to release.
CMake Warning (dev) at /home/Nicolas/anaconda3/envs/gnuradio/share/cmake-3.19/Modules/FindPackageHandleStandardArgs.cmake:426 (message):
The package name passed to find_package_handle_standard_args (PkgConfig)
does not match the name of the calling package (GMP). This can lead to
problems in calling code that expects find_package result variables
(e.g., _FOUND) to follow a certain pattern.
Call Stack (most recent call first):
/home/Nicolas/anaconda3/envs/gnuradio/share/cmake-3.19/Modules/FindPkgConfig.cmake:67 (find_package_handle_standard_args)
/home/Nicolas/anaconda3/envs/gnuradio/lib/cmake/gnuradio/FindGMP.cmake:2 (include)
/home/Nicolas/anaconda3/envs/gnuradio/lib/cmake/gnuradio/FindMPLIB.cmake:1 (find_package)
/home/Nicolas/anaconda3/envs/gnuradio/share/cmake-3.19/Modules/CMakeFindDependencyMacro.cmake:47 (find_package)
/home/Nicolas/anaconda3/envs/gnuradio/lib/cmake/gnuradio/GnuradioConfig.cmake:14 (find_dependency)
CMakeLists.txt:86 (find_package)
This warning is for project developers. Use -Wno-dev to suppress it.

-- Checking for module 'gmp'
-- No package 'gmp' found
-- Could NOT find GMP (missing: GMPXX_LIBRARY GMP_LIBRARY GMP_INCLUDE_DIR)
-- Checking for module 'mpir >= 3.0'
-- No package 'mpir' found
-- User set python executable /home/Nicolas/anaconda3/envs/gnuradio/bin/python
-- Found PythonLibs: /home/Nicolas/anaconda3/envs/gnuradio/lib/libpython3.9.so (found suitable exact version "3.9.2")
-- Extracting version information from git describe...
-- Using install prefix: /home/Nicolas/anaconda3/envs/gnuradio
-- Building for version: ... / ..
-- Could NOT find SWIG (missing: SWIG_EXECUTABLE SWIG_DIR)
-- Found PythonLibs: /home/Nicolas/anaconda3/envs/gnuradio/lib/libpython3.9.so (found suitable version "3.9.2", minimum required is "2")
-- Configuring done
-- Generating done
-- Build files have been written to: /home/Nicolas/gr-ecss/build
(gnuradio) [Nicolas@cst build]$

It seems the modules gmp and mpir couldn't be found even after I installed them with conda. I also installed pybind11 (as I'm working on GNU Radio 3.9) but the compiler is still looking for SWIG.

Any intel on how I could solve these problems ?

Let's start with the high-level problems and work down. Based on what I see, it doesn't look like gr-ecss has been updated to support GNU Radio 3.9. That's why it is looking for SWIG. Are you saying you want to update it to work with 3.9? If that is not your intention, then you're stuck with 3.8 and you'll have to have 3.8 installed to have any hope of getting this to compile.

Second point: that CMake output there actually does succeed in the end ("Build files have been written to ..."), despite missing SWIG and GMP. That tells me it did actually find MPIR, which is good. The CMake output can be confusing sometimes because it will contain messages like "No package 'mpir' found" when it does end up finding MPIR. That's because it often uses multiple methods to find packages, and one of those ways will spit out the "No package found ..." text when it fails even though the next method it tries actually succeeds. CMake won't get to the "Build files have been written to ..." step if it has failed to find anything absolutely required.

So if you were to try to build from this point, I'm guessing it would work but wouldn't build the Python bindings since SWIG is missing. Likely that means it doesn't actually "work" from your perspective.

I think your next step should be to install SWIG and see if that can get it building against GNU Radio 3.8. If that works for you, then great. If you still need 3.9 after that, then you can install GNU Radio 3.9 and try updating gr-ecss to work with it, but at least in that case we should know that you will have cleared up any conda-specific problems.

I created a new conda environnement and installed GNU Radio 3.8. After following your instructions I managed to install gr-ecss correctly !

However, when I try launching GNU Radio I get an Import error : "libvolk.so.2.2.1 : cannot open shared object file : No such file or directory". When I checked the libraries Inside my conda environnement, the only volk Library installed is libvolk.so. Do you know how I can tell GNU Radio to use this one instead ?

That's odd, because I can't think of a situation where conda would install volk 2.2.1. Things that build against volk do require a specific version, so verify the volk version you have installed. Everything should be on volk 2.4.1 at this point. volk-config-info -v should output 2.4. What is the exact version string for your GNU Radio 3.8 (conda list gnuradio, include the build string)? Maybe conda has installed an older broken build for some reason.

Try adding some additional CMake arguments like these:

-DCMAKE_PREFIX_PATH=$CONDA_PREFIX
-DCMAKE_INSTALL_PREFIX=$CONDA_PREFIX
-DLIB_SUFFIX=""
-DPYTHON_EXECUTABLE=python
-DBoost_NO_BOOST_CMAKE=ON
-DGR_PYTHON_DIR=`python -c 'import sysconfig; print(sysconfig.get_paths()["purelib"])'`

Often you need to give CMake a little more guidance when working with a conda environment.

Hi @ryanvolz I am having the same issue: after installing and successfully using gnuradio using conda, when I try to build from source the OOT gr-si446x I have the same cmake error shown below. I tried the additional arguments you suggested but still could not fix it. Any comments? The same happens with any other OOT module I have to build from source.

I'd like to emphasize that I am familiar with using GNUradio but not really with linux, conda, cmake, etc... So please take that into account with your response. For example, if the additional cmake arguments should have any type of consideration when entering the commands, I would also need to know that, thank you for your help!!

CMake Error at /home/ubuser/CONDA/envs/gnuradio382/lib/cmake/gnuradio/FindLOG4CPP.cmake:46 (message):
Could NOT find LOG4CPP library
Call Stack (most recent call first):
/usr/share/cmake-3.22/Modules/CMakeFindDependencyMacro.cmake:47 (find_package)
/home/ubuser/CONDA/envs/gnuradio382/lib/cmake/gnuradio/GnuradioConfig.cmake:25 (find_dependency)
CMakeLists.txt:105 (find_package)

@cmunikat Hmm, this should work out of the box now, but maybe the issue is an older gnuradio package. Which version do you have installed?

Hi @ryanvolz thank you for so much for your fast reply. I tried everything (not only conda) but I am really strugling to have GNUradio working with all the required OOT modules.

In this case, in a fresh installed ubuntu 22.04.1 I installed a fresh conda miniforge3. Then directly gnuradio 3.8.2 through conda, following this procedure https://wiki.gnuradio.org/index.php/CondaInstall

The modules I need are gr-si446x and gr-satnogs, among others, besides others arlready packed with conda.

I really appreciate your help.

@cmunikat I think it's possible you don't have log4cpp installed since it's only required when building packages and not just to run them. So try mamba install log4cpp and run cmake again.

@ryanvolz thank you for your help. Unfortunately it doesnt work either. Please see below. Also, please check if i am proceeding correctly.

gnuradio382) ubuser@ubhost:~$ mamba install log4cpp

              __    __    __    __
             /  \  /  \  /  \  /  \
            /    \/    \/    \/    \

███████████████/ /██/ /██/ /██/ /████████████████████████
/ / \ / \ / \ / \ ____
/ / _/ _/ _/ \ o _,
/ / _
__/ `
|/
███╗ ███╗ █████╗ ███╗ ███╗██████╗ █████╗
████╗ ████║██╔══██╗████╗ ████║██╔══██╗██╔══██╗
██╔████╔██║███████║██╔████╔██║██████╔╝███████║
██║╚██╔╝██║██╔══██║██║╚██╔╝██║██╔══██╗██╔══██║
██║ ╚═╝ ██║██║ ██║██║ ╚═╝ ██║██████╔╝██║ ██║
╚═╝ ╚═╝╚═╝ ╚═╝╚═╝ ╚═╝╚═════╝ ╚═╝ ╚═╝

    mamba (0.27.0) supported by @QuantStack

    GitHub:  https://github.com/mamba-org/mamba
    Twitter: https://twitter.com/QuantStack

█████████████████████████████████████████████████████████████

Looking for: ['log4cpp']

conda-forge/noarch 10.2MB @ 2.3MB/s 5.3s
conda-forge/linux-64 27.7MB @ 2.1MB/s 17.3s

Pinned packages:

  • python 3.9.*

Transaction

Prefix: /home/ubuser/CONDA/envs/gnuradio382

All requested packages already installed

(gnuradio382) ubuser@ubhost:$ git clone https://gitlab.com/librespacefoundation/satnogs/gr-satnogs.git
Cloning into 'gr-satnogs'...
remote: Enumerating objects: 5632, done.
remote: Counting objects: 100% (2506/2506), done.
remote: Compressing objects: 100% (690/690), done.
remote: Total 5632 (delta 1710), reused 2505 (delta 1709), pack-reused 3126
Receiving objects: 100% (5632/5632), 3.17 MiB | 13.76 MiB/s, done.
Resolving deltas: 100% (3844/3844), done.
(gnuradio382) ubuser@ubhost:
$ cd gr-satnogs
mkdir build
cd build
cmake ..
CMake Warning (dev) at /usr/share/cmake-3.22/Modules/GNUInstallDirs.cmake:239 (message):
Unable to determine default CMAKE_INSTALL_LIBDIR directory because no
target architecture is known. Please enable at least one language before
including GNUInstallDirs.
Call Stack (most recent call first):
CMakeLists.txt:22 (include)
This warning is for project developers. Use -Wno-dev to suppress it.

-- The CXX compiler identification is GNU 11.3.0
-- The C compiler identification is GNU 11.3.0
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Build type not specified: defaulting to release.
-- Found PythonLibs: /usr/lib/x86_64-linux-gnu/libpython3.10.so (found suitable version "3.10.6", minimum required is "3")
-- Looked for LOG4CPP libraries named log4cpp.
CMake Error at /home/ubuser/CONDA/envs/gnuradio382/lib/cmake/gnuradio/FindLOG4CPP.cmake:46 (message):
Could NOT find LOG4CPP library
Call Stack (most recent call first):
/usr/share/cmake-3.22/Modules/CMakeFindDependencyMacro.cmake:47 (find_package)
/home/ubuser/CONDA/envs/gnuradio382/lib/cmake/gnuradio/GnuradioConfig.cmake:25 (find_dependency)
CMakeLists.txt:105 (find_package)

-- Configuring incomplete, errors occurred!
See also "/home/ubuser/gr-satnogs/build/CMakeFiles/CMakeOutput.log".
(gnuradio382) ubuser@ubhost:~/gr-satnogs/build$

@cmunikat I get a little farther with the following:

  1. Environment installed with mamba install gnuradio=3.8.2 swig cmake pkg-config nlohmann_json
  2. Running
    mkdir build
    cd build
    cmake -DCMAKE_PREFIX_PATH=$CONDA_PREFIX -DCMAKE_INSTALL_PREFIX=$CONDA_PREFIX -DLIB_SUFFIX="" -DPYTHON_EXECUTABLE=`which python` -DPYTHON_LIBRARY=`ls $CONDA_PREFIX/lib/libpython*.*.so` -DPYTHON_INCLUDE_DIR=`ls -d $CONDA_PREFIX/include/python*.*` -DBoost_NO_BOOST_CMAKE=ON -DGR_PYTHON_DIR=`python -c 'import sysconfig; print(sysconfig.get_paths()["purelib"])'` ..
    

But then I run into an issue with missing Boost::unit_test_framework and a few dependencies that are not available through conda-forge:

png++
it++ (or itpp)

So I think no matter if you can get the rest to work, those missing dependencies are going to be blockers. The only way around is to build them yourself, which I have no experience with. I see that the in-progress port of gr-satnogs to GNU Radio 3.10 drops the dependency on png++, but it adds one on hamlib and it++ remains, so that's no better. There's a small chance it works if you apt install libitpp-dev and libpng++-dev on your Ubuntu system and get lucky with binary compatibility.

This gets me past the Boost::unit_test_framework error, but still itpp is an issue:

cmake -DCMAKE_PREFIX_PATH=$CONDA_PREFIX -DCMAKE_INSTALL_PREFIX=$CONDA_PREFIX -DLIB_SUFFIX="" -DPYTHON_EXECUTABLE=`which python` -DPYTHON_LIBRARY=`ls $CONDA_PREFIX/lib/libpython*.*.so` -DPYTHON_INCLUDE_DIR=`ls -d $CONDA_PREFIX/include/python*.*` -DBoost_NO_BOOST_CMAKE=ON -DGR_PYTHON_DIR=`python -c 'import sysconfig; print(sysconfig.get_paths()["purelib"])'` -DENABLE_TESTING=ON ..

@ryanvolz thank you so much for your help. I think that if you are having trouble with it, given my short experience in this subject, It will take me ages to solve it.
I could install any version of GNU radio provided the OOT modules would work. Also, I already tried multiple VMs and I can try in debian as well.
Thanks again for your feedback