Hi!

here is a short reproducer:


-------------- jni.c --------------
#include <jni.h>
#include <x265.h>
JNIEXPORT jint JNICALL Java_factorial_fact(JNIEnv *env, jobject obj)
{
    x265_param *param = x265_param_alloc();
    x265_param_free(param);
    return 0;
}
-------------- jni.c --------------


# then compile like this

mkdir -p /tmp/install/
_INST_=/tmp/install/
git clone https://bitbucket.org/multicoreware/x265_git.git
cd x265_git/
git checkout 1d117bed4747758b51bd2c124d738527e30392cb
cmake source/. -DCMAKE_INSTALL_PREFIX="$_INST_" -DENABLE_PIC=ON 
-DENABLE_ASSEMBLY=ON
make
make install

gcc -O2 -g -fPIC -Wall -I/usr/lib/jvm/java-17-openjdk-amd64/include/ \
 -I/usr/lib/jvm/java-17-openjdk-amd64/include/linux/ -I"$_INST_"/include 
./jni.c $_INST_/lib/libx265.a -shared -Wl,-soname,libjni.so -o libjni.so

/usr/bin/ld: /tmp/install//lib/libx265.a(cpu-a.asm.o): warning: relocation 
against `x265_intel_cpu_indicator_init' in read-only section `.text'
/usr/bin/ld: /tmp/install//lib/libx265.a(cpu-a.asm.o): relocation R_X86_64_PC32 
against symbol `x265_intel_cpu_indicator_init' can not be used when making a 
shared object; recompile with -fPIC
/usr/bin/ld: final link failed: bad value


        cheers,
        Zoff.

On 30.11.24 20:03, Zoff wrote:
Hi!

i am trying to compile x265 encoder library for linux (amd64) as a static lib 
and then
making a shared JNI lib for java with it.
if i do this:

git clone https://bitbucket.org/multicoreware/x265_git.git
cd x265_git/
git checkout 1d117bed4747758b51bd2c124d738527e30392cb
cmake . -DCMAKE_INSTALL_PREFIX="$_INST_" -DNATIVE_BUILD=ON -DENABLE_PIC=ON

everything works fine, but the i don't get asm optimizations.

if i do this:

cmake . -DCMAKE_INSTALL_PREFIX="$_INST_" -DNATIVE_BUILD=ON -DENABLE_PIC=ON 
-DENABLE_ASSEMBLY=ON

and the link my final JNI lib i get this error:

libx265.a(cpu-a.asm.o): relocation R_X86_64_PC32 against symbol 
`x265_intel_cpu_indicator_init' can not be used when making a shared object; 
recompile with -fPIC

to the best of my knowledge everything is compiled with FPIC. any ideas why 
this is not working?

     cheers,
     Zoff.

_______________________________________________
x265-devel mailing list
[email protected]
https://mailman.videolan.org/listinfo/x265-devel


_______________________________________________
x265-devel mailing list
[email protected]
https://mailman.videolan.org/listinfo/x265-devel

Reply via email to