It has GYP-based build system and produces an executable.
Current plan is to to replace main() with exported run() function and call it from Rust executable instead. https://github.com/nazar-pc/mediasoup/tree/rust-worker/worker (note: if you decide to build it, you'll provably need to set environment variable PYTHON=python3).
I have added static library build for that app and now can't seem to figure out how to call it.
CXX and CC do not really help here since they expect to build things and I already have a static library.
^ in build.rs helps somewhat but results in lots of complaints from linker like this:
= note: /usr/bin/ld: /usr/bin/ld: DWARF error: could not find variable specification at offset 5081
/usr/bin/ld: DWARF error: could not find variable specification at offset 67e4
/usr/bin/ld: DWARF error: could not find variable specification at offset 6816
/web/github/mediasoup/worker/out/Release/libmediasoup-worker.a(DepLibSRTP.o): in function `DepLibSRTP::ClassInit()':
/web/github/mediasoup/worker/out/../src/DepLibSRTP.cpp:48: undefined reference to `srtp_get_version_string'
/usr/bin/ld: /web/github/mediasoup/worker/out/../src/DepLibSRTP.cpp:50: undefined reference to `srtp_init'
/usr/bin/ld: /web/github/mediasoup/worker/out/Release/libmediasoup-worker.a(DepLibSRTP.o): in function `DepLibSRTP::ClassDestroy()':
/web/github/mediasoup/worker/out/../src/DepLibSRTP.cpp:60: undefined reference to `srtp_shutdown'
...
Is there really an accessible way to achieve this?
If you're pulling in a static library from a project, you also have to pull in every other library that it depends on and link it with your Rust program.
In this case it's missing srtp_shutdown. That may need srtp2_sys.
I guess I know too little about this. I though static library has things inside of it. Included all of the .a files that were build and received this lonely error now:
= note: /usr/bin/ld: /web/github/mediasoup/worker/out/Release/libuv.a(sysinfo-loadavg.o): in function `uv_loadavg':
/web/github/mediasoup/worker/out/../deps/libuv/libuv/src/unix/sysinfo-loadavg.c:28: multiple definition of `uv_loadavg'; /web/github/mediasoup/worker/out/Release/libuv.a(linux-core.o):/web/github/mediasoup/worker/out/../deps/libuv/libuv/src/unix/linux-core.c:1132: first defined here
/usr/bin/ld: /web/github/mediasoup/worker/out/Release/libabseil.a(print_hash_of.o): in function `main':
/web/github/mediasoup/worker/out/../deps/libwebrtc/deps/abseil-cpp/abseil-cpp/absl/hash/internal/print_hash_of.cc:20: multiple definition of `main'; /web/github/mediasoup/target/debug/deps/mediasoup_sys-ad2c49156d6c0bb6.37125jqqwh13ju51.rcgu.o:37125jqqwh13ju51:(.text.main+0x0): first defined here
collect2: error: ld returned 1 exit status
But then I'd have to call .compile(), which I don't need (I don't think). And cc doesn't seem to have an API to specify just libraries to link and not build anything on its own.