janet-lang / jpm

Janet Project Manager
MIT License
68 stars 22 forks source link

windows: jaylib builds with old jpm (1.15.4), but not newest #12

Closed saikyun closed 2 years ago

saikyun commented 3 years ago

When building jaylib on newest jpm (using jpm build) on Windows, I get errors like this:

utils.c
C:\Program Files (x86)\Windows Kits\10\include\10.0.15063.0\um\winuser.h(9074): warning C4028: formal parameter 1 different from declarationC:\Program Files (x86)\Windows Kits\10\include\10.0.15063.0\um\wingdi.h(4497): error C2365: 'Rectangle': redefinition; previous definition was 'typedef'

C:\Program Files (x86)\Windows Kits\10\include\10.0.15063.0\um\winuser.h(9073): error C2371: 'ShowCursor': redefinition; different basic typesraylib/src\raylib.h(221): note: see declaration of 'Rectangle'

raylib/src\raylib.h(945): note: see declaration of 'ShowCursor'
C:\Program Files (x86)\Windows Kits\10\include\10.0.15063.0\um\winuser.h(4591): warning C4028: formal parameter 1 different from declaration
C:\Program Files (x86)\Windows Kits\10\include\10.0.15063.0\um\winuser.h(4590): error C2371: 'CloseWindow': redefinition; different basic types
raylib/src\raylib.h(906): note: see declaration of 'CloseWindow'
C:\Program Files (x86)\Windows Kits\10\include\10.0.15063.0\um\winuser.h(9074): warning C4028: formal parameter 1 different from declaration
C:\Program Files (x86)\Windows Kits\10\include\10.0.15063.0\um\winuser.h(9073): error C2371: 'ShowCursor': redefinition; different basic types
raylib/src\raylib.h(945): note: see declaration of 'ShowCursor'C:\Users\Psycheyun\programmering\jaylib\src\core.h(19): error C2198: 'CloseWindow': too few arguments for call
C:\Users\Psycheyun\programmering\jaylib\src\core.h(245): error C2198: 'ShowCursor': too few arguments for call
C:\Users\Psycheyun\programmering\jaylib\src\audio.h(97): error C2440: 'function': cannot convert from 'Sound' to 'LPCSTR'
C:\Users\Psycheyun\programmering\jaylib\src\audio.h(97): warning C4024: 'PlaySoundA': different types for formal and actual parameter 1
C:\Users\Psycheyun\programmering\jaylib\src\audio.h(97): error C2198: 'PlaySoundA': too few arguments for call
C:\Users\Psycheyun\programmering\jaylib\src\text.h(71): warning C4090: 'function': different 'const' qualifiers
C:\Users\Psycheyun\programmering\jaylib\src\text.h(71): warning C4047: 'function': 'LPCSTR' differs in levels of indirection from 'int'
C:\Users\Psycheyun\programmering\jaylib\src\text.h(71): warning C4024: 'DrawTextA': different types for formal and actual parameter 2
C:\Users\Psycheyun\programmering\jaylib\src\text.h(71): warning C4047: 'function': 'LPRECT' differs in levels of indirection from 'int'
C:\Users\Psycheyun\programmering\jaylib\src\text.h(71): warning C4024: 'DrawTextA': different types for formal and actual parameter 4
C:\Users\Psycheyun\programmering\jaylib\src\text.h(71): error C2440: 'function': cannot convert from 'Color' to 'UINT'
C:\Users\Psycheyun\programmering\jaylib\src\text.h(71): warning C4024: 'DrawTextA': different types for formal and actual parameter 5
C:\Users\Psycheyun\programmering\jaylib\src\text.h(83): error C2440: 'function': cannot convert from 'Font' to 'HDC'
C:\Users\Psycheyun\programmering\jaylib\src\text.h(83): warning C4024: 'DrawTextExA': different types for formal and actual parameter 1
C:\Users\Psycheyun\programmering\jaylib\src\text.h(83): warning C4090: 'function': different 'const' qualifiers
C:\Users\Psycheyun\programmering\jaylib\src\text.h(83): error C2440: 'function': cannot convert from 'Vector2' to 'int'
C:\Users\Psycheyun\programmering\jaylib\src\text.h(83): warning C4024: 'DrawTextExA': different types for formal and actual parameter 3
C:\Users\Psycheyun\programmering\jaylib\src\text.h(83): error C2440: 'function': cannot convert from 'float' to 'LPRECT'
C:\Users\Psycheyun\programmering\jaylib\src\text.h(83): warning C4024: 'DrawTextExA': different types for formal and actual parameter 4
C:\Users\Psycheyun\programmering\jaylib\src\text.h(83): error C2440: 'function': cannot convert from 'Color' to 'LPDRAWTEXTPARAMS'
C:\Users\Psycheyun\programmering\jaylib\src\text.h(83): warning C4024: 'DrawTextExA': different types for formal and actual parameter 6
C:\Users\Psycheyun\programmering\jaylib\src\image.h(5): warning C4090: 'function': different 'const' qualifiers
C:\Users\Psycheyun\programmering\jaylib\src\image.h(5): error C2198: 'LoadImageA': too few arguments for call
C:\Users\Psycheyun\programmering\jaylib\src\image.h(5): error C2440: '=': cannot convert from 'HANDLE' to 'Image'

error: command failed with non-zero exit code 2
  in os/execute [src/core/os.c] on line 1049
  in shellC:\Users\Psycheyun\programmering\jaylib\src\core.h(19): error C2198: 'CloseWindow': too few arguments for call [C:/Users/Psycheyun/AppData/Local/Apps/Janet/Library/jpm/shutil.janet]
 (tailcall)C:\Users\Psycheyun\programmering\jaylib\src\core.h(245): error C2198: 'ShowCursor': too few arguments for call on line 110, column 5

C:\Users\Psycheyun\programmering\jaylib\src\audio.h(97): error C2440: 'function': cannot convert from 'Sound' to 'LPCSTR'  in
 <anonymous>C:\Users\Psycheyun\programmering\jaylib\src\audio.h(97): warning C4024: 'PlaySoundA': different types for formal and actual parameter 1 [C:/Users/Psycheyun/AppData/Local/Apps/Janet/Library/jpm/rules.janet]
 on line 18, column 20C:\Users\Psycheyun\programmering\jaylib\src\audio.h(97): error C2198: 'PlaySoundA': too few arguments for call

  inC:\Users\Psycheyun\programmering\jaylib\src\text.h(71): warning C4090: 'function': different 'const' qualifiers executor
 [C:/Users/Psycheyun/AppData/Local/Apps/Janet/Library/jpm/rules.janet]C:\Users\Psycheyun\programmering\jaylib\src\text.h(71): warning C4047: 'function': 'LPCSTR' differs in levels of indirection from 'int' on line 25, column 8

C:\Users\Psycheyun\programmering\jaylib\src\text.h(71): warning C4024: 'DrawTextA': different types for formal and actual parameter 2  in
 workerC:\Users\Psycheyun\programmering\jaylib\src\text.h(71): warning C4047: 'function': 'LPRECT' differs in levels of indirection from 'int' [C:/Users/Psycheyun/AppData/Local/Apps/Janet/Library/jpm/dagbuild.janet]
 on line 65, column 23C:\Users\Psycheyun\programmering\jaylib\src\text.h(71): warning C4024: 'DrawTextA': different types for formal and actual parameter 4

  inC:\Users\Psycheyun\programmering\jaylib\src\text.h(71): error C2440: 'function': cannot convert from 'Color' to 'UINT' <anonymous>
 [C:/Users/Psycheyun/AppData/Local/Apps/Janet/Library/jpm/dagbuild.janet]C:\Users\Psycheyun\programmering\jaylib\src\text.h(71): warning C4024: 'DrawTextA': different types for formal and actual parameter 5 on line 21, column 43

C:\Users\Psycheyun\programmering\jaylib\src\text.h(83): error C2440: 'function': cannot convert from 'Font' to 'HDC'  in
 pmapC:\Users\Psycheyun\programmering\jaylib\src\text.h(83): warning C4024: 'DrawTextExA': different types for formal and actual parameter 1 [C:/Users/Psycheyun/AppData/Local/Apps/Janet/Library/jpm/dagbuild.janet]
 on line 26, column 7C:\Users\Psycheyun\programmering\jaylib\src\text.h(83): warning C4090: 'function': different 'const' qualifiers

  inC:\Users\Psycheyun\programmering\jaylib\src\text.h(83): error C2440: 'function': cannot convert from 'Vector2' to 'int' pdag
 [C:/Users/Psycheyun/AppData/Local/Apps/Janet/Library/jpm/dagbuild.janet]C:\Users\Psycheyun\programmering\jaylib\src\text.h(83): warning C4024: 'DrawTextExA': different types for formal and actual parameter 3 (tailcall)
 on line 71, column 3C:\Users\Psycheyun\programmering\jaylib\src\text.h(83): error C2440: 'function': cannot convert from 'float' to 'LPRECT'

  inC:\Users\Psycheyun\programmering\jaylib\src\text.h(83): warning C4024: 'DrawTextExA': different types for formal and actual parameter 4 _thunk
 [C:\Users\Psycheyun\AppData\Local\Apps\Janet\bin\/jpm]C:\Users\Psycheyun\programmering\jaylib\src\text.h(83): error C2440: 'function': cannot convert from 'Color' to 'LPDRAWTEXTPARAMS' on line -1, column -1

C:\Users\Psycheyun\programmering\jaylib\src\text.h(83): warning C4024: 'DrawTextExA': different types for formal and actual parameter 6  in
 cli-mainC:\Users\Psycheyun\programmering\jaylib\src\image.h(5): warning C4090: 'function': different 'const' qualifiers [boot.janet]
 on line 3618, column 39C:\Users\Psycheyun\programmering\jaylib\src\image.h(5): error C2198: 'LoadImageA': too few arguments for call

C:\Users\Psycheyun\programmering\jaylib\src\image.h(5): error C2440: '=': cannot convert from 'HANDLE' to 'Image'
sogaiu commented 3 years ago

I got similar output for jpm 1cd77f9: jpm-build-output.txt

bakpakin commented 2 years ago

I'm on windows, and I was able to build. Not sure this a jpm issue? Perhaps try with the latest jpm, but I wouldn't expect that to help

sogaiu commented 2 years ago

@bakpakin Thanks for taking a look and the pointer.

I tried building and using various versions of Janet and found that there appears to be a commit beyond which jaylib won't build here.

The following is a list of commits that seem relevant starting with the most recent and going back in time:

The first one https://github.com/janet-lang/janet/commit/d631d29cb4f79d37f594e7f4e482c49549bc1627 is the first commit I was able to confirm jaylib not building for.

The next two https://github.com/janet-lang/janet/commit/01b7891347f752322b82fa724fe03dde7384bdcf and https://github.com/janet-lang/janet/commit/c786a4cbeb8b4384111bde2fbe6113a7b2e06998 were commits where Janet itself didn't build on Windows.

The last one https://github.com/janet-lang/janet/commit/1920ecd668fab77003a7e454fc44fc94d3cdd0f5 is the last commit I confirmed for which jaylib still builds on Windows.

(FWIW, I tried with both the old Janet-bundled jpm and the most recent jpm from the independent repository and the results were the same. So jpm does not appear to be causing issues.)

webview appears to be affected similarly, i.e. it builds with https://github.com/janet-lang/janet/commit/1920ecd668fab77003a7e454fc44fc94d3cdd0f5 but not with https://github.com/janet-lang/janet/commit/d631d29cb4f79d37f594e7f4e482c49549bc1627 .

bakpakin commented 2 years ago

I would guess that it had to with janet.h now including windows.h. windows is a bit picky about the order of includes, so this can break some code. Instead, we should be able to do a forward define of CRITICAL_SECTION. (The change is to allow use of JanetOSMutex from libraries, which is useful for writing thread aware libraries).

sogaiu commented 2 years ago

Thanks for taking a look.

I found this SO answer and some code at WindowsHModular.

So may be part of what's necessary is replacing the #include <windows.h> in janet.h with:

typedef struct _RTL_CRITICAL_SECTION RTL_CRITICAL_SECTION;
typedef RTL_CRITICAL_SECTION CRITICAL_SECTION;
sogaiu commented 2 years ago

Since this commit in Janet, jaylib builds for me in Windows.

TYVM!

May be @saikyun can close this issue.

saikyun commented 2 years ago

Builds for me too, thank you so much!!