binaryen icon indicating copy to clipboard operation
binaryen copied to clipboard

darwin/amd64: dyld: 'BinaryenTypeCreate' missing symbol called

Open chai2010 opened this issue 3 years ago • 2 comments

# version 104
$ clang main.c libbinaryen.dylib 
$ ./a.out 
dyld[16131]: missing symbol called
Abort trap: 6

main.c:

#include "binaryen-c.h"

// "hello world" type example: create a function that adds two i32s and returns
// the result

int main() {
  BinaryenModuleRef module = BinaryenModuleCreate();

  // Create a function type for  i32 (i32, i32)
  BinaryenType ii[2] = {BinaryenTypeInt32(), BinaryenTypeInt32()};
  BinaryenType params = BinaryenTypeCreate(ii, 2);
  BinaryenType results = BinaryenTypeInt32();

  // Get the 0 and 1 arguments, and add them
  BinaryenExpressionRef x = BinaryenLocalGet(module, 0, BinaryenTypeInt32()),
                        y = BinaryenLocalGet(module, 1, BinaryenTypeInt32());
  BinaryenExpressionRef add = BinaryenBinary(module, BinaryenAddInt32(), x, y);

  // Create the add function
  // Note: no additional local variables
  // Note: no basic blocks here, we are an AST. The function body is just an
  // expression node.
  BinaryenFunctionRef adder =
    BinaryenAddFunction(module, "adder", params, results, NULL, 0, add);

  // Print it out
  BinaryenModulePrint(module);

  // Clean up the module, which owns all the objects we created above
  BinaryenModuleDispose(module);

  return 0;
}

chai2010 avatar Jan 09 '22 05:01 chai2010

Odd. That works for me locally on linux, and we test that function in the test suite. Perhaps the problem is specific to MacOS?

kripken avatar Jan 10 '22 23:01 kripken

Odd. That works for me locally on linux, and we test that function in the test suite. Perhaps the problem is specific to MacOS?

https://github.com/chai2010/binaryen-issue-4436

chai2010 avatar Jan 11 '22 12:01 chai2010