Skip to content

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

Open
@MMahdiSetak

Description

@MMahdiSetak

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions