Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to add a custom external library? #91

Open
Kyant0 opened this issue Apr 15, 2024 · 7 comments
Open

How to add a custom external library? #91

Kyant0 opened this issue Apr 15, 2024 · 7 comments

Comments

@Kyant0
Copy link

Kyant0 commented Apr 15, 2024

I want to use libopenmpt, and I adapted the scripts, it gives me error: ERROR: libopenmpt >= 0.2.6557 not found using pkg-config.
But there is already a file created, and the version meets the requirement.
image
image

Here's my script:
libopenmpt.zip

@Javernaut
Copy link
Owner

Such a message usually is posted if any failure happens during the FFmpeg's checking of a given library. Most probably a compilation error happens: FFmpeg tries to compile a test program that uses the library, checking if it is actually available. You can find more details of what is actually happening in: ffmpeg-android-maker/sources/ffmpeg/actualDirectory/ffbuild/config.log, usually at the very end. This file is generated after FFmpeg's configure script execution (this is done by ffmpeg-android-maker's execution)

@Kyant0
Copy link
Author

Kyant0 commented Apr 15, 2024

BEGIN /tmp/ffconf.1yQJTgAY/test.c
    1	#include <libmodplug/modplug.h>
    2	#include <stdint.h>
    3	long check_ModPlug_Load(void) { return (long) ModPlug_Load; }
    4	int main(void) { int ret = 0;
    5	 ret |= ((intptr_t)check_ModPlug_Load) & 0xFFFF;
    6	return ret; }
END /tmp/ffconf.1yQJTgAY/test.c
/home/kyant/android-ndk-r26c/toolchains/llvm/prebuilt/linux-x86_64/bin/armv7a-linux-androideabi26-clang --sysroot=/home/kyant/android-ndk-r26c/toolchains/llvm/prebuilt/linux-x86_64/sysroot -D_ISOC11_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -Dstrtod=avpriv_strtod -DPIC -O3 -fPIC -DMODPLUG_STATIC -I/home/kyant/FFMPEG/ffmpeg-android-maker-master/build/external/armeabi-v7a/include -std=c17 -fPIE -fomit-frame-pointer -fPIC -marm -I/home/kyant/FFMPEG/ffmpeg-android-maker-master/build/external/armeabi-v7a/include -L/home/kyant/FFMPEG/ffmpeg-android-maker-master/build/external/armeabi-v7a/lib -c -o /tmp/ffconf.1yQJTgAY/test.o /tmp/ffconf.1yQJTgAY/test.c
clang-17: warning: argument unused during compilation: '-L/home/kyant/FFMPEG/ffmpeg-android-maker-master/build/external/armeabi-v7a/lib' [-Wunused-command-line-argument]
/home/kyant/android-ndk-r26c/toolchains/llvm/prebuilt/linux-x86_64/bin/armv7a-linux-androideabi26-clang -s -L/home/kyant/FFMPEG/ffmpeg-android-maker-master/build/external/armeabi-v7a/lib -lstdc++ -lm --sysroot=/home/kyant/android-ndk-r26c/toolchains/llvm/prebuilt/linux-x86_64/sysroot -Wl,--as-needed -Wl,-z,noexecstack -fPIE -pie -I/home/kyant/FFMPEG/ffmpeg-android-maker-master/build/external/armeabi-v7a/include -L/home/kyant/FFMPEG/ffmpeg-android-maker-master/build/external/armeabi-v7a/lib -o /tmp/ffconf.1yQJTgAY/test /tmp/ffconf.1yQJTgAY/test.o -lmodplug -lstdc++ -lm
ld.lld: error: /home/kyant/FFMPEG/ffmpeg-android-maker-master/build/external/armeabi-v7a/lib/libmodplug.so is incompatible with armelf_linux_eabi
clang-17: error: linker command failed with exit code 1 (use -v to see invocation)
ERROR: libmodplug not found using pkg-config

@Kyant0
Copy link
Author

Kyant0 commented Apr 15, 2024

I tried a different library called libmodplug, it also gives me that.
It's strange to link to libmodplug.so while I am building a static lib. When I build libmodplug to a shared lib it still doesn't work. Here is my part of config.

./configure
--prefix=${BUILD_DIR_FFMPEG}/${ANDROID_ABI}
--enable-cross-compile
--target-os=android
--arch=${TARGET_TRIPLE_MACHINE_ARCH}
--sysroot=${SYSROOT_PATH}
--cc=${FAM_CC}
--cxx=${FAM_CXX}
--ld=${FAM_LD}
--ar=${FAM_AR}
--as=${FAM_CC}
--nm=${FAM_NM}
--ranlib=${FAM_RANLIB}
--strip=${FAM_STRIP}
--extra-cflags="-O3 -fPIC -DMODPLUG_STATIC $DEP_CFLAGS"
--extra-ldflags="-s $DEP_LD_FLAGS"
--pkgconfigdir=${PKG_CONFIG_LIBDIR}
--pkg-config=$(which pkg-config)
--pkg-config-flags="--static"
--disable-static
--enable-shared \

@Kyant0
Copy link
Author

Kyant0 commented Apr 15, 2024

I really have no idea about it. I think it's because of the misuse of NDK toolchain. But it's indeed the corresponding architecture.

@Javernaut
Copy link
Owner

What exact library are you trying to integrate? It's just you mentioned 2 already.

It would also be helpful if you could provide a fork repo with a branch with all your changes, so there is no need to manually paste your code and add the missing parts (like the argument parsing).

Probably, I'll have some time for this issue this week, though I'm focussed on a different thing now.

@Kyant0
Copy link
Author

Kyant0 commented Apr 15, 2024

https://github.com/Konstanty/libmodplug/tree/master

build.sh:

#!/usr/bin/env bash

autoreconf -i ${SCRIPTS_DIR}/../sources/libmodplug/libmodplug-master

${SCRIPTS_DIR}/../sources/libmodplug/libmodplug-master/configure \
    --prefix=${INSTALL_DIR} \
    --host=${TARGET} \
    --with-sysroot=${SYSROOT_PATH} \
    --enable-shared \
    --disable-static \
    --with-pic \
    CC=${FAM_CC} \
    AR=${FAM_AR} \
    RANLIB=${FAM_RANLIB} \
    CFLAGS="${CFLAGS} -DBUILD_SHARED_LIBS" \
    CMAKEFLAGS="-DANDROID_ABI=arm64-v8a" \
    ${ADDITIONAL_FLAGS} || exit 1

export FFMPEG_EXTRA_LD_FLAGS="${FFMPEG_EXTRA_LD_FLAGS} -lm"

${MAKE_EXECUTABLE} clean
${MAKE_EXECUTABLE} -j${HOST_NPROC}
${MAKE_EXECUTABLE} install

Error:
ld.lld: error: /home/kyant/FFMPEG/ffmpeg-android-maker-master/build/external/arm64-v8a/lib/libmodplug.so is incompatible with aarch64linux

@Kyant0
Copy link
Author

Kyant0 commented Apr 15, 2024

image It's x86-64, but when I compile it by using `./ffmpeg-android-maker.sh -abis=arm64-v8a -android=26 --source-git-branch=release/7.0 --enable-libmodplug`, it shows something about arm64

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants