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

Linking issue #1541

Open
silvio3punkt5 opened this issue Nov 15, 2024 · 7 comments
Open

Linking issue #1541

silvio3punkt5 opened this issue Nov 15, 2024 · 7 comments

Comments

@silvio3punkt5
Copy link

Hi,

I've experienced a linking issue on Ubuntu 22.04 when I install the onnxruntime libs (same as used in cmake: "onnxruntime-linux-x64-static_lib-1.17.1-glibc2_17.zip") upfront into /usr/local.
Steps to reproduce:

# install onnxruntime libs
mkdir -p /tmp/onnx && cd /tmp/onnx && wget https://github.com/csukuangfj/onnxruntime-libs/releases/download/v1.17.1/onnxruntime-linux-x64-static_lib-1.17.1-glibc2_17.zip  &&  unzip onnxruntime-linux-x64-static_lib-1.17.1-glibc2_17.zip &&  mv onnxruntime-linux-x64-static_lib-1.17.1-glibc2_17 onnxruntime && cp -a onnxruntime/* /usr/local/ && cd /tmp && rm -fr onnx*

cmake -DCMAKE_BUILD_TYPE=Release
make -j

It is detected during configuration:

-- location_onnxruntime_header_dir: /usr/local/include
-- location_onnxruntime_lib: /usr/local/lib/libonnxruntime.a

This results in this errors during linking:

/usr/bin/ld: ../../lib/libsherpa-onnx-core.a(offline-punctuation-impl.cc.o): in function `_GLOBAL__sub_I_offline_punctuation_impl.cc':
offline-punctuation-impl.cc:(.text.startup+0x17): undefined reference to `OrtGetApiBase'
/usr/bin/ld: ../../lib/libsherpa-onnx-core.a(offline-ct-transformer-model.cc.o): in function `_GLOBAL__sub_I_offline_ct_transformer_model.cc':
offline-ct-transformer-model.cc:(.text.startup+0x17): undefined reference to `OrtGetApiBase'
/usr/bin/ld: ../../lib/libsherpa-onnx-core.a(onnx-utils.cc.o): in function `_GLOBAL__sub_I_onnx_utils.cc':
onnx-utils.cc:(.text.startup+0x17): undefined reference to `OrtGetApiBase'
/usr/bin/ld: ../../lib/libsherpa-onnx-core.a(session.cc.o): in function `_GLOBAL__sub_I_session.cc':
session.cc:(.text.startup+0x17): undefined reference to `OrtGetApiBase'
/usr/bin/ld: ../../lib/libsherpa-onnx-core.a(provider.cc.o): in function `_GLOBAL__sub_I_provider.cc':
provider.cc:(.text.startup+0x17): undefined reference to `OrtGetApiBase'

When I do not install the onnxruntime libs by myself and let cmake do the onnxruntime libs installation the compilation&linking works - which is strange as it downloads the same onnxruntime-linux-x64-static_lib package...

Do you know why linking behaves different?
Thanks

@csukuangfj
Copy link
Collaborator

please show the output of

make VERBOSE=1

@silvio3punkt5
Copy link
Author

This linking issue happens on many places, here the verbose output while linking sherpa-onnx-offline-punctuation:

# onnxruntime libs by sherpa-onnx itself
[ 76%] Linking CXX executable ../../bin/sherpa-onnx-offline-punctuation
cd /root/sherpa-onnx/Release/sherpa-onnx/csrc && /usr/local/bin/cmake -E cmake_link_script CMakeFiles/sherpa-onnx-offline-punctuation.dir/link.txt --verbose=1
/usr/bin/c++   -static-libstdc++ -static-libgcc  -O3 -DNDEBUG "CMakeFiles/sherpa-onnx-offline-punctuation.dir/sherpa-onnx-offline-punctuation.cc.o" -o ../../bin/sherpa-onnx-offline-punctuation  -Wl,-rpath,"\$ORIGIN:" ../../lib/libsherpa-onnx-core.a -Wl,-rpath,$ORIGIN/../lib -Wl,-rpath,$ORIGIN/../../../sherpa_onnx/lib ../../lib/libkaldi-native-fbank-core.a ../../lib/libkaldi-decoder-core.a ../../lib/libsherpa-onnx-kaldifst-core.a ../../lib/libssentencepiece_core.a -lpthread ../../_deps/onnxruntime-src/lib/libonnxruntime.a -lm ../../lib/libsherpa-onnx-fstfar.a ../../lib/libsherpa-onnx-fst.a ../../lib/libpiper_phonemize.a ../../lib/libespeak-ng.a -Wl,-rpath,$ORIGIN -lm ../../lib/libucd.a -ldl -pthread

# onnxruntime libs installed upfront into /usr/local
[ 78%] Linking CXX executable ../../bin/sherpa-onnx-offline-punctuation
cd /root/sherpa-onnx/Release/sherpa-onnx/csrc && /usr/local/bin/cmake -E cmake_link_script CMakeFiles/sherpa-onnx-offline-punctuation.dir/link.txt --verbose=1
/usr/bin/c++   -static-libstdc++ -static-libgcc  -O3 -DNDEBUG "CMakeFiles/sherpa-onnx-offline-punctuation.dir/sherpa-onnx-offline-punctuation.cc.o" -o ../../bin/sherpa-onnx-offline-punctuation  -Wl,-rpath,"\$ORIGIN:" ../../lib/libsherpa-onnx-core.a -Wl,-rpath,$ORIGIN/../lib -Wl,-rpath,$ORIGIN/../../../sherpa_onnx/lib ../../lib/libkaldi-native-fbank-core.a ../../lib/libkaldi-decoder-core.a ../../lib/libsherpa-onnx-kaldifst-core.a ../../lib/libssentencepiece_core.a -lpthread -lm ../../lib/libsherpa-onnx-fstfar.a ../../lib/libsherpa-onnx-fst.a ../../lib/libpiper_phonemize.a ../../lib/libespeak-ng.a -Wl,-rpath,$ORIGIN -lm ../../lib/libucd.a -ldl -pthread

@csukuangfj
Copy link
Collaborator

Could you tell us which commit you are using?

Are you using the latest master? If not, have you tried the latest master?

@silvio3punkt5
Copy link
Author

Yes, I am using latest commit from master branch. It looks like the issue was introduced with older commit:

commit 9ab89c33bccbe0378f7969316e50232668846416
Date:   Fri Nov 1 11:16:28 2024 +0800

With commit:

commit a3c89aa0d8470d8eab30d7781b3dd7b9ed448046
Date:   Thu Oct 31 17:54:16 2024 +0800

the linking issue wasn't there.

@csukuangfj
Copy link
Collaborator

Yes, I am using latest commit from master branch

I hope you know how to find the latest commit.

Today is 2024.11.15, but the commit you use is

Date:   Fri Nov 1 11:16:28 2024 +0800

Please use the latest master of k2-fsa/sherpa-onnx for testing.

@silvio3punkt5
Copy link
Author

I'm using latest commit from master and observed this linking issues.
During my own investigations I found the problematic commit and the last working version for me - that were the two commits I've posted.

@csukuangfj
Copy link
Collaborator

Ah, I see. Thanks for reporting!

Will try to reproduce it locally.

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