I can't link to object files built by clang or gcc on mac (arm64, ventura)
I thought maybe linking would work. Below is a bash script that on linux will
run fine
On mac I get "t.so: error: t.so: unrecognized file type"
Is there a way I can get this working without writing a ton of dlopen/dlsym
code?
echo "int test(); int main() { test(); return 0; }" > a.c
echo -e '#include <stdio.h>\nint test(int x) { printf("Incorrect func\\n"); return
0; }' > t.c
echo -e '#include <stdio.h>\nextern "C" int test(int x) { printf("Test got %d\\n",
x); return x*2; }' > g.cpp
clang++ -march=native -g -shared g.cpp -o g.so
tcc -march=native -g -shared t.c -o t.so
tcc -g a.c t.so
mv t.so real_t.so
cp g.so t.so
LD_LIBRARY_PATH=. ./a.out