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

Using an external library (in my case, librdkafka) #137

Open
MMahdiSetak opened this issue Jul 11, 2022 · 3 comments
Open

Using an external library (in my case, librdkafka) #137

MMahdiSetak opened this issue Jul 11, 2022 · 3 comments

Comments

@MMahdiSetak
Copy link

Hi
I've been trying to add librdkafka as an external library and use it inside my cpp code but when I try to compile it and generate the wasm file, I get this error:

wasm-ld: error: unknown file type: /usr/lib/x86_64-linux-gnu/librdkafka++.a(ConfImpl.o)
em++: error: '/emsdk/upstream/bin/wasm-ld -o OUTPUT.wasm /tmp/emscripten_temp_1xep1tez/myproject_0.o /tmp/emscripten_temp_1xep1tez/proxy_wasm_intrinsics_lite.pb_1.o /tmp/emscripten_temp_1xep1tez/struct_lite.pb_2.o /tmp/emscripten_temp_1xep1tez/proxy_wasm_intrinsics_3.o /sdk/libprotobuf-lite.a /usr/lib/x86_64-linux-gnu/librdkafka++.a -L/emsdk/upstream/emscripten/cache/sysroot/lib/wasm32-emscripten/lto /emsdk/upstream/emscripten/cache/sysroot/lib/wasm32-emscripten/lto/crt1_reactor.o -lGL -lal -lhtml5 -lstandalonewasm -lstubs -lnoexit -lc -ldlmalloc -lcompiler_rt -lc++-noexcept -lc++abi-noexcept -lsockets -mllvm -combiner-global-alias-analysis=false -mllvm -enable-emscripten-sjlj -mllvm -disable-lsr --import-undefined --strip-debug --export-if-defined=malloc --export-if-defined=__start_em_asm --export-if-defined=__stop_em_asm --export=stackSave --export=stackRestore --export=stackAlloc --export=__errno_location --export=malloc --export-table -z stack-size=5242880 --initial-memory=16777216 --entry=_initialize --max-memory=16777216 --global-base=1024' failed (returned 1)
make: *** [OUTPUT.wasm] Error 1
Makefile:15: recipe for target 'OUTPUT.wasm' failed

I've searched about the error and according to this link, it seems that adding some link files to em++ options is not possible.
How can I do so? Is there a better way for reading a request and sending a Kafka message in envoy?
I've also attached the files that I made some changes to them here:
sample.zip

@MMahdiSetak MMahdiSetak changed the title Using external library (in my case, librdkafka) Using an external library (in my case, librdkafka) Jul 11, 2022
@PiotrSikora
Copy link
Member

You're trying to link together Proxy-Wasm plugin (built for wasm32 architecture) and system library (built for x86_64 architecture). This won't work, you need to build librdkafka++ from sources for wasm32 target as part of the plugin itself.

@amirEBD
Copy link

amirEBD commented Jul 12, 2022

I had the same issue with proxy-wasm as @MMahdiSetak mentioned, how can I get a wasm32 build for librdkafa++. @PiotrSikora
Thansk for any help :)

@PiotrSikora
Copy link
Member

You need to build it from sources as part of the plugin build process (assuming it even compiles to wasm32, since that's not guaranteed).

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

3 participants