robertdavidgraham / masscan

TCP port scanner, spews SYN packets asynchronously, scanning entire Internet in under 5 minutes.
GNU Affero General Public License v3.0
23.31k stars 3.05k forks source link

Compile Error on Windows 10/MinGW32 #593

Open schmitzCatz opened 3 years ago

schmitzCatz commented 3 years ago

Hi,

I get several compile errors regarding src/rawsock-getmac.c I'm running current the msys2 toolchain trying to compile current master...

$ make -v GNU Make 4.3 Built for x86_64-pc-msys

$ gcc -v Using built-in specs. COLLECT_GCC=gcc COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-pc-msys/10.2.0/lto-wrapper.exe Target: x86_64-pc-msys Configured with: /c/_/S/gcc/src/gcc-10.2.0/configure --build=x86_64-pc-msys --prefix=/usr --libexecdir=/usr/lib --enable-bootstrap --enable-shared --enable-shared-libgcc --enable-static --enable-version-specific-runtime-libs --with-arch=x86-64 --with-tune=generic --disable-multilib --enable-__cxa_atexit --with-dwarf2 --enable-languages=c,c++,fortran,lto --enable-graphite --enable-threads=posix --enable-libatomic --enable-libgomp --disable-libitm --enable-libquadmath --enable-libquadmath-support --disable-libssp --disable-win32-registry --disable-symvers --with-gnu-ld --with-gnu-as --disable-isl-version-check --enable-checking=release --without-libiconv-prefix --without-libintl-prefix --with-system-zlib --enable-linker-build-id --with-default-libstdcxx-abi=gcc4-compatible --enable-libstdcxx-filesystem-ts Thread model: posix Supported LTO compression algorithms: zlib gcc version 10.2.0 (GCC)

Output: src/rawsock-getmac.c: In function ‘rawsock_get_adapter_mac’: src/rawsock-getmac.c:183:42: error: ‘AF_LINK’ undeclared (first use in this function); did you mean ‘AF_HYLINK’? 183 | && p->ifa_addr->sa_family == AF_LINK) | ^~~~~~~ | AF_HYLINK src/rawsock-getmac.c:183:42: note: each undeclared identifier is reported only once for each function it appears in src/rawsock-getmac.c:197:23: error: invalid use of undefined type ‘struct sockaddr_dl’ 197 | if (len > link->sdl_alen) { | ^~ src/rawsock-getmac.c:199:23: error: invalid use of undefined type ‘struct sockaddr_dl’ 199 | len = link->sdl_alen; | ^~ src/rawsock-getmac.c:204:21: error: invalid use of undefined type ‘struct sockaddr_dl’ 204 | link->sdl_family, | ^~ src/rawsock-getmac.c:205:21: error: invalid use of undefined type ‘struct sockaddr_dl’ 205 | link->sdl_type, | ^~ src/rawsock-getmac.c:209:20: error: invalid use of undefined type ‘struct sockaddr_dl’ 209 | link->sdl_data + link->sdl_nlen, | ^~ src/rawsock-getmac.c:209:37: error: invalid use of undefined type ‘struct sockaddr_dl’ 209 | link->sdl_data + link->sdl_nlen, | ^~ make: *** [Makefile:109: tmp/rawsock-getmac.o] Error 1

Any ideas how to fix this?

khanjanny commented 3 years ago

make problem. please update compiled file on the release version

ghost commented 2 years ago

I have the same issue on the latest version of make and gcc I could find

MAKE VERSION:
GNU Make 4.3
Built for x86_64-pc-msys
Copyright (C) 1988-2020 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
GCC VERSION:
Using built-in specs.
COLLECT_GCC=/usr/bin/gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-pc-msys/11.2.0/lto-wrapper.exe
Target: x86_64-pc-msys
Configured with: /c/S/gcc/src/gcc-11.2.0/configure --build=x86_64-pc-msys --prefix=/usr --libexecdir=/usr/lib --enable-bootstrap --enable-shared --enable-shared-libgcc --enable-static --enable-version-specific-runtime-libs --with-arch=x86-64 --with-tune=generic --disable-multilib --enable-__cxa_atexit --with-dwarf2 --enable-languages=c,c++,fortran,lto --enable-graphite --enable-threads=posix --enable-libatomic --enable-libgomp --disable-libitm --enable-libquadmath --enable-libquadmath-support --disable-libssp --disable-win32-registry --disable-symvers --with-gnu-ld --with-gnu-as --disable-isl-version-check --enable-checking=release --without-libiconv-prefix --without-libintl-prefix --with-system-zlib --enable-linker-build-id --with-default-libstdcxx-abi=gcc4-compatible --enable-libstdcxx-filesystem-ts
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 11.2.0 (GCC)
OUTPUT:
cc -g -ggdb    -Wall -O2 -c src/rawsock-getmac.c -o tmp/rawsock-getmac.o
src/rawsock-getmac.c: In function 'rawsock_get_adapter_mac':
src/rawsock-getmac.c:183:42: error: 'AF_LINK' undeclared (first use in this function); did you mean 'AF_HYLINK'?
  183 |             && p->ifa_addr->sa_family == AF_LINK)
      |                                          ^~~~~~~
      |                                          AF_HYLINK
src/rawsock-getmac.c:183:42: note: each undeclared identifier is reported only once for each function it appears in
src/rawsock-getmac.c:197:23: error: invalid use of undefined type 'struct sockaddr_dl'
  197 |         if (len > link->sdl_alen) {
      |                       ^~
src/rawsock-getmac.c:199:23: error: invalid use of undefined type 'struct sockaddr_dl'
  199 |             len = link->sdl_alen;
      |                       ^~
src/rawsock-getmac.c:204:21: error: invalid use of undefined type 'struct sockaddr_dl'
  204 |                 link->sdl_family,
      |                     ^~
src/rawsock-getmac.c:205:21: error: invalid use of undefined type 'struct sockaddr_dl'
  205 |                 link->sdl_type,
      |                     ^~
src/rawsock-getmac.c:209:20: error: invalid use of undefined type 'struct sockaddr_dl'
  209 |                link->sdl_data + link->sdl_nlen,
      |                    ^~
src/rawsock-getmac.c:209:37: error: invalid use of undefined type 'struct sockaddr_dl'
  209 |                link->sdl_data + link->sdl_nlen,
      |                                     ^~
make: *** [Makefile:109: tmp/rawsock-getmac.o] Error 1
schmitzCatz commented 2 years ago

make problem. please update compiled file on the release version

tried updating, but no avail :-(

fr0zert commented 2 years ago

have same problem, still no fixes?

schmitzCatz commented 1 year ago

Issue is open for 1 year, anybody success compiling masscan with msys2 on windows?

Badbird5907 commented 1 year ago

same problem here, on windows

make -v
GNU Make 4.3
Built for x86_64-pc-cygwin
gcc -v
Using built-in specs.
COLLECT_GCC=/usr/bin/gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-pc-cygwin/11/lto-wrapper.exe
Target: x86_64-pc-cygwin
Configured with: /mnt/share/cygpkgs/gcc/gcc.x86_64/src/gcc-11.3.0/configure --srcdir=/mnt/share/cygpkgs/gcc/gcc.x86_64/src/gcc-11.3.0 --prefix=/usr --exec-prefix=/usr --localstatedir=/var --sysconfdir=/etc --docdir=/usr/share/doc/gcc --htmldir=/usr/share/doc/gcc/html -C --build=x86_64-pc-cygwin --host=x86_64-pc-cygwin --target=x86_64-pc-cygwin --without-libiconv-prefix --without-libintl-prefix --libexecdir=/usr/lib --with-gcc-major-version-only --enable-shared --enable-shared-libgcc --enable-static --enable-version-specific-runtime-libs --enable-bootstrap --enable-__cxa_atexit --with-dwarf2 --with-tune=generic --enable-languages=c,c++,fortran,lto,objc,obj-c++,jit --enable-graphite --enable-threads=posix --enable-libatomic --enable-libgomp --enable-libquadmath --enable-libquadmath-support --disable-libssp --enable-libada --disable-symvers --with-gnu-ld --with-gnu-as --with-cloog-include=/usr/include/cloog-isl --without-libiconv-prefix --without-libintl-prefix --with-system-zlib --enable-linker-build-id --with-default-libstdcxx-abi=gcc4-compatible --enable-libstdcxx-filesystem-ts
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 11.3.0 (GCC)
make
cc -g -ggdb  -I.  -Wall -O2 -c src/rawsock-getmac.c -o tmp/rawsock-getmac.o
src/rawsock-getmac.c: In function 'rawsock_get_adapter_mac':
src/rawsock-getmac.c:183:42: error: 'AF_LINK' undeclared (first use in this function); did you mean 'AF_HYLINK'?
  183 |             && p->ifa_addr->sa_family == AF_LINK)
      |                                          ^~~~~~~
      |                                          AF_HYLINK
src/rawsock-getmac.c:183:42: note: each undeclared identifier is reported only once for each function it appears in
src/rawsock-getmac.c:197:23: error: invalid use of undefined type 'struct sockaddr_dl'
  197 |         if (len > link->sdl_alen) {
      |                       ^~
src/rawsock-getmac.c:199:23: error: invalid use of undefined type 'struct sockaddr_dl'
  199 |             len = link->sdl_alen;
      |                       ^~
src/rawsock-getmac.c:204:21: error: invalid use of undefined type 'struct sockaddr_dl'
  204 |                 link->sdl_family,
      |                     ^~
src/rawsock-getmac.c:205:21: error: invalid use of undefined type 'struct sockaddr_dl'
  205 |                 link->sdl_type,
      |                     ^~
src/rawsock-getmac.c:209:20: error: invalid use of undefined type 'struct sockaddr_dl'
  209 |                link->sdl_data + link->sdl_nlen,
      |                    ^~
src/rawsock-getmac.c:209:37: error: invalid use of undefined type 'struct sockaddr_dl'
  209 |                link->sdl_data + link->sdl_nlen,
      |                                     ^~
make: *** [Makefile:109: tmp/rawsock-getmac.o] Error 1
Arandom-username commented 1 year ago

@Badbird5907

I could be wrong as I am not too good of a developer, but from your logs it looks like you are using "cygwin" to compile when in the README.md it says

"Windows w/ cygwin: won't work"

A possible fix for you could be to switch to MinGW32, but I used that frmo the start and got the same error.

Badbird5907 commented 1 year ago

Yep, that's what I did and it worked (with some changes) https://github.com/Badbird5907/masscan

fr0zert commented 1 year ago

bruh, im fix problem by just open project in VS and rebuild it and then compile it. dont need to rewrite anything

Badbird5907 commented 1 year ago

I don't use VS

schmitzCatz commented 1 year ago

bruh, im fix problem by just open project in VS and rebuild it and then compile it. dont need to rewrite anything

Thanks for your contribution, but it looks like the mingw tool chain is not working.