nsauzede / vsdl2

🎬 SDL2 V module -- libSDL2 wrapper
MIT License
45 stars 6 forks source link

can't run tvintris example on windows #9

Closed boris-741 closed 3 years ago

boris-741 commented 3 years ago

what i do:

  1. v install nsauzede.vsdl2 2 install msys2 3 do [pacman -S mingw-w64-x86_64-SDL2_ttf mingw-w64-x86_64-SDL2_mixer mingw-w64-x86_64-SDL2_image] with msys2 console

run example v run main_v.v

got me an arror: builder error: 'strings.h' not found

boris-741 commented 3 years ago

i can't build vsdl2 for windows i change SDL_config_windows.h to SDL_config.h and got the error: msys64/mingw64/include/SDL2/SDL_config.h:68: error: incompatible redefinition of 'size_t'

v.exe -cc gcc-10 -os windows -live run "main_v.v" gives me the error msys64/mingw64/include/SDL2/SDL_config.h:68: error: incompatible redefinition of 'size_t' the same error as with tcc compiler

nsauzede commented 3 years ago

what i do:

1. v install nsauzede.vsdl2
   2 install msys2
   3 do [pacman -S mingw-w64-x86_64-SDL2_ttf mingw-w64-x86_64-SDL2_mixer mingw-w64-x86_64-SDL2_image] with msys2 console

run example v run main_v.v

got me an arror: builder error: 'strings.h' not found

I can confirm that error

However, I have this that works :

$ v.exe -cc gcc run tvintris/tvintris.v

Can you please test the same and report ?

If I add -live to the above command, then I have this error :

Microsoft (R) C/C++ Optimizing Compiler Version 19.20.27508.1 for x64
Copyright (C) Microsoft Corporation.  All rights reserved.

cl -w /we4013 /volatile:ms /Fo"C:\msys64\tmp\v\tvintris.7748833833039521500.tmp.so.c.obj" /MDd /D_DEBUG /LD "C:\msys64\tmp\v\tvintris.7748833833039521500.tmp.so.c" -I "C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\ucrt" -I "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.20.27508\include" -I "C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\um" -I "C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\shared" /DSDL_DISABLE_IMMINTRIN_H /Dmain=SDL_main -I "C:\msys64\mingw64\include\SDL2" kernel32.lib user32.lib advapi32.lib dbghelp.lib mingw32.lib SDL2main.lib SDL2.lib SDL2_ttf.lib SDL2_mixer.lib SDL2_image.lib /link /NOLOGO /OUT:"C:\Users\nsauzede\.cache\tmp.1.tvintris\tvintris.dll" /LIBPATH:"C:\Program Files (x86)\Windows Kits\10\Lib\10.0.17763.0\ucrt\X64" /LIBPATH:"C:\Program Files (x86)\Windows Kits\10\Lib\10.0.17763.0\um\X64" /LIBPATH:"C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.20.27508\lib\X64" /DEBUG:FULL /LIBPATH:"C:\msys64\mingw64\lib" /LIBPATH:"C:\msys64\mingw64\lib\msvc"

tvintris.7748833833039521500.tmp.so.c
C:\msys64\mingw64\include\SDL2\SDL_stdinc.h(69): fatal error C1083: Cannot open include file: 'strings.h': No such file or directory
builder error: msvc error
errors while compiling tvintris/tvintris.v
/c/Users/nsauzede/.vmodules/nsauzede/vsdl2/examples$

So I think that -live is broken on Windows : the -cc gcc seems to be not honored by V I think that might be an independent V bug from vsdl2 I guess this should be put in a proper V issue

boris-741 commented 3 years ago

-cc gcc and retun live flag - not help I get the error with msys2 and win cmd console $ C:/vlang/v.exe -cc gcc run "c:/Projects/vlang/sdl2_examples/main_v.v" INFO: compile with v -live c:/Projects/vlang/sdl2_examples/main_v.v, if you want to use the [live] function main.livemain . builder error: 'strings.h' not found

should i build v-lang with mingw copiler? I use tcc on v-lang build.

i run:

  1. pacman -Syu
  2. pacman -S git mingw-w64-x86_64-toolchain mingw64/mingw-w64-x86_64-SDL2 mingw64/mingw-w64-x86_64-SDL2_mixer mingw64/mingw-w64-x86_64-SDL2_image mingw64/mingw-w64-x86_64-SDL2_ttf mingw64/mingw-w64-x86_64-SDL2_net mingw64/mingw-w64-x86_64-cmake make
  3. pacman -S msys2-runtime-devel
  4. build from msys (not cmd - with cmd same error)

now example build? but i got runtime error on start $ C:/vlang/v.exe -cc gcc run "c:/Projects/vlang/sdl2_examples/main_v.v" INFO: compile with v -live c:/Projects/vlang/sdl2_examples/main_v.v, if you want to use the [live] function main.livemain . vsdl2 version: 0.2 current time: 2021-05-18 22:05:42 executable: C:\Projects\vlang\sdl2_examples\main_v.exe hello SDL 2 [v]

Unhandled Exception 0xC0000005 print_backtrace_skipping_top_frames is not implemented Segmentation fault

nsauzede commented 3 years ago

No you don't have to compile the sdl library : you have to install it as documented, and then vsdl2 uses the installed sdl2-config helper to find them

In my post above yours, I actually asked you to test tVintris, and not the main_v example, that I know is currently failing.

So once again, could you please, test the exact following command :

vsdl2/examples$ v -cc gcc run tvintris/tvintris.v

And then, please report here if it works for you, or not ??

boris-741 commented 3 years ago

it turned out to build an example, but now runtime error here

I run: pacman -Syu pacman -S git mingw-w64-x86_64-toolchain mingw64/mingw-w64-x86_64-SDL2 mingw64/mingw-w64-x86_64-SDL2_mixer mingw64/mingw-w64-x86_64-SDL2_image mingw64/mingw-w64-x86_64-SDL2_ttf mingw64/mingw-w64-x86_64-SDL2_net mingw64/mingw-w64-x86_64-cmake make pacman -S msys2-runtime-devel build from msys (not cmd - with cmd same error) now example build? but i got runtime error on start $ C:/vlang/v.exe -cc gcc run "c:/Projects/vlang/sdl2_examples/main_v.v" INFO: compile with v -live c:/Projects/vlang/sdl2_examples/main_v.v , if you want to use the [live] function main.livemain . vsdl2 version: 0.2 current time: 2021-05-18 22:05:42 executable: C:\Projects\vlang\sdl2_examples\main_v.exe hello SDL 2 [v]

Unhandled Exception 0xC0000005 print_backtrace_skipping_top_frames is not implemented Segmentation fault

nsauzede commented 3 years ago

Ok; so you really don't want to try to run https://github.com/nsauzede/vsdl2/blob/master/examples/tvintris/tvintris.v on your side, to help figure out what works/don't work for you ??

boris-741 commented 3 years ago

i see now. tvintris give me that: $ c:/vlang/v.exe -cc gcc run "C:/Projects/vlang/sdl2_examples/tvintris/tvintris.v" C:/Projects/vlang/sdl2_examples/tvintris/tvintris.v:20:2: warning: const names cannot contain uppercase letters, use snake_case instead 18 | const ( 19 | vsdl2_version = vsdl2.version 20 | Title = 'tVintris' | ~ 21 | BASE = os.dir( os.real_path( os.executable() ) ) 22 | font_name = BASE + '/fonts/RobotoMono-Regular.ttf' C:/Projects/vlang/sdl2_examples/tvintris/tvintris.v:21:2: warning: const names cannot contain uppercase letters, use snake_case instead 19 | vsdl2_version = vsdl2.version 20 | Title = 'tVintris' 21 | BASE = os.dir( os.real_path( os.executable() ) ) | ~~~~ 22 | font_name = BASE + '/fonts/RobotoMono-Regular.ttf' 23 | music_name = BASE + '/sounds/TwintrisThosenine.mod' C:/Projects/vlang/sdl2_examples/tvintris/tvintris.v:27:2: warning: const names cannot contain uppercase letters, use snake_case instead 25 | snd_line_name = BASE + '/sounds/single.wav' 26 | snd_double_name = BASE + '/sounds/triple.wav' 27 | VLogo = BASE + '/images/v-logo_30_30.png' | ~ 28 | BlockSize = 20 // pixels 29 | FieldHeight = 20 // # of blocks C:/Projects/vlang/sdl2_examples/tvintris/tvintris.v:28:2: warning: const names cannot contain uppercase letters, use snake_case instead 26 | snd_double_name = BASE + '/sounds/triple.wav' 27 | VLogo = BASE + '/images/v-logo_30_30.png' 28 | BlockSize = 20 // pixels | ~~~~~ 29 | FieldHeight = 20 // # of blocks 30 | FieldWidth = 10 C:/Projects/vlang/sdl2_examples/tvintris/tvintris.v:29:2: warning: const names cannot contain uppercase letters, use snake_case instead 27 | VLogo = BASE + '/images/v-logo_30_30.png' 28 | BlockSize = 20 // pixels 29 | FieldHeight = 20 // # of blocks | ~~~ 30 | FieldWidth = 10 31 | TetroSize = 4 C:/Projects/vlang/sdl2_examples/tvintris/tvintris.v:30:2: warning: const names cannot contain uppercase letters, use snake_case instead 28 | BlockSize = 20 // pixels 29 | FieldHeight = 20 // # of blocks 30 | FieldWidth = 10 | ~~ 31 | TetroSize = 4 32 | WinWidth = BlockSize FieldWidth 3 C:/Projects/vlang/sdl2_examples/tvintris/tvintris.v:31:2: warning: const names cannot contain uppercase letters, use snake_case instead 29 | FieldHeight = 20 // # of blocks 30 | FieldWidth = 10 31 | TetroSize = 4 | ~~~~~ 32 | WinWidth = BlockSize FieldWidth 3 33 | WinHeight = BlockSize FieldHeight C:/Projects/vlang/sdl2_examples/tvintris/tvintris.v:32:2: warning: const names cannot contain uppercase letters, use snake_case instead 30 | FieldWidth = 10 31 | TetroSize = 4 32 | WinWidth = BlockSize FieldWidth 3 | ~~~~ 33 | WinHeight = BlockSize FieldHeight 34 | TimerPeriod = 250 // ms C:/Projects/vlang/sdl2_examples/tvintris/tvintris.v:33:2: warning: const names cannot contain uppercase letters, use snake_case instead 31 | TetroSize = 4 32 | WinWidth = BlockSize FieldWidth 3 33 | WinHeight = BlockSize FieldHeight | ~~~~~ 34 | TimerPeriod = 250 // ms 35 | TextSize = 16 C:/Projects/vlang/sdl2_examples/tvintris/tvintris.v:34:2: warning: const names cannot contain uppercase letters, use snake_case instead 32 | WinWidth = BlockSize FieldWidth 3 33 | WinHeight = BlockSize FieldHeight 34 | TimerPeriod = 250 // ms | ~~~ 35 | TextSize = 16 36 | AudioBufSize = 1024 C:/Projects/vlang/sdl2_examples/tvintris/tvintris.v:35:2: warning: const names cannot contain uppercase letters, use snake_case instead 33 | WinHeight = BlockSize * FieldHeight 34 | TimerPeriod = 250 // ms 35 | TextSize = 16 | ~~~~ 36 | AudioBufSize = 1024 37 | C:/Projects/vlang/sdl2_examples/tvintris/tvintris.v:36:2: warning: const names cannot contain uppercase letters, use snake_case instead 34 | TimerPeriod = 250 // ms 35 | TextSize = 16 36 | AudioBufSize = 1024 | ~~~~ 37 | 38 | P2FIRE = C.SDLK_l C:/Projects/vlang/sdl2_examples/tvintris/tvintris.v:38:2: warning: const names cannot contain uppercase letters, use snake_case instead 36 | AudioBufSize = 1024 37 | 38 | P2FIRE = C.SDLK_l | ~~ 39 | P2UP = C.SDLK_UP 40 | P2DOWN = C.SDLK_DOWN C:/Projects/vlang/sdl2_examples/tvintris/tvintris.v:39:2: warning: const names cannot contain uppercase letters, use snake_case instead 37 | 38 | P2FIRE = C.SDLK_l 39 | P2UP = C.SDLK_UP | ~~~~ 40 | P2DOWN = C.SDLK_DOWN 41 | P2LEFT = C.SDLK_LEFT C:/Projects/vlang/sdl2_examples/tvintris/tvintris.v:40:2: warning: const names cannot contain uppercase letters, use snake_case instead 38 | P2FIRE = C.SDLK_l 39 | P2UP = C.SDLK_UP 40 | P2DOWN = C.SDLK_DOWN | ~~ 41 | P2LEFT = C.SDLK_LEFT 42 | P2RIGHT = C.SDLK_RIGHT C:/Projects/vlang/sdl2_examples/tvintris/tvintris.v:41:2: warning: const names cannot contain uppercase letters, use snake_case instead 39 | P2UP = C.SDLK_UP 40 | P2DOWN = C.SDLK_DOWN 41 | P2LEFT = C.SDLK_LEFT | ~~ 42 | P2RIGHT = C.SDLK_RIGHT 43 | C:/Projects/vlang/sdl2_examples/tvintris/tvintris.v:42:2: warning: const names cannot contain uppercase letters, use snake_case instead 40 | P2DOWN = C.SDLK_DOWN 41 | P2LEFT = C.SDLK_LEFT 42 | P2RIGHT = C.SDLK_RIGHT | ~~~ 43 | 44 | P1FIRE = C.SDLK_s C:/Projects/vlang/sdl2_examples/tvintris/tvintris.v:44:2: warning: const names cannot contain uppercase letters, use snake_case instead 42 | P2RIGHT = C.SDLK_RIGHT 43 | 44 | P1FIRE = C.SDLK_s | ~~ 45 | P1UP = C.SDLK_w 46 | P1DOWN = C.SDLK_x C:/Projects/vlang/sdl2_examples/tvintris/tvintris.v:45:2: warning: const names cannot contain uppercase letters, use snake_case instead 43 | 44 | P1FIRE = C.SDLK_s 45 | P1UP = C.SDLK_w | ~~~~ 46 | P1DOWN = C.SDLK_x 47 | P1LEFT = C.SDLK_a C:/Projects/vlang/sdl2_examples/tvintris/tvintris.v:46:2: warning: const names cannot contain uppercase letters, use snake_case instead 44 | P1FIRE = C.SDLK_s 45 | P1UP = C.SDLK_w 46 | P1DOWN = C.SDLK_x | ~~ 47 | P1LEFT = C.SDLK_a 48 | P1RIGHT = C.SDLK_d C:/Projects/vlang/sdl2_examples/tvintris/tvintris.v:47:2: warning: const names cannot contain uppercase letters, use snake_case instead 45 | P1UP = C.SDLK_w 46 | P1DOWN = C.SDLK_x 47 | P1LEFT = C.SDLK_a | ~~ 48 | P1RIGHT = C.SDLK_d 49 | C:/Projects/vlang/sdl2_examples/tvintris/tvintris.v:48:2: warning: const names cannot contain uppercase letters, use snake_case instead 46 | P1DOWN = C.SDLK_x 47 | P1LEFT = C.SDLK_a 48 | P1RIGHT = C.SDLK_d | ~~~ 49 | 50 | NJOYMAX = 2 C:/Projects/vlang/sdl2_examples/tvintris/tvintris.v:50:2: warning: const names cannot contain uppercase letters, use snake_case instead 48 | P1RIGHT = C.SDLK_d 49 | 50 | NJOYMAX = 2 | ~~~ 51 | // joystick name => enter your own device name 52 | JOYP1NAME = 'Generic X-Box pad' C:/Projects/vlang/sdl2_examples/tvintris/tvintris.v:52:2: warning: const names cannot contain uppercase letters, use snake_case instead 50 | NJOYMAX = 2 51 | // joystick name => enter your own device name 52 | JOYP1NAME = 'Generic X-Box pad' | ~~~~~ 53 | // following are joystick button number 54 | JBP1FIRE = 1 C:/Projects/vlang/sdl2_examples/tvintris/tvintris.v:54:2: warning: const names cannot contain uppercase letters, use snake_case instead 52 | JOYP1NAME = 'Generic X-Box pad' 53 | // following are joystick button number 54 | JBP1FIRE = 1 | ~~~~ 55 | // following are joystick hat value 56 | JHP1UP = 1 C:/Projects/vlang/sdl2_examples/tvintris/tvintris.v:56:2: warning: const names cannot contain uppercase letters, use snake_case instead 54 | JBP1FIRE = 1 55 | // following are joystick hat value 56 | JHP1UP = 1 | ~~ 57 | JHP1DOWN = 4 58 | JHP1LEFT = 8 C:/Projects/vlang/sdl2_examples/tvintris/tvintris.v:57:2: warning: const names cannot contain uppercase letters, use snake_case instead 55 | // following are joystick hat value 56 | JHP1UP = 1 57 | JHP1DOWN = 4 | ~~~~ 58 | JHP1LEFT = 8 59 | JHP1RIGHT = 3 C:/Projects/vlang/sdl2_examples/tvintris/tvintris.v:58:2: warning: const names cannot contain uppercase letters, use snake_case instead 56 | JHP1UP = 1 57 | JHP1DOWN = 4 58 | JHP1LEFT = 8 | ~~~~ 59 | JHP1RIGHT = 3 60 | C:/Projects/vlang/sdl2_examples/tvintris/tvintris.v:59:2: warning: const names cannot contain uppercase letters, use snake_case instead 57 | JHP1DOWN = 4 58 | JHP1LEFT = 8 59 | JHP1RIGHT = 3 | ~~~~~ 60 | 61 | // joystick name => enter your own device name C:/Projects/vlang/sdl2_examples/tvintris/tvintris.v:62:2: warning: const names cannot contain uppercase letters, use snake_case instead 60 | 61 | // joystick name => enter your own device name 62 | JOYP2NAME = 'RedOctane Guitar Hero X-plorer' | ~~~~~ 63 | // following are joystick button number 64 | JBP2FIRE = 0 C:/Projects/vlang/sdl2_examples/tvintris/tvintris.v:64:2: warning: const names cannot contain uppercase letters, use snake_case instead 62 | JOYP2NAME = 'RedOctane Guitar Hero X-plorer' 63 | // following are joystick button number 64 | JBP2FIRE = 0 | ~~~~ 65 | // following are joystick hat value 66 | JHP2UP = 4 C:/Projects/vlang/sdl2_examples/tvintris/tvintris.v:66:2: warning: const names cannot contain uppercase letters, use snake_case instead 64 | JBP2FIRE = 0 65 | // following are joystick hat value 66 | JHP2UP = 4 | ~~ 67 | JHP2DOWN = 1 68 | JHP2LEFT = 8 C:/Projects/vlang/sdl2_examples/tvintris/tvintris.v:67:2: warning: const names cannot contain uppercase letters, use snake_case instead 65 | // following are joystick hat value 66 | JHP2UP = 4 67 | JHP2DOWN = 1 | ~~~~ 68 | JHP2LEFT = 8 69 | JHP2RIGHT = 2 C:/Projects/vlang/sdl2_examples/tvintris/tvintris.v:68:2: warning: const names cannot contain uppercase letters, use snake_case instead 66 | JHP2UP = 4 67 | JHP2DOWN = 1 68 | JHP2LEFT = 8 | ~~~~ 69 | JHP2RIGHT = 2 70 | ) C:/Projects/vlang/sdl2_examples/tvintris/tvintris.v:69:2: warning: const names cannot contain uppercase letters, use snake_case instead 67 | JHP2DOWN = 1 68 | JHP2LEFT = 8 69 | JHP2RIGHT = 2 | ~~~~~ 70 | ) 71 | C:/Projects/vlang/sdl2_examples/tvintris/tvintris.v:110:2: warning: const names cannot contain uppercase letters, use snake_case instead 108 | ] 109 | // Each tetro has its unique color 110 | Colors = [ | ~~ 111 | vsdl2.Color{byte(0), byte(0), byte(0), byte(0)}, // unused ? 112 | vsdl2.Color{byte(0), byte(0x62), byte(0xc0), byte(0)}, // quad : darkblue 0062c0 C:/Projects/vlang/sdl2_examples/tvintris/tvintris.v:122:2: warning: const names cannot contain uppercase letters, use snake_case instead 120 | ] 121 | // Background color 122 | BackgroundColor = vsdl2.Color{byte(0), byte(0), byte(0), byte(0)} | ~~~ 123 | // BackgroundColor = vsdl2.Color{byte(255), byte(255), byte(255), byte(0)} 124 | // Foreground color C:/Projects/vlang/sdl2_examples/tvintris/tvintris.v:125:2: warning: const names cannot contain uppercase letters, use snake_case instead 123 | // BackgroundColor = vsdl2.Color{byte(255), byte(255), byte(255), byte(0)} 124 | // Foreground color 125 | ForegroundColor = vsdl2.Color{byte(0), byte(170), byte(170), byte(0)} | ~~~ 126 | // ForegroundColor = vsdl2.Color{byte(0), byte(0), byte(0), byte(0)} 127 | // Text color C:/Projects/vlang/sdl2_examples/tvintris/tvintris.v:128:2: warning: const names cannot contain uppercase letters, use snake_case instead 126 | // ForegroundColor = vsdl2.Color{byte(0), byte(0), byte(0), byte(0)} 127 | // Text color 128 | TextColor = vsdl2.Color{byte(0xca), byte(0x7d), byte(0x5f), byte(0)} | ~~~~~ 129 | // TextColor = vsdl2.Color{byte(0), byte(0), byte(0), byte(0)} 130 | ) C:/Projects/vlang/sdl2_examples/tvintris/tvintris.v:245:4: warning: use (mut f Foo) instead of (f mut Foo) 243 | 244 | 245 | fn (sdl mut SdlContext) set_sdl_context(w int, h int, title string) { | ~~~~ 246 | C.SDL_Init(C.SDL_INIT_VIDEO | C.SDL_INIT_AUDIO | C.SDL_INIT_JOYSTICK) 247 | C.atexit(C.SDL_Quit) C:/Projects/vlang/sdl2_examples/tvintris/tvintris.v:461:4: warning: use (mut f Foo) instead of (f mut Foo) 459 | idle space fire 460 | } 461 | fn (game mut Game) handle_key(key int) { | ~~~ 462 | // global keys 463 | mut action := Action.idle C:/Projects/vlang/sdl2_examples/tvintris/tvintris.v:504:4: warning: use (mut f Foo) instead of (f mut Foo) 502 | } 503 | 504 | fn (game mut Game) handle_jbutton(jb int, joyid int) { | ~~~ 505 | if joyid != game.joy_id { 506 | return C:/Projects/vlang/sdl2_examples/tvintris/tvintris.v:526:4: warning: use (mut f Foo) instead of (f mut Foo) 524 | } 525 | 526 | fn (game mut Game) handle_jhat(jh int, jv int, joyid int) { | ~~~ 527 | if joyid != game.joy_id { 528 | return C:/Projects/vlang/sdl2_examples/tvintris/tvintris.v:542:4: warning: use (mut f Foo) instead of (f mut Foo) 540 | } 541 | 542 | fn (g mut Game) init_game() { | ~~~~ 543 | g.score = 0 544 | g.tetro_total = 0 C:/Projects/vlang/sdl2_examples/tvintris/tvintris.v:565:4: warning: use (mut f Foo) instead of (f mut Foo) 563 | } 564 | 565 | fn (g mut Game) parse_tetros() { | ~~~~ 566 | for btetros in b_tetros { 567 | for btetro in btetros { C:/Projects/vlang/sdl2_examples/tvintris/tvintris.v:575:4: warning: use (mut f Foo) instead of (f mut Foo) 573 | } 574 | 575 | fn (g mut Game) run() { | ~~~~ 576 | for { 577 | if g.state == .running { C:/Projects/vlang/sdl2_examples/tvintris/tvintris.v:598:4: warning: use (mut f Foo) instead of (f mut Foo) 596 | } 597 | 598 | fn (game mut Game) rotate_tetro() { | ~~~ 599 | // Rotate the tetro 600 | old_rotation_idx := game.rotation_idx C:/Projects/vlang/sdl2_examples/tvintris/tvintris.v:615:4: warning: use (mut f Foo) instead of (f mut Foo) 613 | } 614 | 615 | fn (g mut Game) move_tetro() { | ~~~~ 616 | // Check each block in current tetro 617 | for block in g.tetro { C:/Projects/vlang/sdl2_examples/tvintris/tvintris.v:641:4: warning: use (mut f Foo) instead of (f mut Foo) 639 | } 640 | 641 | fn (g mut Game) move_right(dx int) bool { | ~~~~ 642 | // Reached left/right edge or another tetro? 643 | for i := 0; i < TetroSize; i++ { C:/Projects/vlang/sdl2_examples/tvintris/tvintris.v:684:4: warning: use (mut f Foo) instead of (f mut Foo) 682 | 683 | // Draw a rand tetro index 684 | fn (g mut Game) rand_tetro() int { | ~~~~ 685 | cur := g.tetro_next 686 | g.tetro_next = rand_r(&g.seed) C:/Projects/vlang/sdl2_examples/tvintris/tvintris.v:692:4: warning: use (mut f Foo) instead of (f mut Foo) 690 | 691 | // Place a new tetro on top 692 | fn (g mut Game) generate_tetro() { | ~~~~ 693 | g.pos_y = 0 694 | g.pos_x = FieldWidth / 2 - TetroSize / 2 C:/Projects/vlang/sdl2_examples/tvintris/tvintris.v:704:4: warning: use (mut f Foo) instead of (f mut Foo) 702 | 703 | // Get the right tetro from cache 704 | fn (g mut Game) get_tetro() { | ~~~~ 705 | idx := g.tetro_idx TetroSize TetroSize + g.rotation_idx TetroSize 706 | g.tetro = g.tetros_cache[idx .. idx + TetroSize] C:/Projects/vlang/sdl2_examples/tvintris/tvintris.v:728:26: warning: fn f(x, y Type) syntax has been deprecated and will soon be removed. Use fn f(x Type, y Type) instead. You can run v fmt -w "C:/Projects/vlang/sdl2_examples/tvintris/tvintris.v" to automatically fix your code. 726 | } 727 | 728 | fn (g &Game) draw_block(i, j, color_idx int) { | ^ 729 | rect := vsdl2.Rect {g.ofs_x + (j - 1) BlockSize, (i - 1) BlockSize, 730 | BlockSize - 1, BlockSize - 1} C:/Projects/vlang/sdl2_examples/tvintris/tvintris.v:728:29: warning: fn f(x, y Type) syntax has been deprecated and will soon be removed. Use fn f(x Type, y Type) instead. You can run v fmt -w "C:/Projects/vlang/sdl2_examples/tvintris/tvintris.v" to automatically fix your code. 726 | } 727 | 728 | fn (g &Game) draw_block(i, j, color_idx int) { | ^ 729 | rect := vsdl2.Rect {g.ofs_x + (j - 1) BlockSize, (i - 1) BlockSize, 730 | BlockSize - 1, BlockSize - 1} C:/Projects/vlang/sdl2_examples/tvintris/tvintris.v:10:8: warning: module 'rand' is imported but never used 8 | module main 9 | 10 | import rand | ~~~~ 11 | import time 12 | import os C:/Projects/vlang/sdl2_examples/tvintris/tvintris.v:276:9: warning: function tos_clone must be called from an unsafe block 274 | for i := 0; i < njoy; i++ { 275 | C.SDL_JoystickOpen(i) 276 | jn := tos_clone(vsdl2.joystick_name_for_index(i)) | ~~~~~~~~~~~ 277 | println('JOY NAME $jn') 278 | for j := 0; j < NJOYMAX; j++ { C:/Projects/vlang/sdl2_examples/tvintris/tvintris.v:393:18: warning: reading a union field (or its address) requires unsafe 391 | ev := vsdl2.Event{} 392 | for 0 < vsdl2.poll_event(&ev) { 393 | match int(ev.@type) { | ~~~~ 394 | C.SDL_QUIT { should_close = true } 395 | C.SDL_KEYDOWN { C:/Projects/vlang/sdl2_examples/tvintris/tvintris.v:396:16: warning: reading a union field (or its address) requires unsafe 394 | C.SDL_QUIT { should_close = true } 395 | C.SDL_KEYDOWN { 396 | key := ev.key.keysym.sym | ~~~ 397 | if key == C.SDLK_ESCAPE { 398 | should_close = true C:/Projects/vlang/sdl2_examples/tvintris/tvintris.v:405:19: warning: reading a union field (or its address) requires unsafe 403 | } 404 | C.SDL_JOYBUTTONDOWN { 405 | jb := int(ev.jbutton.button) | ~~~ 406 | joyid := ev.jbutton.which 407 | // println('JOY BUTTON $jb $joyid') C:/Projects/vlang/sdl2_examples/tvintris/tvintris.v:406:18: warning: reading a union field (or its address) requires unsafe 404 | C.SDL_JOYBUTTONDOWN { 405 | jb := int(ev.jbutton.button) 406 | joyid := ev.jbutton.which | ~~~ 407 | // println('JOY BUTTON $jb $joyid') 408 | game.handle_jbutton(jb, joyid) C:/Projects/vlang/sdl2_examples/tvintris/tvintris.v:412:19: warning: reading a union field (or its address) requires unsafe 410 | } 411 | C.SDL_JOYHATMOTION { 412 | jh := int(ev.jhat.hat) | ~~~~ 413 | jv := int(ev.jhat.value) 414 | joyid := ev.jhat.which C:/Projects/vlang/sdl2_examples/tvintris/tvintris.v:413:19: warning: reading a union field (or its address) requires unsafe 411 | C.SDL_JOYHATMOTION { 412 | jh := int(ev.jhat.hat) 413 | jv := int(ev.jhat.value) | ~~~~ 414 | joyid := ev.jhat.which 415 | // println('JOY HAT $jh $jv $joyid') C:/Projects/vlang/sdl2_examples/tvintris/tvintris.v:414:18: warning: reading a union field (or its address) requires unsafe 412 | jh := int(ev.jhat.hat) 413 | jv := int(ev.jhat.value) 414 | joyid := ev.jhat.which | ~~~~ 415 | // println('JOY HAT $jh $jv $joyid') 416 | game.handle_jhat(jh, jv, joyid) C:/Projects/vlang/sdl2_examples/tvintris/tvintris.v:594:8: warning: function time.sleep_ms has been deprecated; call time.sleep(n time.millisecond) 592 | } 593 | } 594 | time.sleep_ms(TimerPeriod) // medium delay between game step | ~~~~~ 595 | } 596 | } C:/Projects/vlang/sdl2_examples/tvintris/tvintris.v:356:6: warning: unused variable: total_frame_ticks 354 | mut g := Game{ font: 0 } 355 | mut should_close := false 356 | mut total_frame_ticks := u64(0) | ~~~~~ 357 | mut total_frames := u32(0) 358 | C:/Projects/vlang/sdl2_examples/tvintris/tvintris.v:260:11: error: cannot use int as fn () in argument 1 to C.atexit 258 | 259 | C.Mix_Init(0) 260 | C.atexit(C.Mix_Quit) | ~~ 261 | if C.Mix_OpenAudio(48000,C.MIX_DEFAULT_FORMAT,2,AudioBufSize) < 0 { 262 | println('couldn\'t open audio')

Buld successful only from C:\msys64\msys2_shell.cmd -mingw64 C:\msys64\msys2_shell.cmd -mingw32 and C:\msys64\msys2_shell.cmd -msys give same error INFO: compile with v -live c:/Projects/vlang/sdl2_examples/main_v.v, if you want to use the [live] function main.livemain . builder error: 'strings.h' not found

strings.h exists inside folder ...mingw64\x86_64-w64-mingw32\include run pacman -S git mingw-w64-x86_64-toolchain... do nothing

nsauzede commented 3 years ago

Now that is strange. I just checked on Windows, and it works for me (ie: no error) Can you please do the following and report output:

/c/Users/nsauzede/.vmodules/nsauzede/vsdl2$ v doctor
OS: windows, Microsoft Windows 10 Enterprise v18363 64-bit
Processor: 8 cpus, 64bit, little endian, Intel(R) Core(TM) i7-6820HQ CPU @ 2.70GHz
CC version: cc (Rev2, Built by MSYS2 project) 10.3.0

getwd: C:\Users\nsauzede\.vmodules\nsauzede\vsdl2
vmodules: C:\Users\nsauzede\.vmodules
vroot: C:\nico\perso\git\v
vexe: C:\nico\perso\git\v\v.exe
vexe mtime: 2021-05-19 20:34:11
is vroot writable: true
is vmodules writable: true
V full version: V 0.2.2 9ddf1ec

Git version: git version 2.31.1
Git vroot status: weekly.2021.20-12-g9ddf1ec3
.git/config present: true
thirdparty/tcc status: thirdparty-windows-amd64 40cb2ddb
nsauzede commented 3 years ago

Oh BTW, -mingw32 and -msys are NOT supported

boris-741 commented 3 years ago

done: $ c:/vlang/v.exe doctor OS: windows, Microsoft Windows 10 Enterprise v19041 64-bit Processor: 4 cpus, 64bit, little endian, Intel(R) Core(TM) i5-2320 CPU @ 3.00GHz CC version: cc (Rev2, Built by MSYS2 project) 10.3.0

getwd: C:\Users\User1.vmodules\nsauzede\vsdl2 vmodules: C:\Users\User1.vmodules vroot: C:\vlang vexe: C:\vlang\v.exe vexe mtime: 2021-05-18 18:48:58 is vroot writable: true is vmodules writable: true V full version: V 0.2.2 19b4504.94e7a55

Git version: git version 2.31.1 Git vroot status: weekly.2021.19-59-g94e7a55b-dirty .git/config present: true thirdparty/tcc status: thirdparty-windows-amd64 40cb2ddb-dirty

I added logs and found a break on the line

tsurf := C.TTF_RenderText_Solid(font, 'Hello SDL_ttf V !', tcol)

output from gdb Thread 1 received signal SIGSEGV, Segmentation fault. 0x000000007100210a in ?? () from C:\msys64\mingw64\bin\SDL2_ttf.dll (gdb)

code:

font := C.TTF_OpenFont('fonts/RobotoMono-Regular.ttf', 16)
if font == voidptr(0)
{
    println('font load error $os.getwd()')
}

return "font load error C:\msys64\home\User1" but file exists inside child directory - tvintris\fonts full path C:\Projects\vlang\sdl2_examples\tvintris\fonts\RobotoMono-Regular.ttf

with full path code run successfully font := C.TTF_OpenFont('C:/Projects/vlang/sdl2_examples/tvintris/fonts/RobotoMono-Regular.ttf', 16)

boris-741 commented 3 years ago
  1. fix problem builder error: 'strings.h' not found pacman -Syu pacman -S git mingw-w64-x86_64-toolchain mingw64/mingw-w64-x86_64-SDL2 mingw64/mingw-w64-x86_64-SDL2_mixer mingw64/mingw-w64-x86_64-SDL2_image mingw64/mingw-w64-x86_64-SDL2_ttf mingw64/mingw-w64-x86_64-SDL2_net mingw64/mingw-w64-x86_64-cmake make

  2. fix problem with run builded run cd c:/Projects/vlang/sdl2_examples/ before C:/vlang/v.exe -cc gcc run "c:/Projects/vlang/sdl2_examples/main_v.v" and change local path from 'fonts/RobotoMono-Regular.ttf' to 'tvintris/fonts/RobotoMono-Regular.ttf' and for sound same path fix the problem with run builded example

nsauzede commented 3 years ago

1/ Oof -- are these the packages recommended to build tVintris ? 2/ Ok I see -- the correct fix would be to automatically find the font, like is done wit tVintris

nsauzede commented 3 years ago

Wait BTW, the title of this issue is referring to tVintris

Do you have issues with tVintris @boris-741 ? or only with the dummy (broken) main_v.v example ? If the former, let's close that issue as invalid

boris-741 commented 3 years ago

problems with example