sctplab / usrsctp

A portable SCTP userland stack
BSD 3-Clause "New" or "Revised" License
653 stars 280 forks source link

Cross compile for Windows using x86_64-w64-mingw64 #632

Open JlnWntr opened 2 years ago

JlnWntr commented 2 years ago

I tried to CC="x86_64-w64-mingw32-gcc" ./configure --host=x86_64-w64-mingw64 on a Ubuntu subystem and make gave me

Making all in usrsctplib
make[1]: Entering directory '/mnt/c/git/usrsctp/usrsctplib'
/bin/bash ../libtool  --tag=CC   --mode=compile x86_64-w64-mingw32-gcc -DPACKAGE_NAME=\"libusrsctp\" -DPACKAGE_TARNAME=\"libusrsctp\" -DPACKAGE_VERSION=\"0.9.5.0\" -DPACKAGE_STRING=\"libusrsctp\ 0.9.5.0\" -DPACKAGE_BUGREPORT=\"\" -DPACKAGE_URL=\"\" -DPACKAGE=\"libusrsctp\" -DVERSION=\"0.9.5.0\" -DSTDC_HEADERS=1 -DHAVE_SYS_TYPES_H=1 -DHAVE_SYS_STAT_H=1 -DHAVE_STDLIB_H=1 -DHAVE_STRING_H=1 -DHAVE_MEMORY_H=1 -DHAVE_STRINGS_H=1 -DHAVE_INTTYPES_H=1 -DHAVE_STDINT_H=1 -DHAVE_UNISTD_H=1 -DLT_OBJDIR=\".libs/\" -DSCTP_DEBUG=1 -DINET=1 -DINET6=1 -DHAVE_STDATOMIC_H=1 -Dsocklen_t=int -I.    -DSCTP_PROCESS_LEVEL_LOCKS -DSCTP_SIMPLE_ALLOCATOR -D__Userspace__ -g -O2 -std=c99 -pthread -D_GNU_SOURCE -Wno-address-of-packed-member -pedantic -Wall -Werror -g -O0 -MT netinet/libusrsctp_la-sctp_cc_functions.lo -MD -MP -MF netinet/.deps/libusrsctp_la-sctp_cc_functions.Tpo -c -o netinet/libusrsctp_la-sctp_cc_functions.lo `test -f 'netinet/sctp_cc_functions.c' || echo './'`netinet/sctp_cc_functions.c
libtool: compile:  x86_64-w64-mingw32-gcc -DPACKAGE_NAME=\"libusrsctp\" -DPACKAGE_TARNAME=\"libusrsctp\" -DPACKAGE_VERSION=\"0.9.5.0\" "-DPACKAGE_STRING=\"libusrsctp 0.9.5.0\"" -DPACKAGE_BUGREPORT=\"\" -DPACKAGE_URL=\"\" -DPACKAGE=\"libusrsctp\" -DVERSION=\"0.9.5.0\" -DSTDC_HEADERS=1 -DHAVE_SYS_TYPES_H=1 -DHAVE_SYS_STAT_H=1 -DHAVE_STDLIB_H=1 -DHAVE_STRING_H=1 -DHAVE_MEMORY_H=1 -DHAVE_STRINGS_H=1 -DHAVE_INTTYPES_H=1 -DHAVE_STDINT_H=1 -DHAVE_UNISTD_H=1 -DLT_OBJDIR=\".libs/\" -DSCTP_DEBUG=1 -DINET=1 -DINET6=1 -DHAVE_STDATOMIC_H=1 -Dsocklen_t=int -I. -DSCTP_PROCESS_LEVEL_LOCKS -DSCTP_SIMPLE_ALLOCATOR -D__Userspace__ -g -O2 -std=c99 -pthread -D_GNU_SOURCE -Wno-address-of-packed-member -pedantic -Wall -Werror -g -O0 -MT netinet/libusrsctp_la-sctp_cc_functions.lo -MD -MP -MF netinet/.deps/libusrsctp_la-sctp_cc_functions.Tpo -c netinet/sctp_cc_functions.c  -fPIC -DPIC -o netinet/.libs/libusrsctp_la-sctp_cc_functions.o
<command-line>: error: two or more data types in declaration specifiers
make[1]: *** [Makefile:694: netinet/libusrsctp_la-sctp_cc_functions.lo] Error 1
make[1]: Leaving directory '/mnt/c/git/usrsctp/usrsctplib'
make: *** [Makefile:410: all-recursive] Error 1

Am I doing this right? :)

tuexen commented 2 years ago

No idea, since I have no experience with Windows based systems including cross compiling for it... Can't you compile it natively on Windows?

weinrank commented 2 years ago

Give CMAKE a try... :)

JlnWntr commented 2 years ago

Give CMAKE a try

I believe you have to know cmake in order to do that. (And that's an entirely different chore.) How do you tell cmake to use mingw or crosscompile for windows?

$ CC="x86_64-w64-mingw32-gcc" cmake ../usrsctp/ throws this error:

The C compiler

    "/usr/bin/x86_64-w64-mingw32-gcc"

  is not able to compile a simple test program.

Which is odd, since I've already compiled other libraries using mingw.

@tuexen : The possibility to crosscompile usrsctp is in my opinion really interesting combined with the idea that it is advertised to be portable. (Which it is.)

tuexen commented 2 years ago

Give CMAKE a try

I believe you have to know cmake in order to do that. (And that's an entirely different chore.) How do you tell cmake to use mingw or crosscompile for windows?

$ CC="x86_64-w64-mingw32-gcc" cmake ../usrsctp/ throws this error:

The C compiler

    "/usr/bin/x86_64-w64-mingw32-gcc"

  is not able to compile a simple test program.

No idea. I'm always referring to @weinrank for any cmake related question...

Which is odd, since I've already compiled other libraries using mingw.

@tuexen : The possibility to crosscompile usrsctp is in my opinion really interesting combined with the idea that it is advertised to be portable. (Which it is.)

I agree, but I have never done it...

lgrahl commented 2 years ago

Not touching CMake with a ten foot pole but I regularly built usrsctp for Windows as a Meson subproject via Dockcross in a CI environment, so it's definitely possible: https://github.com/rawrtc/ci-image/tree/cross/windows-x64