[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Tinycc-devel] Shared objects on mac
From: |
Levo D |
Subject: |
[Tinycc-devel] Shared objects on mac |
Date: |
Thu, 18 May 2023 19:27:12 +0000 (UTC) |
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
- [Tinycc-devel] Shared objects on mac,
Levo D <=