Javernaut / ffmpeg-android-maker

Contains a script that assembles FFmpeg library for Android
MIT License
587 stars 172 forks source link

how to link libx265 with libstdc++.so? #75

Open null4n opened 1 year ago

null4n commented 1 year ago

in my fork, I want to add libx265. but while I only link libx265, the binary will load libx265.so.188. If I add export FFMPEG_EXTRA_LD_FLAGS="${FFMPEG_EXTRA_LD_FLAGS} -lc++" in build.sh , it load libc++_shared.so in NDK. how to link libstdc++.so in /system/lib64/?

BTW my fork has add fdk-aac successed

Javernaut commented 1 year ago

Hello. I didn't try integrating the libx265 yet and have no answer.

Javernaut commented 8 months ago

@null4n

Better later than never)

Recently I added libx265 support to this project. Didn't have any c++ runtime specific problems. I noticed the libavformat.so depends on libc++_shared.so, like you described.

I don't know if this issue is still relevant, but why do you need exactly the libstdc++.so? According to the NDK's docs it is better to use the superior libc++_shared.so instead.

null4n commented 8 months ago

I build the static binary. After I change script/ffmpeg/build.sh with --disable-shared --enable-static, the binary still need "libc++_shared.so" to execute

Oleksandr Berezhnyi @.***> 於 2023年12月29日 週五 01:33 寫道:

@null4n https://github.com/null4n

Better later than never)

Recently I added libx265 support to this project. Didn't have any c++ runtime specific problems. I noticed the libavformat.so depends on libc++_shared.so, like you described.

I don't know if this issue is still relevant, but why do you need exactly the libstdc++.so? According to the NDK's docs https://developer.android.com/ndk/guides/cpp-support#system it is better to use the superior libc++_shared.so instead.

— Reply to this email directly, view it on GitHub https://github.com/Javernaut/ffmpeg-android-maker/issues/75#issuecomment-1871367610, or unsubscribe https://github.com/notifications/unsubscribe-auth/AHXIO5S26URJXGRBBH7IG4LYLWUOXAVCNFSM6AAAAAAWKEQ27KVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQNZRGM3DONRRGA . You are receiving this because you were mentioned. Message ID: @.*** com>

Javernaut commented 8 months ago

You still didn't answer the quesiton about why you need the libstdc++.so. I'm not that experienced with different C++ runtimes, but according to the documentation:

system The system runtime refers to /system/lib/libstdc++.so. This library should not be confused with GNU's full-featured libstdc++. On Android, libstdc++ is just new and delete. Use libc++ for a full-featured C++ standard library.

This 'system' runtime is deprecated since NDK r18. The libc++ menioned above is exactly the libc++_shared.so, or its static variant.

Are you sure the libstdc++.so is even worth checking?

null4n commented 8 months ago

Cause first time I compile using -lc++ ld flag the it dependences on libc++_shared.so which is in NDK. then I found in system there is a libstdc++.so. But now I found libstdc++ in system only has "new" and "delete" function. so the problem now is how to link libc++_static.so instead of libc++_shared.so with ndk

Oleksandr Berezhnyi @.***> 於 2023年12月31日 週日 04:49 寫道:

You still didn't answer the quesiton about why you need the libstdc++.so. I'm not that experienced with different C++ runtimes, but according to the documentation:

system The system runtime refers to /system/lib/libstdc++.so. This library should not be confused with GNU's full-featured libstdc++. On Android, libstdc++ is just new and delete. Use libc++ for a full-featured C++ standard library.

This 'system' runtime is deprecated since NDK r18. The libc++ menioned above is exactly the libc++_shared.so, or its static variant.

Are you sure the libstdc++.so is even worth checking?

— Reply to this email directly, view it on GitHub https://github.com/Javernaut/ffmpeg-android-maker/issues/75#issuecomment-1872603917, or unsubscribe https://github.com/notifications/unsubscribe-auth/AHXIO5SFPP7IQXQQV5EWH6LYMB45NAVCNFSM6AAAAAAWKEQ27KVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQNZSGYYDGOJRG4 . You are receiving this because you were mentioned.Message ID: @.***>

MmingY commented 8 months ago

I have also encountered and solved your problem. In order for others to better solve the problem, I will share my solution.

android{
  ...
  defaultConfig{
   ...
           externalNativeBuild {
            cmake {
                cppFlags "-std=c++14 -fexceptions -frtti"
                arguments "-DANDROID_ARM_NEON=TRUE",'-DANDROID_STL=c++_shared'
            }
        }
 }
}

The main thing is the following command, but you need to put it in the correct place.

 cmake {
                cppFlags "-std=c++14 -fexceptions -frtti"
                arguments "-DANDROID_ARM_NEON=TRUE",'-DANDROID_STL=c++_shared'
            }