pkulchenko / ZeroBraneStudio

Lightweight Lua-based IDE for Lua with code completion, syntax highlighting, live coding, remote debugger, and code analyzer; supports Lua 5.1, 5.2, 5.3, 5.4, LuaJIT and other Lua interpreters on Windows, macOS, and Linux
http://studio.zerobrane.com/
Other
2.62k stars 518 forks source link

Error when trying to build win32 exe #988

Closed fsinisi90 closed 5 years ago

fsinisi90 commented 5 years ago

I'm trying to generate a new .exe file, so I'm running only this part of the build-win32.sh script:

windres ../zbstudio/res/zbstudio.rc zbstudio.rc.o
gcc -O2 -s -mwindows -o ../zbstudio.exe win32_starter.c zbstudio.rc.o
rm zbstudio.rc.o
[ -f ../zbstudio.exe ] || { echo "Error: zbstudio.exe isn't found"; exit 1; }

I've installed mingw:

sudo apt-get install mingw-w64

And then run:

$ ./build-win32-exe-only.sh
gcc: error: unrecognized command line option ‘-mwindows’; did you mean ‘-m3dnow’?
Error: zbstudio.exe isn't found

gcc version:

$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/7/lto-wrapper
OFFLOAD_TARGET_NAMES=nvptx-none
OFFLOAD_TARGET_DEFAULT=1
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu 7.4.0-1ubuntu1~18.04' --with-bugurl=file:///usr/share/doc/gcc-7/README.Bugs --enable-languages=c,ada,c++,go,brig,d,fortran,objc,obj-c++ --prefix=/usr --with-gcc-major-version-only --program-suffix=-7 --program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-vtable-verify --enable-libmpx --enable-plugin --enable-default-pie --with-system-zlib --with-target-system-zlib --enable-objc-gc=auto --enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-offload-targets=nvptx-none --without-cuda-driver --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
gcc version 7.4.0 (Ubuntu 7.4.0-1ubuntu1~18.04)
pkulchenko commented 5 years ago

@fsinisi90, does it work when you build using 32bit mingw? I'm confused why your gcc shows linux target (x86_64-linux-gnu); are you trying to cross-compile to get Windows executable?

The Windows scripts have been written to build 32bit executables, although some parts have also been tested on 64bit builds (luasocket, luasec, and few others). I'm not sure why it complaints about -mwindows, but will check.

pkulchenko commented 5 years ago

I just tested with 64bit mingw and it worked without issues using the same build script.

Here is my gcc version (I'm using one from msys2):

Target: x86_64-w64-mingw32
Configured with: ../gcc-4.9.2/configure --prefix=/mingw64 --with-local-prefix=/mingw64/local --build=x86_64-w64-mingw32 --host=x86_64-w64-mingw32 --target=x86_64-w64-mingw32 --with-native-system-header-dir=/mingw64/x86_64-w64-mingw32/include --libexecdir=/mingw64/lib --with-gxx-include-dir=/mingw64/include/c++/4.9.2 --enable-bootstrap --with-arch=x86-64 --with-tune=generic --enable-languages=c,lto,c++,objc,obj-c++,fortran,ada --enable-shared --enable-static --enable-libatomic --enable-threads=posix --enable-graphite --enable-fully-dynamic-string --enable-libstdcxx-time=yes --disable-libstdcxx-pch --disable-libstdcxx-debug --enable-cloog-backend=isl --enable-version-specific-runtime-libs --disable-cloog-version-check --disable-isl-version-check --enable-lto --enable-libgomp --disable-multilib --enable-checking=release --disable-rpath --disable-win32-registry --disable-nls --disable-werror --disable-symvers --with-libiconv --with-system-zlib --with-gmp=/mingw64 --with-mpfr=/mingw64 --with-mpc=/mingw64 --with-isl=/mingw64 --with-cloog=/mingw64 --with-pkgversion='Rev5, Built by MSYS2 project' --with-bugurl=http://sourceforge.net/projects/msys2 --with-gnu-as --with-gnu-ld
gcc version 4.9.2 (Rev5, Built by MSYS2 project) 

(I'm using this fairly old one, as it's been producing better executable sizes than the more recent ones)

fsinisi90 commented 5 years ago

@pkulchenko you're right, I was trying to cross-compile it when I could compile it on Windows directly. I've installed MinGW on Windows following this steps and I was able to generate a new .exe successfully.

BTW it's a .sh script and it has a rm command inside, wasn't it supposed to be executed on Linux?

pkulchenko commented 5 years ago

it's a .sh script and it has a rm command inside, wasn't it supposed to be executed on Linux?

I use msys2, which provides rm and other "unix" tools. Should probably change it to del, but then cp, sed and others would need to be updated as well. It may be easier just to have msys or similar environment installed.

I'm closing the ticket since it's resolved, but feel free to continue the discussion as needed.