cross-compile fail for Windows in Ubuntu
FAILED: app/scrcpy.exe
/usr/bin/i686-w64-mingw32-gcc -o app/scrcpy.exe 'app/scrcpy@exe/src_main.c.obj' 'app/scrcpy@exe/src_command.c.obj' 'app/scrcpy@exe/src_control_event.c.obj' 'app/scrcpy@exe/src_controller.c.obj' 'app/scrcpy@exe/src_convert.c.obj' 'app/scrcpy@exe/src_decoder.c.obj' 'app/scrcpy@exe/src_device.c.obj' 'app/scrcpy@exe/src_file_handler.c.obj' 'app/scrcpy@exe/src_fps_counter.c.obj' 'app/scrcpy@exe/src_frames.c.obj' 'app/scrcpy@exe/src_input_manager.c.obj' 'app/scrcpy@exe/src_lock_util.c.obj' 'app/scrcpy@exe/src_net.c.obj' 'app/scrcpy@exe/src_scrcpy.c.obj' 'app/scrcpy@exe/src_screen.c.obj' 'app/scrcpy@exe/src_server.c.obj' 'app/scrcpy@exe/src_str_util.c.obj' 'app/scrcpy@exe/src_tiny_xpm.c.obj' 'app/scrcpy@exe/src_sys_win_command.c.obj' 'app/scrcpy@exe/src_sys_win_net.c.obj' '-flto' '-Wl,--no-undefined' '-Wl,--as-needed' '-Wl,-O1' '/home/dogee/work/demo/scrcpy-master/app/../prebuilt-deps/ffmpeg-4.0.2-win32-shared/bin/avcodec-58.dll' '/home/dogee/work/demo/scrcpy-master/app/../prebuilt-deps/ffmpeg-4.0.2-win32-shared/bin/avformat-58.dll' '/home/dogee/work/demo/scrcpy-master/app/../prebuilt-deps/ffmpeg-4.0.2-win32-shared/bin/avutil-56.dll' '/home/dogee/work/demo/scrcpy-master/app/../prebuilt-deps/SDL2-2.0.8/i686-w64-mingw32/bin/SDL2.dll' '/home/dogee/work/demo/scrcpy-master/app/../prebuilt-deps/SDL2-2.0.8/i686-w64-mingw32/lib/libSDL2main.a' '-lmingw32' '-lws2_32' '-lkernel32' '-luser32' '-lgdi32' '-lwinspool' '-lshell32' '-lole32' '-loleaut32' '-luuid' '-lcomdlg32' '-ladvapi32'
/usr/lib/gcc/i686-w64-mingw32/5.3-win32/../../../../i686-w64-mingw32/lib/../lib/libmingw32.a(lib32_libmingw32_a-crt0_c.o): In function `main':
/build/mingw-w64-_1w3Xm/mingw-w64-4.0.4/mingw-w64-crt/crt/crt0_c.c:18: undefined reference to `WinMain@16'
collect2: error: ld returned 1 exit status
ninja: build stopped: subcommand failed.
Makefile.CrossWindows:54: recipe for target 'build-win32' failed
It seems to be lack of " WinMain@16'", but if I changed the function "int main" to "int WinMain", I would got compile passed but run with empty
Ubuntu 16.04
I cannot reproduce on Ubuntu 16.04, it works fine for me.
Could you clean and retest?
Also getting the same issue, but using Debian GNU/Linux from the Windows App Store.
Debian 9.6/stretch. Windows 10.
I cannot reproduce on Ubuntu 16.04, it works fine for me.
Oh sorry, I directly answered to the previous message when I received the notification (without re-reading the initial post), so I tested on a real Ubuntu 16.04.
For Ubuntu on Windows, I don't know.
If you find a solution, please tell us :wink:
Could you test #479, please?
For me it's working like a charm but someone could test it anyway for sure. It shouldn't break anything.
Should be fixed by #479.
I am using the Debian 9.8 on VirtualBox. Using the latest code from "git clone https://github.com/Genymobile/scrcpy" Have check the "main.c" and it has the fix : #define SDL_MAIN_HANDLED // avoid link error on Linux Windows Subsystem
Anyone has idea or solution ?
./mingw-w64-crt/crt/crt0_c.c:18: undefined reference to `WinMain@16' collect2: error: ld returned 1 exit status ninja: build stopped: subcommand failed. Makefile.CrossWindows:54: recipe for target 'build-win32' failed make: *** [build-win32] Error 1
@dilbert168 What if you revert 18f2e33a8bf967a813142dbe9556813032ec9f0b?
I have made following changes in "meson.build" but error the same.
if get_option('windows_noconsole')
c_args = [ '-mwindows' ]
link_args = [ '-mwindows' ]
# link_args = [ '-Wl,--subsystem,windows' ]
else
c_args = []
link_args = []
endif
executable('scrcpy', src,
dependencies: dependencies,
include_directories: src_dir,
install: true,
c_args: c_args,
# c_args: [],
link_args: link_args)
p.s. During the build, does this warning any concern ? WARNING: Unknown keyword arguments in target scrcpy-server: console
During the build, does this warning any concern ? WARNING: Unknown keyword arguments in target scrcpy-server: console
No, it's just an option not supported for your version of meson, but it's not important. See 20b3f101a40cd7455cc5b41e381291504deec5ba.
Any other suggestion for this cross window build issue ?
What if you remove #define SDL_MAIN_HANDLED?
Try adding link flag -lmingw32: https://github.com/libSDL2pp/libSDL2pp/issues/66#issuecomment-169528379
Or use a newer version of mingw (on Debian 10 for example).
I tried remove "#define SDL_MAIN_HANDLED?" but did not work.
I am new to this build env... where should I place the " link flag -lmingw32" ? inside cross_win32.txt ??
where should I place the " link flag -lmingw32" ? inside cross_win32.txt ??
In meson.build, in the link_args array.
Thanks again. I resolved the cross window build issue by getting a newer Debian-10.2.