DIPlib / diplib

Quantitative Image Analysis in C++, MATLAB and Python
https://diplib.org
Apache License 2.0
227 stars 49 forks source link

Cmake-building fail due to missing io and pthread? #73

Closed renerichter closed 3 years ago

renerichter commented 3 years ago

Component CMake build scripts for GIT-commit-ID c9078cd

Describe the bug CMake fails to compile (maybe due to missing io.h and and pthread-problems)

To Reproduce

System information:

Messages

-- The C compiler identification is GNU 10.2.0
-- The CXX compiler identification is GNU 10.2.0
-- 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
-- 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
-- Found OpenMP_C: -fopenmp (found version "4.5") 
-- Found OpenMP_CXX: -fopenmp (found version "4.5") 
-- Found OpenMP: TRUE (found version "4.5")  
-- Performing Test HAS_PRETTY_FUNCTION
-- Performing Test HAS_PRETTY_FUNCTION - Success
-- Performing Test HAS_128_INT
-- Performing Test HAS_128_INT - Success
~~~Configuring Zlib~~~
-- Looking for sys/types.h
-- Looking for sys/types.h - found
-- Looking for stdint.h
-- Looking for stdint.h - found
-- Looking for stddef.h
-- Looking for stddef.h - found
-- Check size of off64_t
-- Check size of off64_t - done
-- Looking for fseeko
-- Looking for fseeko - found
-- Looking for unistd.h
-- Looking for unistd.h - found
~~~
~~~Configuring libics~~~
-- Looking for strtok_r
-- Looking for strtok_r - found
~~~Configuring LibTIFF~~~
-- Performing Test C_FLAG_Wall
-- Performing Test C_FLAG_Wall - Success
-- Performing Test C_FLAG_Winline
-- Performing Test C_FLAG_Winline - Success
-- Performing Test C_FLAG_W
-- Performing Test C_FLAG_W - Success
-- Performing Test C_FLAG_Wformat_security
-- Performing Test C_FLAG_Wformat_security - Success
-- Performing Test C_FLAG_Wpointer_arith
-- Performing Test C_FLAG_Wpointer_arith - Success
-- Performing Test C_FLAG_Wdisabled_optimization
-- Performing Test C_FLAG_Wdisabled_optimization - Success
-- Performing Test C_FLAG_Wno_unknown_pragmas
-- Performing Test C_FLAG_Wno_unknown_pragmas - Success
-- Performing Test C_FLAG_Wdeclaration_after_statement
-- Performing Test C_FLAG_Wdeclaration_after_statement - Success
-- Performing Test C_FLAG_Wno_unused_parameter
-- Performing Test C_FLAG_Wno_unused_parameter - Success
-- Performing Test C_FLAG_Wno_unused_but_set_variable
-- Performing Test C_FLAG_Wno_unused_but_set_variable - Success
-- Performing Test C_FLAG_fstrict_aliasing
-- Performing Test C_FLAG_fstrict_aliasing - Success
-- Looking for assert.h
-- Looking for assert.h - found
-- Looking for dlfcn.h
-- Looking for dlfcn.h - found
-- Looking for fcntl.h
-- Looking for fcntl.h - found
-- Looking for inttypes.h
-- Looking for inttypes.h - found
-- Looking for io.h
-- Looking for io.h - not found
-- Looking for search.h
-- Looking for search.h - found
-- Looking for string.h
-- Looking for string.h - found
-- Looking for strings.h
-- Looking for strings.h - found
-- Looking for sys/time.h
-- Looking for sys/time.h - found
-- Looking for unistd.h
-- Looking for unistd.h - found
-- Performing Test C_HAS_inline
-- Performing Test C_HAS_inline - Success
-- Performing Test TIME_WITH_SYS_TIME
-- Performing Test TIME_WITH_SYS_TIME - Success
-- Performing Test TM_IN_SYS_TIME
-- Performing Test TM_IN_SYS_TIME - Success
-- Check size of signed int
-- Check size of signed int - done
-- Check size of unsigned int
-- Check size of unsigned int - done
-- Check size of signed long
-- Check size of signed long - done
-- Check size of unsigned long
-- Check size of unsigned long - done
-- Check size of signed long long
-- Check size of signed long long - done
-- Check size of unsigned long long
-- Check size of unsigned long long - done
-- Check size of unsigned char *
-- Check size of unsigned char * - done
-- Check size of size_t
-- Check size of size_t - done
-- Check size of ptrdiff_t
-- Check size of ptrdiff_t - done
-- Looking for mmap
-- Looking for mmap - found
-- Looking for setmode
-- Looking for setmode - not found
-- Looking for snprintf
-- Looking for snprintf - found
-- Looking for strcasecmp
-- Looking for strcasecmp - found
-- Looking for strtol
-- Looking for strtol - found
-- Looking for strtoll
-- Looking for strtoll - found
-- Looking for strtoul
-- Looking for strtoul - found
-- Looking for strtoull
-- Looking for strtoull - found
-- Looking for getopt
-- Looking for getopt - found
-- Looking for lfind
-- Looking for lfind - found
-- LibTIFF uses win32 IO: FALSE
-- LibTIFF has JPEG 8/12 bit dual mode: FALSE
~~~
-- Found FFTW3: /usr/include  
-- Found Java: /usr/bin/java (found suitable version "1.8.0.292", minimum required is "1.8") found components: Development 
-- Found JNI: /usr/lib/jvm/default/jre/lib/amd64/libjawt.so  
CMake Warning (dev) at /usr/share/cmake-3.20/Modules/FindOpenGL.cmake:315 (message):
  Policy CMP0072 is not set: FindOpenGL prefers GLVND by default when
  available.  Run "cmake --help-policy CMP0072" for policy details.  Use the
  cmake_policy command to set the policy and suppress this warning.

  FindOpenGL found both a legacy GL library:

    OPENGL_gl_LIBRARY: /usr/lib/libGL.so

  and GLVND libraries for OpenGL and GLX:

    OPENGL_opengl_LIBRARY: /usr/lib/libOpenGL.so
    OPENGL_glx_LIBRARY: /usr/lib/libGLX.so

  OpenGL_GL_PREFERENCE has not been set to "GLVND" or "LEGACY", so for
  compatibility with CMake 3.10 and below the legacy GL library will be used.
Call Stack (most recent call first):
  CMakeLists.txt:119 (find_package)
This warning is for project developers.  Use -Wno-dev to suppress it.

-- Found OpenGL: /usr/lib/libOpenGL.so   
-- Found FreeGLUT: /usr/lib/libglut.so  
-- FreeGLUT found: /usr/lib/libglut.so -- /usr/include
-- Found GLFW: /usr/lib/libglfw.so  
-- GLFW found: /usr/lib/libglfw.so -- /usr/include
-- Looking for pthread.h
-- Looking for pthread.h - found
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Failed
-- Check if compiler accepts -pthread
-- Check if compiler accepts -pthread - yes
-- Found Threads: TRUE  
-- Found PythonInterp: /usr/bin/python3.9 (found version "3.9.4") 
-- Found PythonLibs: /usr/lib/libpython3.9.so
CMake Error at dipimage/CMakeLists.txt:11 (matlab_add_mex):
  Unknown CMake command "matlab_add_mex".
Call Stack (most recent call first):
  dipimage/CMakeLists.txt:43 (compile_mex_files)

-- Configuring incomplete, errors occurred!
See also "/[...]/Downloads/MATLAB/diplib/target/CMakeFiles/CMakeOutput.log".
See also "/[...]/Downloads/MATLAB/diplib/target/CMakeFiles/CMakeError.log".

CmakeError.log

Determining if the include file io.h exists failed with the following output:
Change Dir: /[...]/Downloads/MATLAB/diplib/target/CMakeFiles/CMakeTmp

Run Build Command(s):/usr/bin/make -f Makefile cmTC_e157a/fast && /usr/bin/make  -f CMakeFiles/cmTC_e157a.dir/build.make CMakeFiles/cmTC_e157a.dir/build
make[1]: Entering directory '/[...]/Downloads/MATLAB/diplib/target/CMakeFiles/CMakeTmp'
Building C object CMakeFiles/cmTC_e157a.dir/CheckIncludeFile.c.o
/usr/bin/cc   -Wall -Winline -W -Wformat-security -Wpointer-arith -Wdisabled-optimization -Wno-unknown-pragmas -Wdeclaration-after-statement -Wno-unused-parameter -Wno-unused-but-set-variable -fstrict-aliasing  -o CMakeFiles/cmTC_e157a.dir/CheckIncludeFile.c.o -c /[...]/Downloads/MATLAB/diplib/target/CMakeFiles/CMakeTmp/CheckIncludeFile.c
/[...]/Downloads/MATLAB/diplib/target/CMakeFiles/CMakeTmp/CheckIncludeFile.c:1:10: fatal error: io.h: No such file or directory
    1 | #include <io.h>
      |          ^~~~~~
compilation terminated.
make[1]: *** [CMakeFiles/cmTC_e157a.dir/build.make:78: CMakeFiles/cmTC_e157a.dir/CheckIncludeFile.c.o] Error 1
make[1]: Leaving directory '/[...]/Downloads/MATLAB/diplib/target/CMakeFiles/CMakeTmp'
make: *** [Makefile:127: cmTC_e157a/fast] Error 2

Determining if the setmode exist failed with the following output:
Change Dir: /[...]/Downloads/MATLAB/diplib/target/CMakeFiles/CMakeTmp

Run Build Command(s):/usr/bin/make -f Makefile cmTC_8744f/fast && /usr/bin/make  -f CMakeFiles/cmTC_8744f.dir/build.make CMakeFiles/cmTC_8744f.dir/build
make[1]: Entering directory '/[...]/Downloads/MATLAB/diplib/target/CMakeFiles/CMakeTmp'
Building C object CMakeFiles/cmTC_8744f.dir/CheckSymbolExists.c.o
/usr/bin/cc   -Wall -Winline -W -Wformat-security -Wpointer-arith -Wdisabled-optimization -Wno-unknown-pragmas -Wdeclaration-after-statement -Wno-unused-parameter -Wno-unused-but-set-variable -fstrict-aliasing  -o CMakeFiles/cmTC_8744f.dir/CheckSymbolExists.c.o -c /[...]/Downloads/MATLAB/diplib/target/CMakeFiles/CMakeTmp/CheckSymbolExists.c
/[...]/Downloads/MATLAB/diplib/target/CMakeFiles/CMakeTmp/CheckSymbolExists.c: In function ‘main’:
/[...]/Downloads/MATLAB/diplib/target/CMakeFiles/CMakeTmp/CheckSymbolExists.c:8:19: error: ‘setmode’ undeclared (first use in this function)
    8 |   return ((int*)(&setmode))[argc];
      |                   ^~~~~~~
/[...]/Downloads/MATLAB/diplib/target/CMakeFiles/CMakeTmp/CheckSymbolExists.c:8:19: note: each undeclared identifier is reported only once for each function it appears in
/[...]/Downloads/MATLAB/diplib/target/CMakeFiles/CMakeTmp/CheckSymbolExists.c:4:14: warning: parameter ‘argc’ set but not used [-Wunused-but-set-parameter]
    4 | int main(int argc, char** argv)
      |          ~~~~^~~~
make[1]: *** [CMakeFiles/cmTC_8744f.dir/build.make:78: CMakeFiles/cmTC_8744f.dir/CheckSymbolExists.c.o] Error 1
make[1]: Leaving directory '/[...]/Downloads/MATLAB/diplib/target/CMakeFiles/CMakeTmp'
make: *** [Makefile:127: cmTC_8744f/fast] Error 2

File /[...]/Downloads/MATLAB/diplib/target/CMakeFiles/CMakeTmp/CheckSymbolExists.c:
/* */
#include <unistd.h>

int main(int argc, char** argv)
{
  (void)argv;
#ifndef setmode
  return ((int*)(&setmode))[argc];
#else
  (void)argc;
  return 0;
#endif
}
Performing C SOURCE FILE Test CMAKE_HAVE_LIBC_PTHREAD failed with the following output:
Change Dir: /[...]/Downloads/MATLAB/diplib/target/CMakeFiles/CMakeTmp

Run Build Command(s):/usr/bin/make -f Makefile cmTC_701e4/fast && /usr/bin/make  -f CMakeFiles/cmTC_701e4.dir/build.make CMakeFiles/cmTC_701e4.dir/build
make[1]: Entering directory '/[...]/Downloads/MATLAB/diplib/target/CMakeFiles/CMakeTmp'
Building C object CMakeFiles/cmTC_701e4.dir/src.c.o
/usr/bin/cc -DCMAKE_HAVE_LIBC_PTHREAD   -o CMakeFiles/cmTC_701e4.dir/src.c.o -c /[...]/Downloads/MATLAB/diplib/target/CMakeFiles/CMakeTmp/src.c
Linking C executable cmTC_701e4
/usr/bin/cmake -E cmake_link_script CMakeFiles/cmTC_701e4.dir/link.txt --verbose=1
/usr/bin/cc CMakeFiles/cmTC_701e4.dir/src.c.o -o cmTC_701e4 
/usr/bin/ld: CMakeFiles/cmTC_701e4.dir/src.c.o: in function `main':
src.c:(.text+0x3e): undefined reference to `pthread_create'
/usr/bin/ld: src.c:(.text+0x4a): undefined reference to `pthread_detach'
/usr/bin/ld: src.c:(.text+0x56): undefined reference to `pthread_cancel'
/usr/bin/ld: src.c:(.text+0x67): undefined reference to `pthread_join'
collect2: error: ld returned 1 exit status
make[1]: *** [CMakeFiles/cmTC_701e4.dir/build.make:99: cmTC_701e4] Error 1
make[1]: Leaving directory '/[...]/Downloads/MATLAB/diplib/target/CMakeFiles/CMakeTmp'
make: *** [Makefile:127: cmTC_701e4/fast] Error 2

Source file was:
#include <pthread.h>

static void* test_func(void* data)
{
  return data;
}

int main(void)
{
  pthread_t thread;
  pthread_create(&thread, NULL, test_func, NULL);
  pthread_detach(thread);
  pthread_cancel(thread);
  pthread_join(thread, NULL);
  pthread_atfork(NULL, NULL, NULL);
  pthread_exit(NULL);

  return 0;
}
wcaarls commented 3 years ago

The error is a bit hard to parse, but the problem is that building DIPimage without a shared library is not supported. Try configuring with "-DDIP_SHARED_LIBRARY=On".

renerichter commented 3 years ago

@wcaarls thank you for the suggestion. dipimage compiled nicely and after running "make -j check" and ..install I started matlab to test my startup script. As suggested on your readme I (in matlab) addpath of the dipimage installation and run "dipimage" to receive the notifcation

Warning: Call to DIPMENUS failed:
Invalid MEX-file '/usr/local/share/DIPimage/measure.mexa64': Missing dependent shared libraries:
'libDIP.so' required by '/usr/local/share/DIPimage/measure.mexa64'
Missing symbol 'calloc@GLIBC_2.2.5' required by '/usr/local/share/DIPimage/measure.mexa64'
Missing symbol '__cxa_allocate_exception@CXXABI_1.3' required by '/usr/local/share/DIPimage/measure.mexa64'
Missing symbol '__cxa_atexit@GLIBC_2.2.5' required by '/usr/local/share/DIPimage/measure.mexa64'
Missing symbol '__cxa_begin_catch@CXXABI_1.3' required by '/usr/local/share/DIPimage/measure.mexa64'
Missing symbol '__cxa_end_catch@CXXABI_1.3' required by '/usr/local/share/DIPimage/measure.mexa64'
Missing symbol '__cxa_free_exception@CXXABI_1.3' required by '/usr/local/share/DIPimage/measure.mexa64'
Missing symbol '__cxa_guard_abort@CXXABI_1.3' required by '/usr/local/share/DIPimage/measure.mexa64'
Missing symbol '__cxa_guard_acquire@CXXABI_1.3' required by '/usr/local/share/DIPimage/measure.mexa64'
Missing symbol '__cxa_guard_release@CXXABI_1.3' required by '/usr/local/share/DIPimage/measure.mexa64'
Missing symbol '__cxa_rethrow@CXXABI_1.3' required by '/usr/local/share/DIPimage/measure.mexa64'
Missing symbol '__cxa_throw@CXXABI_1.3' required by '/usr/local/share/DIPimage/measure.mexa64'
Missing symbol 'free@GLIBC_2.2.5' required by '/usr/local/share/DIPimage/measure.mexa64'
Missing symbol '__gxx_personality_v0@CXXABI_1.3' required by '/usr/local/share/DIPimage/measure.mexa64'
Missing symbol 'malloc@GLIBC_2.2.5' required by '/usr/local/share/DIPimage/measure.mexa64'
Missing symbol 'memcmp@GLIBC_2.2.5' required by '/usr/local/share/DIPimage/measure.mexa64'
Missing symbol 'memcpy@GLIBC_2.14' required by '/usr/local/share/DIPimage/measure.mexa64'
Missing symbol 'memmove@GLIBC_2.2.5' required by '/usr/local/share/DIPimage/measure.mexa64'
Missing symbol 'memset@GLIBC_2.2.5' required by '/usr/local/share/DIPimage/measure.mexa64'
Missing symbol 'mxCreateCharArray@v7.3' required by '/usr/local/share/DIPimage/measure.mexa64'
Missing symbol 'mxCreateDoubleMatrix@v7.3' required by '/usr/local/share/DIPimage/measure.mexa64'
Missing symbol 'mxCreateStructMatrix@v7.3' required by '/usr/local/share/DIPimage/measure.mexa64'
Missing symbol 'mxGetCell@v7.3' required by '/usr/local/share/DIPimage/measure.mexa64'
Missing symbol 'mxGetDimensions@v7.3' required by '/usr/local/share/DIPimage/measure.mexa64'
Missing symbol 'mxGetField@v7.3' required by '/usr/local/share/DIPimage/measure.mexa64'
Missing symbol 'mxGetNumberOfDimensions@v7.3' required by '/usr/local/share/DIPimage/measure.mexa64'
Missing symbol 'mxGetString@v7.3' required by '/usr/local/share/DIPimage/measure.mexa64'
Missing symbol 'mxSetFieldByNumber@v7.3' required by '/usr/local/share/DIPimage/measure.mexa64'
Missing symbol 'mxSetProperty@v7.3' required by '/usr/local/share/DIPimage/measure.mexa64'
Missing symbol 'realloc@GLIBC_2.2.5' required by '/usr/local/share/DIPimage/measure.mexa64'
Missing symbol '__stack_chk_fail@GLIBC_2.4' required by '/usr/local/share/DIPimage/measure.mexa64'
Missing symbol 'strcmp@GLIBC_2.2.5' required by '/usr/local/share/DIPimage/measure.mexa64'
Missing symbol 'strlen@GLIBC_2.2.5' required by '/usr/local/share/DIPimage/measure.mexa64'
Missing symbol 'tolower@GLIBC_2.2.5' required by '/usr/local/share/DIPimage/measure.mexa64'
Missing symbol '_Unwind_Resume@GCC_3.0' required by '/usr/local/share/DIPimage/measure.mexa64'
Missing symbol '_ZdlPvm@CXXABI_1.3.9' required by '/usr/local/share/DIPimage/measure.mexa64'
Missing symbol '_ZN3dip15MeasurementToolC1Ev' required by '/usr/local/share/DIPimage/measure.mexa64'
Missing symbol '_ZN3dip5Image15SpatialToTensorEmmm' required by '/usr/local/share/DIPimage/measure.mexa64'
Missing symbol '_ZN3dip5Image16SetNormalStridesEv' required by '/usr/local/share/DIPimage/measure.mexa64'
Missing symbol '_ZN3dip5Image4CopyERKS0_' required by '/usr/local/share/DIPimage/measure.mexa64'
Missing symbol '_ZN3dip5Image4View4CopyERKS0_' required by '/usr/local/share/DIPimage/measure.mexa64'
Missing symbol '_ZN3dip5Image4View4FillERKNS0_6SampleE' required by '/usr/local/share/DIPimage/measure.mexa64'
Missing symbol '_ZN3dip5Image5ForgeEv' required by '/usr/local/share/DIPimage/measure.mexa64'
Missing symbol '_ZN3dip5Image7ConvertENS_8DataTypeE' required by '/usr/local/share/DIPimage/measure.mexa64'
Missing symbol '_ZN3dip5LabelERKNS_5ImageERS0_mmmSt6vectorINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESaISA_EE' required by '/usr/local/share/DIPimage/measure.mexa64'
Missing symbol '_ZN3dip5UnitsC1ERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE' required by '/usr/local/share/DIPimage/measure.mexa64'
Missing symbol '_ZN3dip8DataType10Class_UIntE' required by '/usr/local/share/DIPimage/measure.mexa64'
Missing symbol '_ZN3dip8DataType13Class_ComplexE' required by '/usr/local/share/DIPimage/measure.mexa64'
Missing symbol '_ZNK3dip15MeasurementTool7MeasureERKNS_5ImageES3_St6vectorINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESaISA_EERKNS_14DimensionArrayImEEm' required by '/usr/local/share/DIPimage/measure.mexa64'
Missing symbol '_ZNK3dip5Image4RealEv' required by '/usr/local/share/DIPimage/measure.mexa64'
Missing symbol '_ZNK3dip5Image9ImaginaryEv' required by '/usr/local/share/DIPimage/measure.mexa64'
Missing symbol '_ZNK3dip5Units20StringRepresentationB5cxx11Eb' required by '/usr/local/share/DIPimage/measure.mexa64'
Missing symbol '_ZNKSt25__codecvt_utf8_utf16_baseIDsE10do_unshiftER11__mbstate_tPcS3_RS3_@GLIBCXX_3.4.21' required by '/usr/local/share/DIPimage/measure.mexa64'
Missing symbol '_ZNKSt25__codecvt_utf8_utf16_baseIDsE11do_encodingEv@GLIBCXX_3.4.21' required by '/usr/local/share/DIPimage/measure.mexa64'
Missing symbol '_ZNKSt25__codecvt_utf8_utf16_baseIDsE13do_max_lengthEv@GLIBCXX_3.4.21' required by '/usr/local/share/DIPimage/measure.mexa64'
Missing symbol '_ZNKSt25__codecvt_utf8_utf16_baseIDsE16do_always_noconvEv@GLIBCXX_3.4.21' required by '/usr/local/share/DIPimage/measure.mexa64'
Missing symbol '_ZNKSt25__codecvt_utf8_utf16_baseIDsE5do_inER11__mbstate_tPKcS4_RS4_PDsS6_RS6_@GLIBCXX_3.4.21' required by '/usr/local/share/DIPimage/measure.mexa64'
Missing symbol '_ZNKSt25__codecvt_utf8_utf16_baseIDsE6do_outER11__mbstate_tPKDsS4_RS4_PcS6_RS6_@GLIBCXX_3.4.21' required by '/usr/local/share/DIPimage/measure.mexa64'
Missing symbol '_ZNKSt25__codecvt_utf8_utf16_baseIDsE9do_lengthER11__mbstate_tPKcS4_m@GLIBCXX_3.4.21' required by '/usr/local/share/DIPimage/measure.mexa64'
Missing symbol '_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE7compareEPKc@GLIBCXX_3.4.21' required by '/usr/local/share/DIPimage/measure.mexa64'
Missing symbol '_ZNSo9_M_insertImEERSoT_@GLIBCXX_3.4.9' required by '/usr/local/share/DIPimage/measure.mexa64'
Missing symbol '_ZNSt12length_errorC1EPKc@GLIBCXX_3.4.21' required by '/usr/local/share/DIPimage/measure.mexa64'
Missing symbol '_ZNSt12length_errorD1Ev@GLIBCXX_3.4' required by '/usr/local/share/DIPimage/measure.mexa64'
Missing symbol '_ZNSt15basic_streambufIcSt11char_traitsIcEE4syncEv@GLIBCXX_3.4' required by '/usr/local/share/DIPimage/measure.mexa64'
Missing symbol '_ZNSt15basic_streambufIcSt11char_traitsIcEE5imbueERKSt6locale@GLIBCXX_3.4' required by '/usr/local/share/DIPimage/measure.mexa64'
Missing symbol '_ZNSt15basic_streambufIcSt11char_traitsIcEE5uflowEv@GLIBCXX_3.4' required by '/usr/local/share/DIPimage/measure.mexa64'
Missing symbol '_ZNSt15basic_streambufIcSt11char_traitsIcEE6setbufEPcl@GLIBCXX_3.4' required by '/usr/local/share/DIPimage/measure.mexa64'
Missing symbol '_ZNSt15basic_streambufIcSt11char_traitsIcEE6xsgetnEPcl@GLIBCXX_3.4' required by '/usr/local/share/DIPimage/measure.mexa64'
Missing symbol '_ZNSt15basic_streambufIcSt11char_traitsIcEE7seekoffElSt12_Ios_SeekdirSt13_Ios_Openmode@GLIBCXX_3.4' required by '/usr/local/share/DIPimage/measure.mexa64'
Missing symbol '_ZNSt15basic_streambufIcSt11char_traitsIcEE7seekposESt4fposI11__mbstate_tESt13_Ios_Openmode@GLIBCXX_3.4' required by '/usr/local/share/DIPimage/measure.mexa64'
Missing symbol '_ZNSt15basic_streambufIcSt11char_traitsIcEE9pbackfailEi@GLIBCXX_3.4' required by '/usr/local/share/DIPimage/measure.mexa64'
Missing symbol '_ZNSt15basic_streambufIcSt11char_traitsIcEE9showmanycEv@GLIBCXX_3.4' required by '/usr/local/share/DIPimage/measure.mexa64'
Missing symbol '_ZNSt15basic_streambufIcSt11char_traitsIcEE9underflowEv@GLIBCXX_3.4' required by '/usr/local/share/DIPimage/measure.mexa64'
Missing symbol '_ZNSt25__codecvt_utf8_utf16_baseIDsED2Ev@GLIBCXX_3.4.21' required by '/usr/local/share/DIPimage/measure.mexa64'
Missing symbol '_ZNSt6localeC1Ev@GLIBCXX_3.4' required by '/usr/local/share/DIPimage/measure.mexa64'
Missing symbol '_ZNSt6localeD1Ev@GLIBCXX_3.4' required by '/usr/local/share/DIPimage/measure.mexa64'
Missing symbol '_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE10_M_replaceEmmPKcm@GLIBCXX_3.4.21' required by '/usr/local/share/DIPimage/measure.mexa64'
Missing symbol '_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_M_constructEmc@GLIBCXX_3.4.21' required by '/usr/local/share/DIPimage/measure.mexa64'
Missing symbol '_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE4swapERS4_@GLIBCXX_3.4.21' required by '/usr/local/share/DIPimage/measure.mexa64'
Missing symbol '_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE6resizeEmc@GLIBCXX_3.4.21' required by '/usr/local/share/DIPimage/measure.mexa64'
Missing symbol '_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE7reserveEm@GLIBCXX_3.4.21' required by '/usr/local/share/DIPimage/measure.mexa64'
Missing symbol '_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE9_M_appendEPKcm@GLIBCXX_3.4.21' required by '/usr/local/share/DIPimage/measure.mexa64'
Missing symbol '_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE9_M_assignERKS4_@GLIBCXX_3.4.21' required by '/usr/local/share/DIPimage/measure.mexa64'
Missing symbol '_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE9_M_createERmm@GLIBCXX_3.4.21' required by '/usr/local/share/DIPimage/measure.mexa64'
Missing symbol '_ZNSt8ios_base4InitC1Ev@GLIBCXX_3.4' required by '/usr/local/share/DIPimage/measure.mexa64'
Missing symbol '_ZNSt8ios_base4InitD1Ev@GLIBCXX_3.4' required by '/usr/local/share/DIPimage/measure.mexa64'
Missing symbol '_ZNSt9bad_allocD1Ev@GLIBCXX_3.4' required by '/usr/local/share/DIPimage/measure.mexa64'
Missing symbol '_ZNSt9basic_iosIcSt11char_traitsIcEE5rdbufEPSt15basic_streambufIcS1_E@GLIBCXX_3.4' required by '/usr/local/share/DIPimage/measure.mexa64'
Missing symbol '_ZNSt9exceptionD2Ev@GLIBCXX_3.4' required by '/usr/local/share/DIPimage/measure.mexa64'
Missing symbol '_Znwm@GLIBCXX_3.4' required by '/usr/local/share/DIPimage/measure.mexa64'
Missing symbol '_ZSt11_Hash_bytesPKvmm@CXXABI_1.3.5' required by '/usr/local/share/DIPimage/measure.mexa64'
Missing symbol '_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l@GLIBCXX_3.4.9' required by '/usr/local/share/DIPimage/measure.mexa64'
Missing symbol '_ZSt17__throw_bad_allocv@GLIBCXX_3.4' required by '/usr/local/share/DIPimage/measure.mexa64'
Missing symbol '_ZSt19__throw_logic_errorPKc@GLIBCXX_3.4' required by '/usr/local/share/DIPimage/measure.mexa64'
Missing symbol '_ZSt19__throw_range_errorPKc@GLIBCXX_3.4' required by '/usr/local/share/DIPimage/measure.mexa64'
Missing symbol '_ZSt20__throw_length_errorPKc@GLIBCXX_3.4' required by '/usr/local/share/DIPimage/measure.mexa64'
Missing symbol '_ZSt4cout@GLIBCXX_3.4' required by '/usr/local/share/DIPimage/measure.mexa64'
Missing symbol '_ZTISt12length_error@GLIBCXX_3.4' required by '/usr/local/share/DIPimage/measure.mexa64'
Missing symbol '_ZTISt15basic_streambufIcSt11char_traitsIcEE@GLIBCXX_3.4' required by '/usr/local/share/DIPimage/measure.mexa64'
Missing symbol '_ZTISt25__codecvt_utf8_utf16_baseIDsE@GLIBCXX_3.4.21' required by '/usr/local/share/DIPimage/measure.mexa64'
Missing symbol '_ZTISt9bad_alloc@GLIBCXX_3.4' required by '/usr/local/share/DIPimage/measure.mexa64'
Missing symbol '_ZTISt9exception@GLIBCXX_3.4' required by '/usr/local/share/DIPimage/measure.mexa64'
Missing symbol '_ZTVN10__cxxabiv117__class_type_infoE@CXXABI_1.3' required by '/usr/local/share/DIPimage/measure.mexa64'
Missing symbol '_ZTVN10__cxxabiv120__si_class_type_infoE@CXXABI_1.3' required by '/usr/local/share/DIPimage/measure.mexa64'
Missing symbol '_ZTVSt15basic_streambufIcSt11char_traitsIcEE@GLIBCXX_3.4' required by '/usr/local/share/DIPimage/measure.mexa64'
Missing symbol '_ZTVSt9bad_alloc@GLIBCXX_3.4' required by '/usr/local/share/DIPimage/measure.mexa64'.

together with a very long error-trace-list on whose end I find:

`Missing symbol 'sysconf@GLIBC_2.2.5' required by
'/usr/lib/libgomp.so.1->/usr/local/share/DIPimage/private/libDIP.so->/usr/local/share/DIPimage/private/numberofthreads.mexa64'
Missing symbol 'vfprintf@GLIBC_2.2.5' required by
'/usr/lib/libgomp.so.1->/usr/local/share/DIPimage/private/libDIP.so->/usr/local/share/DIPimage/private/numberofthreads.mexa64'.

Error in dippreferences (line 76)
      'NumberOfThreads',         struct('type','integer','value',numberofthreads),...

Error in dipgetpref (line 51)
      pref = dippreferences('get',name);

Error in dipinit (line 38)
dipinit_ws = [dipgetpref('DefaultFigureWidth'),dipgetpref('DefaultFigureHeight')];

Error in dipimage/do_start (line 111)
   evalin('base','dipinit');

Error in dipimage (line 48)
   do_start;

So it appears to me that dipLIB.so (as a shared library) is not automatically shifted to its according place even though this is stated during the "make -j check" routine.

wcaarls commented 3 years ago

Hmm, I'm not getting this behavior here. It seems libDIP.so cannot be found, but its path should be hardcoded in the mexfiles. The fact that it's complaining about basic and Matlab-specific symbols is also strange. Can you run

ls /usr/local/lib ldd /usr/local/share/DIPimage/measure.mexa64

and post the output? @crisluengo, any ideas?

crisluengo commented 3 years ago

This is weird. You should have a file /usr/local/lib/libDIP.so. You do need admin privileges to install the file there, so the installation could have failed? I would expect make install to show an error message in that case. This issue would be fixed by doing either sudo make install, or configuring the build to install in $HOME.

renerichter commented 3 years ago

Hiho, please excuse my late reply and thank you for your thoughts. Here are my comments:

ls /usr/local/lib I ran it with access listing and this is the result:

drwxr-xr-x  3 root root 4.0K May 20 15:46 cmake
-rw-r--r--  1 root root 5.5K May 21 16:51 DIPjavaio.jar
-rwxr-xr-x  1 root root  83K May 21 16:51 libDIPjavaio.so
-rwxr-xr-x  1 root root  17M May 21 16:50 libDIP.so
-rwxr-xr-x  1 root root 439K May 21 16:51 libDIPviewer.so

ldd /usr/local/share/DIPimage/measure.mexa64

linux-vdso.so.1 (0x00007ffe13d6a000)
libmex.so => not found
libmx.so => not found
libDIP.so => /usr/local/share/DIPimage/../../lib/libDIP.so (0x00007f8c9ab6b000)
libstdc++.so.6 => /usr/lib/libstdc++.so.6 (0x00007f8c9a98e000)
libgcc_s.so.1 => /usr/lib/libgcc_s.so.1 (0x00007f8c9a974000)
libc.so.6 => /usr/lib/libc.so.6 (0x00007f8c9a7a7000)
libfftw3f.so.3 => /usr/lib/libfftw3f.so.3 (0x00007f8c9a557000)
libfftw3f_threads.so.3 => /usr/lib/libfftw3f_threads.so.3 (0x00007f8c9a54e000)
libfftw3.so.3 => /usr/lib/libfftw3.so.3 (0x00007f8c9a309000)
libfftw3_threads.so.3 => /usr/lib/libfftw3_threads.so.3 (0x00007f8c9a300000)
libgomp.so.1 => /usr/lib/libgomp.so.1 (0x00007f8c9a2bf000)
libpthread.so.0 => /usr/lib/libpthread.so.0 (0x00007f8c9a29e000)
libm.so.6 => /usr/lib/libm.so.6 (0x00007f8c9a157000)
/usr/lib64/ld-linux-x86-64.so.2 (0x00007f8c9b9fa000)
libdl.so.2 => /usr/lib/libdl.so.2 (0x00007f8c9a150000)

This issue would be fixed by doing either sudo make install,

Installation of dipimage was performed via sudo make -j install (as was matlab btw).

Thank you for your thoughts. It seems that maybe my system or the matlab installation is misconfigured...

crisluengo commented 3 years ago

So it does know where to find libDIP.so. I’m guessing then that the “Missing dependent shared libraries: 'libDIP.so'” error is not because it is missing, but because it cannot be loaded.

And that could be caused by using a newer version of the GCC libraries than what MATLAB uses. MATLAB ships (used to ship, not sure if they still do this) a copy of the GCC libraries it uses. Those libraries are loaded before your MEX-file, so when your MEX-file loads, the preloaded GCC libs have missing symbols, preventing libDIP.so from properly loading.

The “official” solution from MathWorks is to use only the GCC version that is compatible with your version of MATLAB.

The non-supported solution, which I’ve successfully used in the past (but I haven’t used MATLAB on Linux in quite a while), is to delete the GCC libs that come with MATLAB, so that MATLAB uses the newer ones you have in your system folder. GCC is pretty good with backward-compatibility, so this should not be a problem. If you move the libraries away, or rename them, then you can see if MATLAB loads properly without them, and can restore them if you find a problem.

The libraries to be removed are in <matlabroot>/sys/os/glnxa64. You can type matlabroot at the MATLAB command prompt to find its root directory.

You probably should remove libstdc++.so.6, libglib-2.0.so and libgomp.so. Each of these should have a corresponding version under usr/lib/, which MATLAB will then use instead of its own copy.

Related: https://www.mathworks.com/support/bugreports/1297894 (requires MATLAB account).

renerichter commented 3 years ago

the compatible compiler seems to be GCC4.9.x

On my linux, the $matlabroot is not set and hence I used matlab -n to get system-data, leading to paths like:

MATLAB              = /usr/local/MATLAB/R2017b
ARCH                = glnxa64
TOOLBOX             = /usr/local/MATLAB/R2017b/toolbox
LD_LIBRARY_PATH     = /usr/local/MATLAB/R2017b/sys/opengl/lib/glnxa64:/usr/local/MATLAB/R2017b/sys/os/glnxa64:/u
sr/local/MATLAB/R2017b/bin/glnxa64:/usr/local/MATLAB/R2017b/extern/lib/glnxa64:/usr/local/MATLAB/R2017b/sys/java/jre/gln
xa64/jre/lib/amd64/native_threads:/usr/local/MATLAB/R2017b/sys/java/jre/glnxa64/jre/lib/amd64/server

The folder matlabroot/sys/os/glnxa64 holds:

libgcc_s.so.1         libifcore.so.5  libintlc.so.5  libquadmath.so.0      libstdc++.so.6.0.20
libgfortran.so.3      libifport.so.5  libiomp5.so    libquadmath.so.0.0.0  libsvml.so
libgfortran.so.3.0.0  libimf.so       libirc.so      libstdc++.so.6        README.libstdc++

Hence: I excluded libstdc++.so.6 and made sure it exists under /usr/lib. Starting matlab leads now to

com.jogamp.opengl.GLException: X11GLXDrawableFactory - Could not initialize shared resources for X11GraphicsDevice[type .x11, connection :0.0, unitID 0, handle 0x0, owner false, ResourceToolkitLock[obj 0x1fb8f100, isOwner false, <6938702d, 124595c1>[count 0, qsz 0, owner <NULL>]]]
    at jogamp.opengl.x11.glx.X11GLXDrawableFactory$SharedResourceImplementation.createSharedResource(X11GLXDrawableFactory.java:326)
    at jogamp.opengl.SharedResourceRunner.run(SharedResourceRunner.java:297)
    at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.NullPointerException
    at jogamp.opengl.GLContextImpl.makeCurrent(GLContextImpl.java:688)
    at jogamp.opengl.GLContextImpl.makeCurrent(GLContextImpl.java:580)
    at jogamp.opengl.x11.glx.X11GLXDrawableFactory$SharedResourceImplementation.createSharedResource(X11GLXDrawableFactory.java:297)
    ... 2 more

Which seems uncorrelated to dipimage and is a problem of my installation under linux. I never saw this error before and will try to trace that. Further I ran dipimage which for now starts without any direct error except a follow-up from the x11 error.

MATLAB has experienced a low-level graphics error, and may not have drawn correctly.
Read about what you can do to prevent this issue at Resolving Low-Level Graphics Issues then restart MATLAB.
To share details of this issue with MathWorks technical support,
please include this file with your service request.

Thank you very much for your help so far. I wouldn't have made it here without your support!

crisluengo commented 3 years ago

Thank you for your perseverance! This is good experience for us, will make it much easier on the next person with a similar issue.

So R2017b was build with GCC 4.9?! Ouch!

Your new error message seems related to the OpenGL driver. I’m sure you already found this: https://www.mathworks.com/matlabcentral/answers/342906-could-not-initialize-shared-resources-for-x11graphicsdevice

By the way, matlabroot is a command in MATLAB. But matlab -n is a good solution as well.

renerichter commented 3 years ago

Thank you for pointing me to the right mathworks-discussion on the topic. Starting matlab from commandline via export MESA_LOADER_DRIVER_OVERRIDE=i965; matlab solved the issue for me for now. Awesome!

I tested FT2D in the GUI (cmd=dipimage) with an arbitrary rr(128,128) image and it works nicely, while it seems that "dip_fouriertransform" is no longer part of the library. I thus cannot evaluate a=rr(128,128);dip_fouriertransform(a,'forward',[1 1]) which I believe was working with DIPimage (DIPlib) 2.x before. Or is there any mistake?

Further in the installation instruction it is stated that addpath('/usr/share/DIPimage') should be part of the MATLAB startup script, but my DIP installation is actually in addpath('/usr/local/share/DIPimage'). Shall this be updated or does it change per system?

crisluengo commented 3 years ago

Thanks for pointing this out, I will update the installation instructions to be more clear about this. You need to add the path where DIPimage was installed, which is configurable in CMake. I guess the default installation root is /usr/local/, not /usr/, on Linux.

One big change from DIPimage 2.9 to 3.0 is the removal of all dip_xxx low-level functions. The "normal" interface has always been easier to use, and is the one that is preserved in 3.0. dip_fouriertransform(a,'forward',[1 1]) is the same as ft(a), just a lot harder to type... Also check the 'symmetric' option to ft for compatibility with 2.9.

At the bottom of the change log you'll find a list of all old dip_xxx functions and the corresponding function to use instead.

renerichter commented 3 years ago

thank you for pointing this out. To make DIPlib3.0 compatible with our existing code we wrote some new overrides such that it just smoothely works as before, but hence dip_filter is not reachable anymore as well (at least on Linux)?

crisluengo commented 3 years ago

I don't have a dip_filter in 2.9 either? Are you sure it's not custom code?

renerichter commented 3 years ago

We are checking this internally now, as developing with the "dip_filter" routine is not part of my code-base. Sorry for the confusion!

While ft works like a charm I encountered that (by forcing an error eg using array-dimensions starting from 0) dipimage uses the header files of the folder used for its compilation, so eg

>>> a=rr(16,16);ft(a,'symmetric',[0,1])

Error using dip_filtering
Process array contains index out of range
in function: dip::BooleanArray dml::GetProcessArray(const mxArray*, dip::uint) (/home/.../Downloads/MATLAB/diplib/include/dip_matlab_interface.h
at line number 267)

Error in ft (line 71)
out = dip_filtering('ft',in,options,varargin{:});

Wouldn't it be better if these header-files would be included/used from somewhere like /usr/local/share/DIPimage? But find /usr/local/share/DIPimage/ -name "*.h" returns nothing. Maybe my installation configuration is wrong?

crisluengo commented 3 years ago

DIPimage uses those header files only at compile time. The file name locations are generated at compile time and embedded in the MEX-file and/or libDIP.dylib. If you turn off the stack trace generation in CMake when building DIPimage, you will not see those messages.

I appreciate these questions. It is good to have answers for them online, surely other people will have the same questions. But I worry that they’ll be hard to find this way. Could you please open a new issue for each distinct question? That way they will be easier to find, I hope.

Since your original problem was solved, I will close this issue. Feel free to reopen if the problems building DIPimage reappear.