n2n
n2n copied to clipboard
Dev branch for windows MINGW build not well support extra library build
as title, currnet dev build which using MINGW on the windows build, it is not support to specify the extra library compile flag which used like on linux build e.g --enable-natmap --enable-miniupnpc etc.
This seems will block those features applicable on windows.
These features are still available, just not in a simple and integrated fashion. Until this integration has been improved, if you want to both follow the development branch and use these features on windows, you can use something like the following workaround:
cd n2n
git submodule update --init
./scripts/hack_fakeautoconf.sh
export CC=gcc
cd thirdparty/libnatpmp
sed -i -E -e 's/(CC = i686-w64-mingw32-gcc)/#\1/' Makefile
sed -i -E -e '3a#define NATPMP_STATICLIB 1' natpmp_declspec.h
make libnatpmp.a
cd ../..
cd thirdparty/miniupnp/miniupnpc
sed -i -E -e '3a#define MINIUPNP_STATICLIB 1' include/miniupnpc_declspec.h
make -f Makefile.mingw libminiupnpc.a
cp -a include miniupnpc
cd ../../../
echo "#define HAVE_NATPMP 1" >>include/config.h
echo 'LDLIBS_EXTRA+=-lnatpmp' >>config.mak
echo 'CFLAGS+=-I$(realpath thirdparty/libnatpmp/)' >>config.mak
echo 'LDFLAGS+=-L$(realpath thirdparty/libnatpmp/)' >>config.mak
echo "#define HAVE_MINIUPNP 1" >>include/config.h
echo 'LDLIBS_EXTRA+=-lminiupnpc' >>config.mak
echo 'CFLAGS+=-I$(realpath thirdparty/miniupnp/miniupnpc/)' >>config.mak
echo 'LDFLAGS+=-L$(realpath thirdparty/miniupnp/miniupnpc/)' >>config.mak
make
OK.Got.I will have a try. Thank you.Looking forward to a simplified integration build way
---Original--- From: "Hamish @.> Date: Thu, May 11, 2023 15:27 PM To: @.>; Cc: "michael @.@.>; Subject: Re: [ntop/n2n] Dev branch for windows MINGW build not well supportextra library build (Issue #1110)
These features are still available, just not in a simple and integrated fashion. Until this integration has been improved, if you want to both follow the development branch and use these features on windows, you can use something like the following workaround:
cd n2n git submodule update --init ./scripts/hack_fakeautoconf.sh export CC=gcc cd thirdparty/libnatpmp sed -i -E -e 's/(CC = i686-w64-mingw32-gcc)/#\1/' Makefile sed -i -E -e '3a#define NATPMP_STATICLIB 1' natpmp_declspec.h make libnatpmp.a cd ../.. cd thirdparty/miniupnp/miniupnpc sed -i -E -e '3a#define MINIUPNP_STATICLIB 1' include/miniupnpc_declspec.h make -f Makefile.mingw libminiupnpc.a cp -a include miniupnpc cd ../../../ echo "#define HAVE_NATPMP 1" >>include/config.h echo 'LDLIBS_EXTRA+=-lnatpmp' >>config.mak echo 'CFLAGS+=-I$(realpath thirdparty/libnatpmp/)' >>config.mak echo 'LDFLAGS+=-L$(realpath thirdparty/libnatpmp/)' >>config.mak echo "#define HAVE_MINIUPNP 1" >>include/config.h echo 'LDLIBS_EXTRA+=-lminiupnpc' >>config.mak echo 'CFLAGS+=-I$(realpath thirdparty/miniupnp/miniupnpc/)' >>config.mak echo 'LDFLAGS+=-L$(realpath thirdparty/miniupnp/miniupnpc/)' >>config.mak make
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you authored the thread.Message ID: @.***>
I have tested your steps, looks good. thanks. maybe you can make it in a build script and integrated it.
I have tested your steps, looks good. thanks. maybe you can make it in a build script and integrated it.
Have we gotta any further steps on this? thanks.
That's... eww.
CMake anyone?
Yes, this is eww - it was never supposed to be anything else, and the long term goal is to have an answer for this before the next stable release.
We used to have cmake, but it made debugging harder, optimisation almost impossible, multi-architecture/multi-os support inscrutible and worst of all - when things broke, the maintainers didnt want to have to deal with cmake.
But cross-compiling is what CMake is good at! All you need is a simple toolchain file. For example:
set(CMAKE_SYSTEM_NAME Windows)
set(CMAKE_SYSTEM_PROCESSOR x86_64)
set(triple x86_64-w64-mingw32)
set(CMAKE_C_COMPILER x86_64-w64-mingw32-gcc-10-posix)
set(CMAKE_C_COMPILER_TARGET ${triple})
set(CMAKE_CXX_COMPILER x86_64-w64-mingw32-c++-posix)
set(CMAKE_CXX_COMPILER_TARGET ${triple})
I feed that to cmake along with the CMakeList and out pops a Windows build from my Linux box. Seeing as how the two NAT libraries N2N uses already use CMake, it wouldn't be hard to tie it all together into a single build.
I know CMake is ... odd. But AutoTools? Egads! :grinning: