Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

compilation in windows #4

Open
glira opened this issue Aug 21, 2017 · 14 comments
Open

compilation in windows #4

glira opened this issue Aug 21, 2017 · 14 comments

Comments

@glira
Copy link

glira commented Aug 21, 2017

Please describe how compile this in vistual studio or mingw.

@rofl0r
Copy link
Owner

rofl0r commented Aug 22, 2017

try this: compile it on linux, look which C files get compiled, then instruct to compile these files and link em together.
if you take the release tarball, you can probably just gcc *.c -o microsocks.
or maybe you do your homework and read up on how to use makefiles with mingw...

@barbadosa
Copy link

rofl0r... Could you please compile the .exe for us and post it as a release?
Some of us aren't tech savvy enough to compile, but we would still like to use it.

@rofl0r
Copy link
Owner

rofl0r commented Feb 1, 2018

i don't use windows, but maybe someone watching this repo can provide an exe ?
but i dont think it is very complicated, you basically just need to run mingw32-make which ships with mingw if i understand this correctly. they also mention this GUI: http://www.bloodshed.net/dev/devcpp.html

good luck. if you succeed, let us know how it worked.

@barbadosa
Copy link

barbadosa commented Feb 2, 2018

MinGW lacks pthreads by default so it fails from the start. So to compile microsocks, you would have to compile phtreads first...

MinGW-64 appears to have phtreads support, but running "make" in MinGW-64 console (mingw-w64.bat) will give a ton of errors of missing includes, one after another:

sockssrv.c:32:10: fatal error: sys/select.h: No such file or directory
sockssrv.c:34:10: fatal error: arpa/inet.h: No such file or directory
server.h:7:10: fatal error: sys/socket.h: No such file or directory
server.h:8:10: fatal error: netdb.h: No such file or directory

Because MinGW is not a full port of the whole of Linux on your Windows machine.

Cygwin is pretty much that, but it took me 8 hours to install as it has millions of files and is over 50GB in size, and I just don't bother with it anymore after having encountered errors compiling a project previously.

So, unless someone can release an .exe and/or a tutorial how to compile it, microsocks does not support Windows.

I wonder if you can build an exe on Linux? You should be able to?

@rofl0r
Copy link
Owner

rofl0r commented Feb 2, 2018

mingw (at least the official one from mingw.org) ships some sort of package manager where you can select pthread and get it installed. it will create a file libwinpthread-1.dll.
i know this because i'm involved in anotehr project where the main developer makes use of that package.

@barbadosa
Copy link

When you re-run MinGW installer and do Install > Continue > Run Now, you get the MinGW Installation Manager.

You cannot select all packages, you have to mark them for install one by one, which is hell. There is no search function to search for "pthread". When I marked "wingw-developer-toolkit", it marked packages used in development, among them is "mingw32-libpthreadgc". But apparently it wasn't enough, because I still get this after running "mingw32-make":

"sockssrv.c:30:21: fatal error: pthread.h: No such file or directory"

(I also had to add "CC = gcc" to Makefile)

There is also a package called "mingw32-pthreads-w32", which is not selected when you select "wingw-developer-toolkit".

Installing it, did indeed add pthread support to MinGW. But now I'm getting the same errors I got in MinGW-64:

sockssrv.c:32:24: fatal error: sys/select.h: No such file or directory

@rofl0r
Copy link
Owner

rofl0r commented Feb 2, 2018

maybe there needs to be yet another package selected ? can "select.h" be located in mingw's directory tree ? if so, adding the right base path a la CPPFLAGS=-I/path/to/headers make might fix it...

@rofl0r
Copy link
Owner

rofl0r commented Feb 2, 2018

re your previous comment

Because MinGW is not a full port of the whole of Linux on your Windows machine.

this is not about linux, it's about POSIX, and to the best of my knowlegde, mingw tries to provide those APIs on top of M$' msvcrt runtime.

note that POSIX is meant as a portable standard to make programs work on all platforms, and windows used to ship a POSIX subsystem a while ago, but then removed it for some reason.

so windows is really the only OS which seems to be deliberately trying to push its own APIs instead of collaborating in the joint POSIX effort, and requiring programmers to write special code to support it.

@barbadosa
Copy link

barbadosa commented Feb 2, 2018

There is this:
https://github.com/wido/libs3/blob/master/inc/mingw/sys/select.h

// This file is used only on a MingW build, and converts an include of
// sys/select.h to its Windows equivalent

#include <winsock2.h>

Then I proceed to receive:

sockssrv.c:33:23: fatal error: arpa/inet.h: No such file or directory

Even though I have selected "msys-inetutils" in MinGW Installation Manager, it seems to not be enough. I commented it out, just to see if it's the last one, I received another error of a missing file. I have listed 4 of them is a post on this thread, the same ones I was getting with MinGW-64.

You are freely using any includes available in Linux, as you should, and MinGW simply does not include them. Cygwin does include a lot more of them, and maybe even all the ones used in microsocks, but I would have to wait for 8 hours again to install it, and who knows what kind of errors I would be encountering in the end.

@rofl0r
Copy link
Owner

rofl0r commented Feb 3, 2018

i agree that it is annoying that mingw doesn't install the full set of headers by default, but i do think that it provides all of them when you turn the right knobs. that said, again, this is not about linux, this is about posix. microsocks compiles and works fine on all platforms that adhere to that standard (linux, *bsd, mac os x, rtos, ...) and it should in theory even work on windows using one of cygwin / mingw / midipix, when properly configured.

@barbadosa
Copy link

Yes, I can understand that the microsocks code is all right.
But I need to be able to run it on home PCs and a lot of them are Windows, so I have to make it work.

I believe I have selected all relevant packages in MinGW package manager.

From https://stackoverflow.com/questions/1517762/sockets-in-mingw:

BSD sys/socket.h is a POSIX header and the win32 API doesn't support it. MinGW headers are just a reimplementation of native win32 headers and don't offer additional POSIX compatibility.

If you are looking for sys/socket.h support, try either GNU gnulib's sys/socket.h replacement or go with Cygwin, which provides a POSIX compatibility wrapper on Windows.

So we come to the same conclusion.

@barbadosa
Copy link

barbadosa commented Feb 3, 2018


@rofl0r
Copy link
Owner

rofl0r commented Feb 3, 2018

you may come to #proxychains on irc.freenode.net

@ewwink
Copy link

ewwink commented Jul 30, 2018

it can compiled using cygwin

$ make
cc  -Wall -std=c99   -c -o sockssrv.o sockssrv.c
cc  -Wall -std=c99   -c -o server.o server.c
cc  -Wall -std=c99   -c -o sblist.o sblist.c
sblist.c:8:2: warning: #warning "your C library sucks." [-Wcpp]
 #warning "your C library sucks."
  ^~~~~~~
cc  -Wall -std=c99   -c -o sblist_delete.o sblist_delete.c
cc  sockssrv.o server.o sblist.o sblist_delete.o -lpthread -o microsocks

$ ./microsocks.exe
client[4] 127.0.0.1: connected to x.x.x.x:443

@rofl0r if you don't use windows you can compile it online using appveyor

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants