-
Hello, org.graalvm.polyglot.PolyglotException: External LLVMFunction _Znwm cannot be found.
at <llvm>.allocNativeProgram(lib.c:25)
at app/org.graalvm.sdk/org.graalvm.polyglot.Value.execute(Value.java:878) Full listing #include <stdio.h>
#include <vector>
#include <graalvm/llvm/polyglot.h>
typedef struct Item {
int i;
} Item;
typedef std::vector<Item> Items;
typedef struct Program {
Items* items;
} Program;
POLYGLOT_DECLARE_STRUCT(Program)
extern "C" void *allocNativeProgram() {
struct Program *ret = (Program *) malloc(sizeof(Program));
ret->items = new Items();
return polyglot_from_Program(ret);
} compiled with: clang -x c++ src/main/c/lib.c -emit-llvm -c -o src/test/resources/lib.bc Thanks! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
This is using the wrong C++ standard library. It's compiling for Try compiling your bitcode with the LLVM toolchain wrappers provided by Sulong, instead of vanilla clang. You can get the path to them with |
Beta Was this translation helpful? Give feedback.
This is using the wrong C++ standard library. It's compiling for
libstdc++
, you need to compile forlibc++
instead. Also, this does not link against the C++ library, so Sulong is not going to load it.Try compiling your bitcode with the LLVM toolchain wrappers provided by Sulong, instead of vanilla clang. You can get the path to them with
lli --print-toolchain-path
. Also, don't use-emit-llvm
. The toolchain wrappers will produce standard ELF files with embedded bitcode. That way, the dependency to the C++ library is visible to Sulong.