How to compile Graal Native Image on MacOs BigSur? - gradle

When I try to compile with ./gradlew nativeCompile
java -version
openjdk version "17.0.5" 2022-10-18
OpenJDK Runtime Environment GraalVM CE 22.3.0 (build 17.0.5+8-jvmci-22.3-b08)
OpenJDK 64-Bit Server VM GraalVM CE 22.3.0 (build 17.0.5+8-jvmci-22.3-b08, mixed mode, sharing)
native-image --version
GraalVM 22.3.0 Java 17 CE (Java Version 17.0.5+8-jvmci-22.3-b08)
Error: Error compiling query code (in /var/folders/zr/ctjr8g2574ggz5xjzrd6jyxw0000gn/T/SVM-4935784945826410470/PosixDirectives.c). Compiler command '/usr/bin/cc -Wall -Werror -Wno-tautological-compare -ObjC -o /var/folders/zr/ctjr8g2574ggz5xjzrd6jyxw0000gn/T/SVM-4935784945826410470/PosixDirectives /var/folders/zr/ctjr8g2574ggz5xjzrd6jyxw0000gn/T/SVM-4935784945826410470/PosixDirectives.c' output included error: /Library/Developer/CommandLineTools/SDKs/MacOSX12.1.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSBundle.h:91:143: error: function does not return NSString
Error: Use -H:+ReportExceptionStackTraces to print stacktrace of underlying exception
The stack-trace isn't any more useful, the error has something to do about a function not returning NSString.
Error: Error compiling query code (in /var/folders/zr/ctjr8g2574ggz5xjzrd6jyxw0000gn/T/SVM-17577305799927673130/PosixDirectives.c). Compiler command '/usr/bin/cc -Wall -Werror -Wno-tautological-compare -ObjC -o /var/folders/zr/ctjr8g2574ggz5xjzrd6jyxw0000gn/T/SVM-17577305799927673130/PosixDirectives /var/folders/zr/ctjr8g2574ggz5xjzrd6jyxw0000gn/T/SVM-17577305799927673130/PosixDirectives.c' output included error: /Library/Developer/CommandLineTools/SDKs/MacOSX12.1.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSBundle.h:91:143: error: function does not return NSString
com.oracle.svm.core.util.UserError$UserException: Error compiling query code (in /var/folders/zr/ctjr8g2574ggz5xjzrd6jyxw0000gn/T/SVM-17577305799927673130/PosixDirectives.c). Compiler command '/usr/bin/cc -Wall -Werror -Wno-tautological-compare -ObjC -o /var/folders/zr/ctjr8g2574ggz5xjzrd6jyxw0000gn/T/SVM-17577305799927673130/PosixDirectives /var/folders/zr/ctjr8g2574ggz5xjzrd6jyxw0000gn/T/SVM-17577305799927673130/PosixDirectives.c' output included error: /Library/Developer/CommandLineTools/SDKs/MacOSX12.1.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSBundle.h:91:143: error: function does not return NSString
at org.graalvm.nativeimage.builder/com.oracle.svm.core.util.UserError.abort(UserError.java:139)
at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.c.NativeLibraries.reportErrors(NativeLibraries.java:371)
at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.NativeImageGenerator.processNativeLibraryImports(NativeImageGenerator.java:1715)
at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.NativeImageGenerator.setupNativeLibraries(NativeImageGenerator.java:1121)
at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.NativeImageGenerator.setupNativeImage(NativeImageGenerator.java:915)
at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.NativeImageGenerator.doRun(NativeImageGenerator.java:575)
at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.NativeImageGenerator.run(NativeImageGenerator.java:535)
at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.NativeImageGeneratorRunner.buildImage(NativeImageGeneratorRunner.java:403)
at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.NativeImageGeneratorRunner.build(NativeImageGeneratorRunner.java:580)
at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.NativeImageGeneratorRunner.main(NativeImageGeneratorRunner.java:128)

Related

Failed to test on bazel due to issues with c++ version required

BUILD.bazel:69:11: Compiling absl/numeric/int128.cc failed: (Exit 1):
gcc failed: error executing command
/opt/rh/devtoolset-3/root/usr/bin/gcc -U_FORTIFY_SOURCE
-fstack-protector -Wall -Wunused-but-set-parameter -Wno-free-nonheap-object -fno-omit-frame-pointer '-std=c++0x' -MD -MF ...
gcc: error: unrecognized command line option '-std=c++17'
$ gcc --version
gcc (GCC) 8.3.1 20190311 (Red Hat 8.3.1-3)
Why is the old version of GCC being used when I have the newer GCC (v8) already installed in my centOS?
Initially I upgraded the gcc version from 4.8 to 8 but it is still not working

GCC undefined reference to thrd_create() in C11 mode after #include <threads.h> in Debian

I'm trying to compile a program that I've been able to compile on several other Debian environments with no issues using the C11 <threads.h> library on a relatively fresh install of Debian Bullseye with "gcc (Debian 10.2.1-6) 10.2.1 20210110" installed
with the command
gcc -o <progname> -O3 -Wall -Wextra -std=c11 -lpthread <sourcefile>
and I'm getting a string of linker errors in the form of
undefined reference to 'mtx_unlock'
as well as mtx_lock mtx_init thrd_create etc.
But I'm not getting an error saying the threads.h file is absent. I tried removing the -lpthread argument from the compilation command but this changed nothing.
What is going wrong?
The correct command line parameter seems to be -pthread without the l.

How to use NDK wth gcc on Android?

I need to compile OpenCV 2 to test some things and it can only be built with gcc. I tried downloading the oldest NDK in Android Studio which is version 16, however it still tries to use clang. How can I force it to use gcc?
Error on version 16:
ERROR: /home/user/AndroidStudioProjects/opencv2builder/app/src/main/cpp/CMakeLists.txt : C/C++ debug|x86 : CMake Error at /home/user/Android/Sdk/cmake/3.10.2.4988404/share/cmake-3.10/Modules/CMakeTestCCompiler.cmake:52 (message):
The C compiler
"/home/user/Android/Sdk/ndk/16.1.4479499/toolchains/llvm/prebuilt/linux-x86_64/bin/clang"
is not able to compile a simple test program.
It fails with the following output:
Change Dir: /home/user/AndroidStudioProjects/opencv2builder/app/.cxx/cmake/debug/x86/CMakeFiles/CMakeTmp
Run Build Command:"/home/user/Android/Sdk/cmake/3.10.2.4988404/bin/ninja" "cmTC_ed369"
[1/2] Building C object CMakeFiles/cmTC_ed369.dir/testCCompiler.c.o
FAILED: CMakeFiles/cmTC_ed369.dir/testCCompiler.c.o
/home/user/Android/Sdk/ndk/16.1.4479499/toolchains/llvm/prebuilt/linux-x86_64/bin/clang --target=i686-none-linux-android --gcc-toolchain=/home/user/Android/Sdk/ndk/16.1.4479499/toolchains/x86-4.9/prebuilt/linux-x86_64 --sysroot=/home/user/Android/Sdk/ndk/16.1.4479499/sysroot -isystem /home/user/Android/Sdk/ndk/16.1.4479499/sysroot/usr/include/i686-linux-android -D__ANDROID_API__=16 -g -DANDROID -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -mstackrealign -Wa,--noexecstack -Wformat -Werror=format-security -fPIE -o CMakeFiles/cmTC_ed369.dir/testCCompiler.c.o -c testCCompiler.c
/home/user/Android/Sdk/ndk/16.1.4479499/toolchains/llvm/prebuilt/linux-x86_64/bin/clang: error while loading shared libraries: libncurses.so.5: cannot open shared object file: No such file or directory
ninja: build stopped: subcommand failed.
CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
CMakeLists.txt
Affected Modules: app

Rstudio unable to install package devtools: gcc error

I want to install package devtools. But after successful downloading of all dependencies, it gives error while installing of the form:
gcc -std=gnu99 -I/usr/share/R/include -DNDEBUG -fpic -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g -c rawmatch.c -o rawmatch.o
gcc: error: unrecognized command line option ‘-fstack-protector-strong’
gcc: error: unrecognized command line option ‘-Wdate-time’
/usr/lib/R/etc/Makeconf:159: recipe for target 'rawmatch.o' failed
make: *** [rawmatch.o] Error 1
ERROR: compilation failed for package ‘mime’
* removing ‘/usr/local/lib/R/site-library/mime’
I have checked gcc. I am able to run a sample c program file from terminal.
It seems you'll need to use a more recent gcc version, 4.9 at least.
Both unrecognized options, -fstack-protector-strong and -Wdate-time, were introduced in gcc 4.9 (release notes).

Error on compilation of x264 on qnap

We are facing issues on compiling x264 on qnap.
We need to compile ffmpeg with x264 library, qnap packages have the built-in x264 0.66 library but ffmpeg-0.9.2 doesn't support too old version of x264 and produces the following error on compiling x264 from source.
[/share/MD0_DATA/.qpkg/x264-snapshot-20130208-2245] # make
gcc -Wshadow -O3 -ffast-math -m32 -Wall -I. -I. -march=i686 -mfpmath=sse -msse -std=gnu99 -I/opt/include -I/opt/include -fomit-frame-pointer -fno-tree-vectorize -c -o x264.o x264.c
x264.c: In function 'help':
x264.c:401: error: 'X264_VERSION' undeclared (first use in this function)
x264.c:401: error: (Each undeclared identifier is reported only once
x264.c:401: error: for each function it appears in.)
make: *** [x264.o] Error 1
[/share/MD0_DATA/.qpkg/x264-snapshot-20130208-2245] # cat /proc/version
Linux version 2.6.33.2 (root#NasX86-4) (gcc version 4.1.3 20070929 (prerelease) (Ubuntu 4.1.2-16ubuntu2)) #1 SMP Wed Dec 5 06:48:23 CST 2012
Can someone assist me on that ?
Probably version.sh does not have execution permission. So, chmod 744 version.sh then retry configure and make.
X264_VERSION define is generated in x264_config.h during configure script execution by calling to version.sh. So either it wasn't generated in x264_config.h (some fault of your building environment and need analyze of config.log) or you have old x264.h headers somewhere in you include path which for some reason used instead of new one.
Removing --prefix="path" from the ./configure arguments fixed this error for me.

Resources