Question

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?

Was it helpful?

Solution

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

OTHER TIPS

  1. Use tiny_impdef.exe to export definitions from the DLL file using the command line:
    tiny_impdef.exe wsock32.dll -o .\lib\wsock32.def

  2. 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's include directory to TCC's include\winapi directory.

  3. 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
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top