문제

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

다른 팁

  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
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top