Tiny C Compiler (TCC) and winsock?
Asked Answered
B

3

6

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?

Bloody answered 1/11, 2010 at 14:29 Comment(0)
A
9

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
Angell answered 1/11, 2010 at 15:26 Comment(2)
Found wsock32.h on google code search. It included a few others that were easily found. Worked like a charm, cheersBloody
@tm1rbrt how do you know it worked like a charm if you got the file from somewhere rather than use the method in the answer? btw tcc asks for winsock.h maybe renaming wsock32.h to winsock.h works If so you could put that in your own answer. And it requires common.h which isn't in there.Affirmatory
N
8
  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

Nereen answered 19/2, 2012 at 17:2 Comment(7)
C:\Users\compile\Desktop\tcc>tcc.exe code.c -lwsock32 -o program.exe In file included from code.c:6: c:/users/compile/desktop/tcc/include/winapi/winsock2.h:10: error: include file '_mingw_unicode.h' not foundMerras
Used mingw-w64-v7.0.0: sourceforge.net/projects/mingw-w64 And tcc-0.9.27-win64-bin.zip download.savannah.gnu.org/releases/tinyccMerras
mingw-w64-v7.0.0.zip\mingw-w64-headers\crt folder does contain _mingw_unicode.hMerras
However dropping all the headers from mingw-w64-v7.0.0.zip\mingw-w64-headers\crt to the tcc\include does not resolve the problem and continually shows different error:Merras
C:\Users\compile\Desktop\tcc>tcc.exe code.c -lwsock32 -o program.exe In file included from code.c:5: In file included from c:/users/compile/desktop/tcc/include/stdio.h:9: In file included from c:/users/compile/desktop/tcc/include/crtdefs.h:10: In file included from c:/users/compile/desktop/tcc/include/corecrt.h:10: In file included from c:/users/compile/desktop/tcc/include/_mingw.h:27: c:/users/compile/desktop/tcc/include/stddef.h:18: error: ';' expected (got "extern")Merras
It seems that latest TCC compiler compiled from git repository sources code does work properly with winsocks and some other libraries.Merras
Sorry, I haven't used TCC nor used Windows since 2013...Nereen
R
1
tiny_impdef winsock.dll 

copy winsock.def to lib/

run:

tcc -lwinsock yourcode.c -o yourcode.exe
Ringleader answered 22/9, 2011 at 13:12 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.