SALOME-9.8.0-native-FD34-SRC on Fedora35, several build problems

Hi there,

I have a bunch of problems building Salome. Starting with the first:

When it comes to OpenCV, I get, apart from lots of warnings,

/home/.../SALOME-9.8.0-native-FD34-SRC/SOURCES/opencv/3rdparty/openexr/Imath/ImathVec.h:227:41: error: ISO C++17 does not allow dynamic exception specifications

for several objects. Nevermind that I actually have OpenCV on my machine, but do not understand how sat would find it. This uses gcc 11.3.1.

Thanks in advance to anyone who can help.

AFAIK, Opencv is used for one feature in GEOM (shape recognition from picture), so you can do the following:

  • Edit PROJECT/products/GEOM.pyconf

    • remove opencv from the dependencies list
    • replace: -DSALOME_GEOM_USE_OPENCV=ON with -DSALOME_GEOM_USE_OPENCV=OFF
  • Edit PROJECT/applications/SALOME-9.8.0-native.pyconf and comment out opencv.

Note, that neither FD35, nor FD36 are supported yet.
HTH

You may see this kind of error message in other packages and this is because the newer GCC compilers have switched their default behaviour to the C++ 17 standard but some components do not conform to this standard and therefore an extra compiler option is required in order to specify the supported standard.

For the case of opencv the proper standard to use is C++ 14 and in order to do that you have to edit the script which builds this package for Salome. In order to do that you need to go to the foilder :

PROJECT/products/compil_scripts

and then edit file “opencv.sh”. You need to specify the proper C++ version in the beginning of the script so that it looks like the following:

#!/bin/bash

echo "##########################################################################"
echo "opencv" $VERSION
echo "##########################################################################"

function version_ge() { test "$(echo "$@" | tr " " "\n" | sort -rV | head -n 1)" == "$1"; }
CPPSTD="\"-std=c++14\""
CMAKE_OPTIONS=""
CMAKE_OPTIONS+=" -DCMAKE_INSTALL_PREFIX:STRING=${PRODUCT_INSTALL}"
CMAKE_OPTIONS+=" -DCMAKE_BUILD_TYPE:STRING=Release"

if version_ge $VERSION "3."; then
    echo "*** openCV version $VERSION >= 3."
    CMAKE_OPTIONS+=" -DBUILD_NEW_PYTHON_SUPPORT=ON"
    CMAKE_OPTIONS+=" -DBUILD_EXAMPLES:BOOL=ON"
    CMAKE_OPTIONS+=" -DPYTHON3_EXECUTABLE=${PYTHONBIN}"
    CMAKE_OPTIONS+=" -DPYTHON3_NUMPY_INCLUDE_DIRS=${NUMPY_INCLUDE_DIR};${NUMPY_INCLUDE_DIR2}"
    CMAKE_OPTIONS+=" -DWITH_IPP:BOOL=OFF"
    CMAKE_OPTIONS+=" -DBUILD_opencv_java:BOOL=OFF"
    CMAKE_OPTIONS+=" -DPYTHON_INCLUDE_DIR=${PYTHON_ROOT_DIR}/include/python${PYTHON_VERSION}"
    CMAKE_OPTIONS+=" -DPYTHON_INCLUDE_DIR2=${PYTHON_ROOT_DIR}/include/python${PYTHON_VERSION}"
    CMAKE_OPTIONS+=" -DWITH_FFMPEG:BOOL=OFF"
    CMAKE_OPTIONS+=" -DWITH_LAPACK:BOOL=OFF"
    CMAKE_OPTIONS+=" -DWITH_CUDA:BOOL=OFF"
    CMAKE_OPTIONS+=" -DWITH_V4L:BOOL=OFF"
    CMAKE_OPTIONS+=" -DWITH_LIBV4L:BOOL=ON"
    # bos 19730
    CMAKE_OPTIONS+=" -DWITH_VTK:BOOL=OFF"
    CMAKE_OPTIONS+=" -DENABLE_PRECOMPILED_HEADERS:BOOL=OFF"
    CMAKE_OPTIONS+=" -DCMAKE_CXX_FLAGS=-fPIC"
    CMAKE_OPTIONS+=" -DCMAKE_CXX_STANDARD=14"
    CMAKE_OPTIONS+=" -DCMAKE_C_FLAGS=-fPIC"
    if [[ $DIST_NAME == "FD" && $DIST_VERSION == "34" ]]
        then
            CMAKE_OPTIONS+=" -DCMAKE_CXX_FLAGS=${CPPSTD}"
        fi
    CMAKE_OPTIONS+=" -DCMAKE_C_FLAGS=-fPIC"
    # 
else
    echo "*** openCV version $VERSION < 3."
    CMAKE_OPTIONS+=" -DWITH_CUDA:BOOL=OFF"
    CMAKE_OPTIONS+=" -DWITH_FFMPEG:BOOL=OFF"
    # OP opencv on Ubuntu
    CMAKE_OPTIONS+=" -DPYTHON_EXECUTABLE=${PYTHON_ROOT_DIR}/bin/python"
    CMAKE_OPTIONS+=" -DPYTHON_INCLUDE_DIRS=${PYTHON_ROOT_DIR}/include/python${PYTHON_VERSION}"
    CMAKE_OPTIONS+=" -DPYTHON_LIBRARY=${PYTHON_ROOT_DIR}/lib/libpython${PYTHON_VERSION}.so"
    CMAKE_OPTIONS+=" -DBUILD_opencv_java=OFF"
fi

Note the line:

    if [[ $DIST_NAME == "FD" && $DIST_VERSION == "34" ]]
        then
            CMAKE_OPTIONS+=" -DCMAKE_CXX_FLAGS=${CPPSTD}"
        fi

This line adds the option which selects the C++ standard to enable for the case of Fedora 34. It would be better to remove the if-statement and make this option be applied all the time regradless of the Linux distro such as:

    # bos 19730
    CMAKE_OPTIONS+=" -DWITH_VTK:BOOL=OFF"
    CMAKE_OPTIONS+=" -DENABLE_PRECOMPILED_HEADERS:BOOL=OFF"
    CMAKE_OPTIONS+=" -DCMAKE_CXX_FLAGS=-fPIC"
    CMAKE_OPTIONS+=" -DCMAKE_CXX_STANDARD=14"
    CMAKE_OPTIONS+=" -DCMAKE_C_FLAGS=-fPIC"
    CMAKE_OPTIONS+=" -DCMAKE_CXX_FLAGS=${CPPSTD}"
    CMAKE_OPTIONS+=" -DCMAKE_C_FLAGS=-fPIC"

This will resolve the problem. Note that other packages may produce a similar error message in which case you have to do the same in order to modify the appropriate compilation script and specify a C++ version lower than 17.

With these changes I have compiled Salome for both Fedora 35 and 36 without any problems.

2 Likes

Thank you @paspro ! It is certainly nice to at least know which files to look at. With your modifications, the compilation now proceeds a wee further until:

home/…/SALOME-9.8.0-native-FD34-SRC/SOURCES/opencv/modules/core/src/persistence.cpp:7512:31: error: comparing the result of pointer addition ‘(src + ((sizetype)off))’ and NULL [-Werror=address]
7512 | if (src == 0 || src + off == 0)

I tried something like

CMAKE_OPTIONS+=" -DCMAKE_CXX_FLAGS=-fPIC -Wno-error=address"

in opencv.sh, but this seems to straight out get ignored.
Note that I upgraded to Fedora 36 in the meantime, and now use gcc 12.1.1

Yes, I also encountered this issue and I modified the offending part of code to the following:

/* check parameters */
if (src == nullptr)
  return false;

u_int8_t const * src_more = src + off;
if (src_more == nullptr)
  return false;

That will fix the problem.

1 Like

Nice, this fixed the problem indeed.

Moving on. The next issue was something like

ar: libdeps specified more than once

when building AfterImage. This was easy to fix since it is a problem that many people already found. I replaced

AR = ar cq
#AR = ar clq

and the compilation worked. The next thing where I get stuck is the kernel compilation:

CMake Error at /usr/share/cmake/Modules/FindPackageHandleStandardArgs.cmake:230 (message):
Could NOT find OmniORBPy (missing: OMNIORB_PYTHON_BACKEND)
Call Stack (most recent call first):
/usr/share/cmake/Modules/FindPackageHandleStandardArgs.cmake:594 (_FPHSA_FAILURE_MESSAGE)
/home/xxx/SALOME-9.8.0-native-FD34-SRC/SOURCES/CONFIGURATION/cmake/FindOmniORBPy.cmake:64 (FIND_PACKAGE_HANDLE_STANDARD_ARGS)
/home/xxx/SALOME-9.8.0-native-FD34-SRC/SOURCES/CONFIGURATION/cmake/SalomeMacros.cmake:448 (FIND_PACKAGE)
/home/xxx/SALOME-9.8.0-native-FD34-SRC/SOURCES/CONFIGURATION/cmake/SalomeMacros.cmake:547 (SALOME_FIND_PACKAGE)
/home/xxx/SALOME-9.8.0-native-FD34-SRC/SOURCES/CONFIGURATION/cmake/FindSalomeOmniORBPy.cmake:44 (SALOME_FIND_PACKAGE_AND_DETECT_CONFLICTS)
CMakeLists.txt:97 (FIND_PACKAGE)

But earlier it says that omniORBpy is actually there:

Compilation of omniORB … Already installed
Compilation of omniORBpy … Already installed

Any ideas?

Regarding omniORB (and some other prerequisites), I chose to use the native version of these packages on Fedora rather than waste time and disk space building them for Salome. I suggest you do the same. It is easy to do:

  1. Go to the PROJECT/applications directory.
  2. Open file SALOME-9.8.0-native.pyconf
  3. Go to the line which mentions omniORB and change it to: omniORB: 'native'
  4. Go to the next line which mentions omniORBpy and change it to: omniORBpy: 'native'
  5. Save the file and close it.

You can do the same for other prerequisites which are available in the Fedora repositories. In order to install these components in Fedora do:

sudo dnf install omniORB omniORB-devel omniORBpy-devel