On 5/18/23 21:27, Levo D wrote:
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
This is expected. The object files that tcc generates and read are in
elf format and not in macos format.
The reason is that macos differs a lot from elf format and it is
difficult to implement this in tcc.
The output executable/dll is in macos format.
_______________________________________________
Tinycc-devel mailing list
Tinycc-devel@nongnu.org
https://lists.nongnu.org/mailman/listinfo/tinycc-devel