Compilation errors for medcoupling with clang

Hello,
In order to install Code_Aster on FreeBSD, I have to install medcoupling, from the bundled tarball (9.11.0 in my case). We use clang-18, and the compilation fails with several errors, mostly in the directory MEDLoader, and related to int / long conversions.
E.g.:

medcoupling-V9_11_0-1b5fb5650409b0ad3a61da3215496f2adf2dae02/src/MEDLoader/MEDFileMeshElt.cxx:58:14: error: no matching function for call to 'MEDmeshEntityFamilyNumberRd'
   58 |           if(MEDmeshEntityFamilyNumberRd(fid,mName,dt,it,entity,geoElt,miFam->getPointer())!=0)
      |              ^~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/local/include/medmesh.h:380:1: note: candidate function not viable: no known conversion from 'int *' to 'med_int *const' (aka 'long *const') for 7th argument
  380 | MEDmeshEntityFamilyNumberRd(const med_idt               fid,
      | ^
  381 |                             const char*  const          meshname,
  382 |                             const med_int               numdt,
  383 |                             const med_int               numit,
  384 |                             const med_entity_type       entitype,
  385 |                             const med_geometry_type     geotype,
  386 |                             med_int * const             number);
      |                             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Remark: MED has been installed with --with-int64=long and FCFLAGS=-fdefault-integer-8, and the platform is AMD64.

Is this a known problem?

Hi Thierry,

can you share the commands you ran to compile medfile (cmake or autotools approach) as well as medcoupling (cmake ) such that we can check on our side ?

Did you set CC and CXX environment variables and if yes to what values ?

Regards.

Hello Nabil,

I’m building MED with autotools, with these options:
--enable-python --with-int64=long --with-swig=/usr/local --with-hdf5=/usr/local --with-hdf5-include=/usr/local/include/hdf5-110 --prefix=/usr/local
and medcoupling with cmake, with these options:
-DCONFIGURATION_ROOT_DIR=/usr/local/share/salome/configuration -DSALOME_CMAKE_DEBUG=ON -DMEDCOUPLING_USE_64BIT_IDS=ON -DMEDCOUPLING_MEDLOADER_USE_XDR=OFF -DMEDCOUPLING_PARTITIONER_PARMETIS=OFF -DMEDCOUPLING_PARTITIONER_METIS=OFF -DMEDCOUPLING_PARTITIONER_SCOTCH=OFF -DHDF5_INCLUDE_DIR:PATH=/usr/local/include/hdf5-110 -DHDF5_INCLUDE_DIRS:PATH=/usr/local/include/hdf5-110 -DHDF5_LIBRARIES=libhdf5-110.so -DMEDCOUPLING_BUILD_DOC:BOOL=false -DMEDCOUPLING_USE_MPI:BOOL=false -DMEDCOUPLING_PARTITIONER_PTSCOTCH:BOOL=false -DCMAKE_C_COMPILER:STRING="cc" -DCMAKE_CXX_COMPILER:STRING="c++" -DCMAKE_C_FLAGS:STRING="-O2 -pipe -I/usr/local/include/hdf5-110 -DLIBICONV_PLUG -fstack-protector-strong -isystem /usr/local/include -fno-strict-aliasing " -DCMAKE_C_FLAGS_DEBUG:STRING="-O2 -pipe -I/usr/local/include/hdf5-110 -DLIBICONV_PLUG -fstack-protector-strong -isystem /usr/local/include -fno-strict-aliasing " -DCMAKE_C_FLAGS_RELEASE:STRING="-O2 -pipe -I/usr/local/include/hdf5-110 -DLIBICONV_PLUG -fstack-protector-strong -isystem /usr/local/include -fno-strict-aliasing -DNDEBUG" -DCMAKE_CXX_FLAGS:STRING="-O2 -pipe -I/usr/local/include/hdf5-110 -DLIBICONV_PLUG -fstack-protector-strong -isystem /usr/local/include -fno-strict-aliasing -DLIBICONV_PLUG -isystem /usr/local/include " -DCMAKE_CXX_FLAGS_DEBUG:STRING="-O2 -pipe -I/usr/local/include/hdf5-110 -DLIBICONV_PLUG -fstack-protector-strong -isystem /usr/local/include -fno-strict-aliasing -DLIBICONV_PLUG -isystem /usr/local/include " -DCMAKE_CXX_FLAGS_RELEASE:STRING="-O2 -pipe -I/usr/local/include/hdf5-110 -DLIBICONV_PLUG -fstack-protector-strong -isystem /usr/local/include -fno-strict-aliasing -DLIBICONV_PLUG -isystem /usr/local/include -DNDEBUG" -DCMAKE_EXE_LINKER_FLAGS:STRING=" -Wl,--allow-shlib-undefined -lsysinfo -fstack-protector-strong -L/usr/local/lib " -DCMAKE_MODULE_LINKER_FLAGS:STRING=" -Wl,--allow-shlib-undefined -lsysinfo -fstack-protector-strong -L/usr/local/lib " -DCMAKE_SHARED_LINKER_FLAGS:STRING=" -Wl,--allow-shlib-undefined -lsysinfo -fstack-protector-strong -L/usr/local/lib " -DCMAKE_INSTALL_PREFIX:PATH="/usr/local" -DCMAKE_BUILD_TYPE:STRING="Release" -DTHREADS_HAVE_PTHREAD_ARG:BOOL=YES -DCMAKE_INSTALL_RPATH_USE_LINK_PATH=YES -DCMAKE_VERBOSE_MAKEFILE:BOOL=ON -DFETCHCONTENT_FULLY_DISCONNECTED:BOOL=ON -DCMAKE_COLOR_MAKEFILE:BOOL=OFF -GNinja -DICONV_INCLUDE_DIR=/usr/include -DICONV_LIBRARIES=/usr/lib/libc.so -DICONV_LIBRARY=/usr/lib/libc.so -DLIBICONV_INCLUDE_DIR=/usr/include -DLIBICONV_LIBRARIES=/usr/lib/libc.so -DLIBICONV_LIBRARY=/usr/lib/libc.so -DPython_ADDITIONAL_VERSIONS=3.11 -DPython_EXECUTABLE:FILEPATH="/usr/local/bin/python3.11" -DPython3_EXECUTABLE:FILEPATH="/usr/local/bin/python3.11" -DBOOST_PYTHON_SUFFIX:STRING=311

And for $CC and $CXX I’m using:

$ cc --version
FreeBSD clang version 18.1.4 (https://github.com/llvm/llvm-project.git llvmorg-18.1.4-0-ge6c3289804a6)
Target: x86_64-unknown-freebsd15.0
Thread model: posix
InstalledDir: /usr/bin
$ c++ --version
FreeBSD clang version 18.1.4 (https://github.com/llvm/llvm-project.git llvmorg-18.1.4-0-ge6c3289804a6)
Target: x86_64-unknown-freebsd15.0
Thread model: posix
InstalledDir: /usr/bin
1 Like