From d0184f7cc258be16e35c15351d63ff60a824c587 Mon Sep 17 00:00:00 2001 From: Steffen Pohle Date: Wed, 8 Dec 2021 21:59:50 +0100 Subject: [PATCH] crosscompiling works. --- Makefile | 28 +++++++++---------------- copydlls.sh | 58 +++++++++++++++++++++++++++++----------------------- copyshare.sh | 6 ++++++ 3 files changed, 48 insertions(+), 44 deletions(-) diff --git a/Makefile b/Makefile index c9f55aa..db3b7c5 100644 --- a/Makefile +++ b/Makefile @@ -51,6 +51,7 @@ $(TARGET): $(OBJECTS) $(CPP) -o $@ -c $(CPPFLAGS) $< clean: + rm -rf TestModbus-Server-$(VERSION)/ rm -f *.o *.oo *.c~ *.h~ *.cc~ *.ui~ $(APP) Makefile~ rm -rf *.dll rm -rf *.exe @@ -80,31 +81,22 @@ test-fc16: test-fc16.cc test-fc15: test-fc15.cc $(CPP) -o test-fc15 test-fc15.cc $(LDFLAGS) -I/usr/include -I/usr/local/include -L/usr/local/lib -L/usr/lib -copydll: $(TARGET) - echo "delete all librarys" - rm -rf *.dll - echo "copy linked dll first level" - cp -vf `ldd testmodbus-server.exe | grep .dll | grep /mingw64/bin | cut -d' ' -f3 ` ./ - echo "copy network dll" - cp /usr/lib/*UDPTCPNetwork.dll ./ - echo "copy linked dll second level" - cp -vf `ldd testmodbus-server.exe | grep .dll | grep /mingw64/bin | cut -d' ' -f3 ` ./ - - -buildwindows: - rm -rf TestModbus-Server-$(VERSION) - mkdir TestModbus-Server-$(VERSION) - make clean +buildwindows: clean make configcross - make $(TARGET) + make $(TARGET) -j 9 + mkdir TestModbus-Server-$(VERSION) cp testmodbus-server.exe TestModbus-Server-$(VERSION)/ cp testmodbus-server.ui TestModbus-Server-$(VERSION)/ cp testmodbus-server.png TestModbus-Server-$(VERSION)/ cp README.md TestModbus-Server-$(VERSION)/ cp Changelog TestModbus-Server-$(VERSION)/ cp LICENSE TestModbus-Server-$(VERSION)/ - tar xvzf $(CROSSENV)/files/winbuild-dll.tgz -C TestModbus-Server-$(VERSION)/ - tar xvzf $(CROSSENV)/files/winbuild-share.tgz -C TestModbus-Server-$(VERSION)/ + ./copydlls.sh + ./copyshare.sh + mv *.dll TestModbus-Server-$(VERSION)/ + mv share TestModbus-Server-$(VERSION)/ + #tar xvzf $(CROSSENV)/files/winbuild-dll.tgz -C TestModbus-Server-$(VERSION)/ + #tar xvzf $(CROSSENV)/files/winbuild-share.tgz -C TestModbus-Server-$(VERSION)/ -include $(DEPENDFILE) diff --git a/copydlls.sh b/copydlls.sh index 40c44fd..c11a144 100755 --- a/copydlls.sh +++ b/copydlls.sh @@ -1,32 +1,38 @@ #!/bin/bash -cp -v /usr/lib/gcc/x86_64-w64-mingw32/10-win32/libgcc_s_seh-1.dll ./ -cp -v /usr/lib/gcc/x86_64-w64-mingw32/10-win32/libssp-0.dll ./ -cp -v /usr/lib/gcc/x86_64-w64-mingw32/10-win32/libstdc++-6.dll ./ +CROSS_DEST_DIR=/opt/W64-cross-compile/lib +CROSS_COMPILER_DIR=/usr/x86_64-w64-mingw32/lib +CROSS_GCC_DIR=/usr/lib/gcc/x86_64-w64-mingw32/10-win32 -for i in `strings testmodbus-server.exe | grep -i '\.dll$' | grep -e "^lib"` -do - if [ -e /opt/W64-cross-compile/lib/$i ] - then - cp -v /opt/W64-cross-compile/lib/$i ./ - for j in `strings $i | grep -i '\.dll$' | grep -e "^lib"` - do - if [ -e /opt/W64-cross-compile/lib/$j ] - then - cp -v /opt/W64-cross-compile/lib/$j ./ - fi - if [ -e /usr/x86_64-w64-mingw32/lib/$j ] - then - cp -v /usr/x86_64-w64-mingw32/lib/$j ./ - fi - done - - fi - if [ -e /usr/x86_64-w64-mingw32/lib/$i ] - then - cp -v /usr/x86_64-w64-mingw32/lib/$i ./ - fi +cp -v $CROSS_COMPILER_DIR/zlib1.dll ./ -done +# copy dll dependencys +copy_dependency() { + local I + for I in `strings $1 | grep -i '\.dll$' | grep -e "^lib"` + do + if [ -e ./$I ] + then + echo "File Exist" + + elif [ -e $CROSS_COMPILER_DIR/$I ] + then + cp -v $CROSS_COMPILER_DIR/$I ./ + copy_dependency $CROSS_COMPILER_DIR/$I + + elif [ -e $CROSS_GCC_DIR/$I ] + then + cp -v $CROSS_GCC_DIR/$I ./ + copy_dependency $CROSS_GCC_DIR/$I + + elif [ -e $CROSS_DEST_DIR/$I ] + then + cp -v $CROSS_DEST_DIR/$I ./ + copy_dependency $CROSS_DEST_DIR/$I + fi + + done +} +copy_dependency testmodbus-server.exe diff --git a/copyshare.sh b/copyshare.sh index 4d1d3ff..2eb2180 100755 --- a/copyshare.sh +++ b/copyshare.sh @@ -1,4 +1,10 @@ #!/bin/bash +CROSS_PREFIX=/opt/W64-cross-compile + mkdir share +cp -rf $CROSS_PREFIX/share/glib-2.0 share/glib-2.0 +cp -rf $CROSS_PREFIX/share/gtk-2.0 share/gtk-4.0 +cp -rf $CROSS_PREFIX/share/gtk-3.0 share/gtk-3.0 +cp -rf $CROSS_PREFIX/share/icons share/icons