scrcpy icon indicating copy to clipboard operation
scrcpy copied to clipboard

cross-compile fail for Windows in Ubuntu

Open Howie-hxu opened this issue 8 years ago • 17 comments

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

Howie-hxu avatar Oct 30 '18 12:10 Howie-hxu

Ubuntu 16.04

Howie-hxu avatar Oct 30 '18 12:10 Howie-hxu

I cannot reproduce on Ubuntu 16.04, it works fine for me.

Could you clean and retest?

rom1v avatar Nov 12 '18 13:11 rom1v

Also getting the same issue, but using Debian GNU/Linux from the Windows App Store.

Debian 9.6/stretch. Windows 10.

Ghoulean avatar Dec 04 '18 23:12 Ghoulean

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:

rom1v avatar Dec 05 '18 07:12 rom1v

Could you test #479, please?

rom1v avatar Mar 27 '19 20:03 rom1v

For me it's working like a charm but someone could test it anyway for sure. It shouldn't break anything.

Gerdal avatar Mar 28 '19 22:03 Gerdal

Should be fixed by #479.

rom1v avatar Mar 31 '19 18:03 rom1v

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 avatar Dec 21 '19 17:12 dilbert168

@dilbert168 What if you revert 18f2e33a8bf967a813142dbe9556813032ec9f0b?

rom1v avatar Dec 21 '19 18:12 rom1v

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

dilbert168 avatar Dec 21 '19 20:12 dilbert168

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.

rom1v avatar Dec 21 '19 21:12 rom1v

Any other suggestion for this cross window build issue ?

dilbert168 avatar Dec 21 '19 23:12 dilbert168

What if you remove #define SDL_MAIN_HANDLED?

Try adding link flag -lmingw32: https://github.com/libSDL2pp/libSDL2pp/issues/66#issuecomment-169528379

rom1v avatar Dec 22 '19 01:12 rom1v

Or use a newer version of mingw (on Debian 10 for example).

rom1v avatar Dec 22 '19 01:12 rom1v

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 ??

dilbert168 avatar Dec 24 '19 17:12 dilbert168

where should I place the " link flag -lmingw32" ? inside cross_win32.txt ??

In meson.build, in the link_args array.

rom1v avatar Dec 24 '19 17:12 rom1v

Thanks again. I resolved the cross window build issue by getting a newer Debian-10.2.

dilbert168 avatar Dec 27 '19 21:12 dilbert168