Can I use a socket library from TCC? I can't find any reference to winsock or sys/socket.h in the include directory.
If i remember correctly, winsock was part of the windows platform SDK (?) If so can I link that with TCC?
According to Tinycc-devel mailing list
you should give this a try:
tiny_impdef winsock.dll -o winsock.def
tcc yourcode.c winsock.def -o yourcode.exe
Use
tiny_impdef.exe
to export definitions from the DLL file using the command line:tiny_impdef.exe wsock32.dll -o .\lib\wsock32.def
You will also need the header files for your source code to include them. MinGW's ones (such as
winsock2.h
,ws2tcpip.h
,ws2spi.h
...) can be reused with TCC.
The MinGW compiler can be downloaded from here. Just copy the headers you need from MinGW'sinclude
directory to TCC'sinclude\winapi
directory.At compilation time, you will need to tell the compiler you are using the Windows socket library:
tcc.exe path\to\code.c -lwsock32 -o path\to\program.exe
tiny_impdef winsock.dll
copy winsock.def to lib/
run:
tcc -lwinsock yourcode.c -o yourcode.exe
来源:https://stackoverflow.com/questions/4069770/tiny-c-compiler-tcc-and-winsock