odin-lang / Odin

Odin Programming Language
https://odin-lang.org
BSD 3-Clause "New" or "Revised" License
7.05k stars 630 forks source link

Error while building on Windows 11 ("misc\odin.rc(41) : error RC2104 : undefined keyword or key name: All") #4540

Closed LaurentOngaro closed 9 hours ago

LaurentOngaro commented 4 days ago

My System: Windows 11x64

I've downloaded the master version (and also the dev-2024-11 version) and I can't build Odin because the following error occurs:

misc\odin.rc(41) : error RC2104 : undefined keyword or key name: All
main.cpp
libtommath.cpp
LINK : fatal error LNK1181: cannot open input file 'misc\odin.res'

mt : general error c101008c: Failed to read the manifest from the resource of file "\\?\R:\Sources\Odin\Odin\odin.exe".

I've made some tests, to find the cause of the issue and I found that the build.bat file of the dev-2024-10 works well and if I replace the master version by this one, I can build Odin.

The changes in the file are very small. The line that causes the error in the build is :

In the master version (build is HS):

for /f %%i in ('powershell get-date -format "{yyyyMMdd}"') do (
    set CURR_DATE_TIME=%%i
)

In the dev-2024-10 version (build is OK):

for /f "usebackq tokens=1,2 delims=,=- " %%i in (`wmic os get LocalDateTime /value`) do @if %%i==LocalDateTime (
    set CURR_DATE_TIME=%%j
)

(note that this line of script is buggy, because the loop uses %%i and the CURR_DATE_TIME uses %%j,I've tested to put %%i instead of %%j and nothing changes

To debug the code deeper, I've added the line:

echo %odin_version_full%

after the line:

set odin_version_full="%V1%.%V2%.%V3%.%V4%"

in both files (master and dev-2024-10) and these are the results:

with the dev-2024-10 version -> "2024.11.0.0" is printed with the master version -> "Loca.lD.0.0" is printed

I ran the command from cmd.exe.

powershell get-date -format "{yyyyMMdd}" 

I've got the error message:

The argument 'get-date' is not recognized as the name of a script file. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
same error in a powershell terminal or in a command prompt console (cmd.exe)
gingerBill commented 1 day ago

I cannot replicate this on my Windows 11 machine. But I wonder if anyone else can.

LaurentOngaro commented 1 day ago

I've tested once again today with the current master version, the bug is still present for me.

Please note I've updated powershell to its last version available a 2 or 3 months ago, perhaps the 'get-date' command is still present in older versions. I'm using PowerShell 7.4.6

laytan commented 1 day ago

I have this error when building on my windows machine, looks slightly different from yours though:

> build.bat
libtommath.cpp
main.cpp
LINK : fatal error LNK1104: cannot open file 'odin.exe'

mt : manifest authoring error c1010001: Values of attribute "version" not equal in different manifest snippets.
The system cannot find the batch label specified - end_of_build
LaurentOngaro commented 1 day ago

build.bat libtommath.cpp main.cpp LINK : fatal error LNK1104: cannot open file 'odin.exe'

mt : manifest authoring error c1010001: Values of attribute "version" not equal in different manifest snippets. The system cannot find the batch label specified - end_of_build

Perhaps could you test

powershell get-date -format "{yyyyMMdd}" 

in your powershell prompt to see if the command still exists for you ?

flysand7 commented 1 day ago

Uhm....

powershell get-date -format "{yyyyMMdd}"

I'm using PowerShell 7.4.6

Actually, you're not using powershell 7.4.6. In this case you're using the Inferior version of the powershell known as the Windows Powershell (the one with blue background). Powershell Core is called via pwsh.exe

LaurentOngaro commented 15 hours ago

I understand your point, but even though I usually start my terminal using pwsh.exe, this is the result of the commands I run.

image

As you can see, I run both commands using powershell and not pwsh, and get date throws an error.

The error is also present if I launch a terminal using powershell.exe

image

Please note that this error is not a blocking bug for me because I can compile using an old version of the build.bat file.

But the fact that the get-date argument is missing is very strange and of course it is not really related to Odin.

Kelimion commented 9 hours ago

Added a little C program to print the current date as YYYYMMDD, which allows us not to rely on cmd.exe or any version of PowerShell. Let us know if this fixes your issue.

LaurentOngaro commented 8 hours ago

Issue solved ! Thanks to Kelimion