libfuzzer on macOS not found for architecture x86_64

1.1k views Asked by At

i am trying to compile a simple fuzzing example on macOS 10.14.6, and CLion 2019.2.5

#include <stdint.h>
#include <stddef.h>

extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
    if (size > 0 && data[0] == 'H')
        if (size > 1 && data[1] == 'I')
            if (size > 2 && data[2] == '!')
                __builtin_trap();
    return 0;
}

which is also shown here https://llvm.org/docs/LibFuzzer.html#toy-example if have set up my CMakeLists.txt everything works fine he is linking the CXX executable after this the error occurs

Undefined symbols for architecture x86_64:
  "_main", referenced from:
     implicit entry/start for main executable
ld: symbol(s) not found for architecture x86_64

same error occurs when i am compiling via terminal I tried it with a Virtualbox with Ubuntu 18.04 - no problems with the same Clion version & Cmakelist

1

There are 1 answers

0
supagas On BEST ANSWER

It works you use the right compiler, not the apple one, -> brew install llvm set preferences compiler c and c++ to /usr/local/opt/llvm/bin/clang