tinycc-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Tinycc-devel] Shared objects on mac


From: Herman ten Brugge
Subject: Re: [Tinycc-devel] Shared objects on mac
Date: Mon, 22 May 2023 15:09:41 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.10.0

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.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]