Tiny C Compiler (TCC) and winsock?

自作多情 提交于 2019-12-29 05:32:27

问题


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?


回答1:


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



回答2:


  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




回答3:


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!