Hi!
I'm trying to integrate some Rust code that I have with an existing C++ Bela project (because I don't want to rewrite the Trill and IMU libraries in Rust). The way I'm going about it is a static library with C bindings generated by cbindgen.
The library is a very simple no_std library built using
$ cargo build --target=armv7-unknown-linux-gnueabihf --release
and
$ cross build --target=armv7-unknown-linux-gnueabihf --release
both gave the same result. The target is the same as the complete Rust example at https://github.com/padenot/bela-sys which compiles and runs on the Bela.
nm shows that the symbol for the test function (called magic_number) exists in the static library:
$ nm ./target/armv7-unknown-linux-gnueabihf/release/libneodrs.a | grep "magic"
00000000 T magic_number
Linking does work on my local desktop using a dummy test project. The same dummy test project does not link on the Bela though, and neither does the Bela project where i try to use it.
Test code (neodrs: static library, magic_number: test function):
#include <iostream>
#include "neodrs.h"
int main() {
std::cout << "The rust function returns: " << magic_number(0) << "\n";
}
I'm compiling the dummy C++ project with the same command on the Bela as my computer:
clang++ test_lib.cpp -o test -L./libraries/ -lneodrs -v
Full printout:
Relevant portion:
/tmp/test_lib-d46f46.o: In function `main':
test_lib.cpp:(.text+0x28): undefined reference to `magic_number(float)'
clang: error: linker command failed with exit code 1 (use -v to see invocation)
g++ gives almost exactly the same error
/tmp/ccTj1Uy8.o: In function `main':
test_lib.cpp:(.text+0x1e): undefined reference to `magic_number(float)'
collect2: error: ld returned 1 exit status
It seems like the library is found, but is unable to be parsed or something. Is there some Bela or BBB specific thing about static libraries that I need to correct for?