v icon indicating copy to clipboard operation
v copied to clipboard

Can not run compiled program on windows (linked using msys/mingw)

Open T0maas opened this issue 2 years ago • 5 comments

Describe the bug

I was trying calculator example (https://github.com/vlang/ui/blob/master/examples/calculator.v) on windows. I installed required module v.exe install ui And then I compiled that example inside msys (mingw): v.exe calculator.v And launched it inside msys: ./calculator.exe

But after launch I am getting this error: Assertion failed: _sapp.wgl.arb_pixel_format, file C:\msys64\home\tom\v\thirdparty\sokol/sokol_app.h, line 6568 and some empty white window just blinks.

When launching outside msys (using double click on calculator.exe in explorer) it complains about missing libwinpthread-1.dll

I tried to crosscompile on linux v -os windows -ldflags "-Wl,-Bstatic,--whole-archive -lwinpthread -Wl,--no-whole-archive" calculator.v I had to add some compiler flags to staticall link, because it complained about winpthread. When I move this exe to windows and launch it, it produces same error with arb_pixel_format.

When I compile it on linux (not cross compiling) it and launch it then window shows normally and program works under linux.

During compilation I didn't see any errors.

Expected Behavior

It must work on windows like it works on linux.

Current Behavior

Crashing or not launching with those messages:

  1. When launch inside msys: Assertion failed: _sapp.wgl.arb_pixel_format, file C:\msys64\home\tom\v\thirdparty\sokol/sokol_app.h, line 6568 and some empty white window just blinks.

  2. When launching outside msys (using double click on calculator.exe in explorer) it complains about missing libwinpthread-1.dll

  3. When cross-compiled on linux v -os windows -ldflags "-Wl,-Bstatic,--whole-archive -lwinpthread -Wl,--no-whole-archive" calculator.v and launched on windows: It does not complain about libwinpthread-1.dll (that's ok), but complains about arb_pixel_format (same message in first case) in msys and outside msys.

Reproduction Steps

  1. Install required module v.exe install ui
  2. Compile it under windows inside msys v.exe calculator.v
  3. Launch it ./calculator.exe
  4. See errors.

Possible Solution

No response

Additional Information/Context

Verison of gcc in msys/mingw $ gcc --version

gcc.exe (Rev10, Built by MSYS2 project) 12.2.0
Copyright (C) 2022 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

version of gcc mingw on linux

x86_64-w64-mingw32-gcc (GCC) 12.2.0
Copyright (C) 2022 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

V version

V 0.3.4 ac32d2a

Environment details (OS name and version, etc.)

Windows 10 Msys 2 (msys2-x86_64-20220904) gcc 12.2.0 (from package: mingw64/mingw-w64-x86_64-gcc 12.2.0-10)

Linux (used for cross compiling) x86_64-w64-mingw32-gcc (GCC) 12.2.0

T0maas avatar Jun 17 '23 10:06 T0maas

We recommend the gcc/clang package from https://winlibs.com - it is the one that has caused the least amount of problems for other V users.

Also highly recommend enabling WSL instead of using msys.

JalonSolov avatar Jun 17 '23 11:06 JalonSolov

Does WSL produce windows native binaries? I want windows native binary.

T0maas avatar Jun 17 '23 12:06 T0maas

Just cross-compile from Linux to Windows. Works fine.

JalonSolov avatar Jun 17 '23 12:06 JalonSolov

And if you do use WSL, you don't need to worry about gcc on Windows, because you can use the native Linux gcc.

JalonSolov avatar Jun 17 '23 12:06 JalonSolov

i have got same problem but in other line, and i built from linux to windows

Assertion failed: _sapp.wgl.arb_pixel_format, file /home/diman/Documents/v/thirdparty/sokol/sokol_app.h, line 6883

SuperErnD avatar May 31 '24 07:05 SuperErnD

It works on Windows 11

I tried to run (inside msys because of libwinpthread-1.dll) same executable (build using v -os windows10 main.v) to run on windows 10 and it failed with message:

Assertion failed: _sapp.wgl.arb_pixel_format, file /home/tom/programy/v/thirdparty/sokol/sokol_app.h
, line 6929

But when I run this executable on windows 11 (inside msys) it works

Executable was compiled with:

  • V 0.4.7 8f95709
  • UI Version: 0.0.4
  • x86_64-w64-mingw32-gcc (GCC) 13.1.0

Btw i am running win10 inside kvm with QXL graphics, but win11 on physical machine - intel nuc

T0maas avatar Sep 02 '24 14:09 T0maas

looks like its not supported OpenGL version (outdated, or even not supporting), i successfully ran a GG (vui looks using it) app on gpu which support latest (4.6) OpenGL, i think sokol need opengl 3.x

SuperErnD avatar Sep 08 '24 11:09 SuperErnD

From the sokol home page:

simple, modern wrapper around GLES3/WebGL2, GL3.3, D3D11, Metal, and WebGPU

So yes, your video drivers must support opengl 3.3/Direct3D 11 at a minimum.

JalonSolov avatar Sep 08 '24 14:09 JalonSolov