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 do I compile to a shared library? without libc++_shared.so ? #30

Closed
azkadev opened this issue Oct 8, 2022 · 4 comments
Closed

How do I compile to a shared library? without libc++_shared.so ? #30

azkadev opened this issue Oct 8, 2022 · 4 comments
Labels
build Build related issues

Comments

@azkadev
Copy link

azkadev commented Oct 8, 2022

I want to experiment with using whisper into the app, but when I open it, an error occurs when the compiled library requires libc++_shared.so,

i use this bash to build for android target

/home/azkdev/Android/Sdk/ndk/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android21-clang -pthread -O3 -std=c11 -mavx -mavx2 -mfma -mf16c -c ./ggml.c -fPIC -lstdc++
/home/azkadev/Android/Sdk/ndk/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android21-clang++ -pthread -O3 -std=c++11 -mavx -mavx2 -mfma -mf16c -c ./whisper.cpp -fPIC -lstdc++
/home/azkadev/Android/Sdk/ndk/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android21-clang++ -pthread -O3 -std=c++11 ./main.cpp -fPIC -lstdc++ whisper.o ggml.o -o ./whisper.so --shared -fPIC -lstdc++

I have also tried this clang-linking-so-library-libc-shared-so, but it doesn't work

Error
Screenshot from 2022-10-08 19-17-21

can you give a build command so it doesn't need libc++_shared.so? sorry i'm still a beginner in cpp

@azkadev azkadev changed the title How do I compile to a shared library? How do I compile to a shared library? without libc++_shared.so ? Oct 8, 2022
@ggerganov ggerganov added the build Build related issues label Oct 8, 2022
@ggerganov
Copy link
Owner

Does this work:

gcc -O3 -std=c11 -pthread -mavx -mavx2 -mfma -mf16c -fPIC -c ggml.c
g++ -O3 -std=c++11 -pthread --shared -static-libstdc++ whisper.cpp ggml.o -o libwhisper.so

Then you can link libwhisper.so like this, for example:

g++ main.cpp -L. -lwhisper

Also, I'm pretty sure you don't need the -mavx -mavx2 -mfma -mf16c flags for Android, so you can remove them. You might need some other flags though, not sure. Might want to check this comment:

#18 (comment)

@azkadev
Copy link
Author

azkadev commented Oct 8, 2022

Screenshot from 2022-10-08 20-42-32
Thank you very much, now I can convert audio to text, thanks for porting to cpp, and thanks for helping me,

@azkadev azkadev closed this as completed Oct 8, 2022
@ggerganov ggerganov pinned this issue Oct 9, 2022
@Topping1
Copy link
Contributor

@azkadev can you please give some tips on how to create a minimal application with whisper like the one you are showing? I have not much experience in C++ or android application coding.
@ggerganov I did an experiment myself compiling the code on android, using the CxxDroid compiler and it worked perfectly. On a Snapdragon 712 with 6gb Ram I get 6.5s for transcribing jfk.wav (11s) with tiny model, 16s with base model and 62s with small model. Pretty decent for a midrange chipset.

@azkadev
Copy link
Author

azkadev commented Oct 25, 2022

@azkadev can you please give some tips on how to create a minimal application with whisper like the one you are showing? I have not much experience in C++ or android application coding. @ggerganov I did an experiment myself compiling the code on android, using the CxxDroid compiler and it worked perfectly. On a Snapdragon 712 with 6gb Ram I get 6.5s for transcribing jfk.wav (11s) with tiny model, 16s with base model and 62s with small model. Pretty decent for a midrange chipset.

I don't know tips, you can see my repo here, sorry my english is bad

@ggerganov ggerganov unpinned this issue Oct 26, 2022
mattsta pushed a commit to mattsta/whisper.cpp that referenced this issue Apr 1, 2023
* Add rust as a dependency

* Update README.md

Co-authored-by: Jong Wook Kim <ilikekjw@gmail.com>
kultivator-consulting pushed a commit to KultivatorConsulting/whisper.cpp that referenced this issue Feb 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
build Build related issues
Projects
None yet
Development

No branches or pull requests

3 participants