You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am trying to cross-compile Rust code for x86_64 Android using Cross (I am running macOS 13 with M1 chip).
This code uses symbols from espeak-ng that I've built myself.
Upon reaching the link step, I am hit with the error :
ld: error: undefined symbol: espeak_Initialize
>>> referenced by lib.rs:108 (packages/espeak/src/lib.rs:108)
>>> /target/x86_64-linux-android/debug/deps/oratio_espeak-6fba08adc959e6d8.3x6nmh9h9fre8r93.rcgu.o:(oratio_espeak::initialize::h403ba8dd7c5de0ec)
clang140: error: linker command failed with exit code 1 (use -v to see invocation)
I am 100% sure that the library is actually found, because -L/-l flags are properly set, and if I try to change them I get the error "cannot find library".
In order to cross-build the C library I use the following (using Android NDK on M1 mac) :
PATH=$NDK_HOME/toolchains/llvm/prebuilt/darwin-x86_64/bin:$PATH
CC="x86_64-linux-android33-clang"
CXX="x86_64-linux-android33-clang++"
./autogen.sh
./configure --host=aarch64-apple-darwin --target=x86_64-linux-android
make
Here is some info about the resulting archive :
$ nm libespeak-ng.a | grep espeak_Initialize
0000000000000000 T espeak_Initialize
$ objdump -f libespeak-ng.a
libespeak-ng.a(libespeak_ng_la-case.o): file format elf64-x86-64
architecture: x86_64
start address: 0x0000000000000000
[repeat for all object files...]
What can cause missing symbols even when the library is found and actually contains the symbols?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I am trying to cross-compile Rust code for x86_64 Android using Cross (I am running macOS 13 with M1 chip).
This code uses symbols from espeak-ng that I've built myself.
Upon reaching the link step, I am hit with the error :
I am 100% sure that the library is actually found, because -L/-l flags are properly set, and if I try to change them I get the error "cannot find library".
In order to cross-build the C library I use the following (using Android NDK on M1 mac) :
Here is some info about the resulting archive :
What can cause missing symbols even when the library is found and actually contains the symbols?
Here is the exact built library I am trying to link : https://drive.google.com/file/d/1y9YgkDMrfkpct4ee-ETvRmxXv1zBsSzz/view?usp=sharing
EDIT : Here are the command used for building/linking.
Note that I also tried without the
--config
, when doing so it changes the linker fromx86_64-linux-android33-clang
tocc
but gives the same result.Linker invocation (each argument have been put on newline for readability) :
Also asked on Stack Overflow : https://stackoverflow.com/questions/77464901/linker-cannot-find-symbols-in-static-c-library-when-cross-compiling-rust-to-andr
Thank you
Beta Was this translation helpful? Give feedback.
All reactions