vid.stab icon indicating copy to clipboard operation
vid.stab copied to clipboard

1.1.0 breaks compilation under clang

Open mqudsi opened this issue 6 years ago • 5 comments

mqudsi@Blitzkrieg /m/d/G/FFmpeg> ./configure --enable-libvidstab --enable-gpl
ERROR: vidstab >= 0.98 not found using pkg-config

If you think configure made a mistake, make sure you are using the latest
version from Git.  If the latest version fails, report the problem to the
[email protected] mailing list or IRC #ffmpeg on irc.freenode.net.
Include the log file "ffbuild/config.log" produced by configure as this will help
solve the problem.
mqudsi@Blitzkrieg /m/d/G/FFmpeg> pkg-config --cflags --libs "vidstab >= 0.98"
-I/usr/local/include -L/usr/local/lib -lvidstab -lm -lgomp -lpthread

ffmpeg's configure script tries to compile the following, which fails:

#include <vid.stab/libvidstab.h>
#include <stdint.h>
long check_vsMotionDetectInit(void) { return (long) vsMotionDetectInit; }
int main(void) { int ret = 0;
ret |= ((intptr_t)check_vsMotionDetectInit) & 0xFFFF;
return ret; }

compiling it myself:

mqudsi@Blitzkrieg /m/d/G/FFmpeg> clang (pkg-config --cflags --libs vidstab | string split ' ') ./test.c -o test
/usr/local/lib/libvidstab.so: undefined reference to `__kmpc_end_critical'
/usr/local/lib/libvidstab.so: undefined reference to `__kmpc_for_static_fini'
/usr/local/lib/libvidstab.so: undefined reference to `__kmpc_fork_call'
/usr/local/lib/libvidstab.so: undefined reference to `__kmpc_for_static_init_4'
/usr/local/lib/libvidstab.so: undefined reference to `__kmpc_critical'
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Corrected by modifying vidstab.pc to include -fopenmp=libomp:

# file generated by vid.stab cmake build
prefix=/usr/local
libdir=/usr/local/lib
includedir=/usr/local/include

Name: vidstab
Description: Vid.Stab, a library for stabilizing video clips
Version: 1.10
Libs: -L${libdir} -lvidstab -lm -lgomp -lpthread -fopenmp=libomp
Cflags: -I${includedir}

I'm not familiar enough with OpenMP to determine if this is safe to add universally.

mqudsi avatar Sep 15 '18 16:09 mqudsi

Hi, I think openmp should be fairly standard. I think you can safely add it universally.

georgmartius avatar Sep 16 '18 19:09 georgmartius

Sure, but should the particular openmp library (=libomp) be hardcoded?

mqudsi avatar Sep 16 '18 21:09 mqudsi

I don't know a better way. Not sure whether the dependencies in the packages have to be updated as well.

georgmartius avatar Sep 17 '18 06:09 georgmartius

I have this issue as well, when using clang > 7.0 you don't need to specify -lgomp

in the CmakeLists.txt change

if(USE_OMP)
  add_definitions(-fopenmp -DUSE_OMP)
endif()

to

if(USE_OMP)
  find_package(OpenMP)
  if(OpenMP_CXX_FOUND)
    target_link_libraries(OpenMP::OpenMP_CXX)
  endif()
endif()

and this

if(USE_OMP)
  target_link_libraries(vidstab gomp)
  set(PKG_EXTRA_LIBS "${PKG_EXTRA_LIBS} -lgomp -lpthread")
endif()

to

if(USE_OMP)
  target_link_libraries(vidstab)
  set(PKG_EXTRA_LIBS "${PKG_EXTRA_LIBS} -lpthread")
endif()

museum-future avatar Dec 16 '19 09:12 museum-future

I have another way to solve this problem add CFLAGS to -fopenmp my build environment: linux mint Linux Mint 19.3 LLVM 9.0.0 Pre-Built Binaries:

charles1018 avatar Dec 31 '19 03:12 charles1018