opennars / OpenNARS-for-Applications

General reasoning component for applications based on NARS theory.
https://cis.temple.edu/~pwang/NARS-Intro.html
MIT License
91 stars 40 forks source link

[build] New script `build.cmd` for compilation on Windows #285

Open ARCJ137442 opened 1 month ago

ARCJ137442 commented 1 month ago

Feature

Translated shell script build.cmd for Windows

Environment of testing

Previews

Compilation on Terminal

CMD & PowerShell:

CMD&PowerShell

Runtime

ONA Running

patham9 commented 1 month ago

Thank you! This PR is a good fit for the Portability branch: https://github.com/opennars/OpenNARS-for-Applications/tree/portability This branch is better suitable as it does not depend on POSIX and Windows support for POSIX is fluctuating / non-stable. Does evaluation.py lead to the correct / same results as on a Linux or UNIX OS?

patham9 commented 1 month ago

It is good that it does not need Cygwin but only MinGW now. Maybe it can be called build_mingw.cmd and be added to the portability branch?

ARCJ137442 commented 1 month ago

It is good that it does not need Cygwin but only MinGW now. Maybe it can be called build_mingw.cmd and be added to the portability branch?

I agree.

This script was originally written by me to test ONA in Windows 11 with MinGW, and The PR submission left out a prerequisite: to remove NetworkNAR / UDPNAR references (presumably because there is no socket.h in Windows) in order for GCC to compile successfully on Windows.

In this case, the script may still be incomplete, so instead of putting it in the master branch, it might be better to put it in portability branch first (because it's needed to modify the source code to work)

Does evaluation.py lead to the correct / same results as on a Linux or UNIX OS?

This .cmd script is primarily for Windows and I have not tested it on other Linux/UNIX systems yet. However, I tried to run the script misc\Python\NAR.py, and when the executable file (.exe) path in def spawnNAR() is correct, it will run and interact normally.

ARCJ137442 commented 1 month ago

This script was originally written by me to test ONA in Windows 11 with MinGW, and The PR submission left out a prerequisite: to remove NetworkNAR / UDPNAR references (presumably because there is no socket.h in Windows) in order for GCC to compile successfully on Windows.

For example, if you compile directly with build.cmd in the master branch, the following results might happen:

In file included from [...]\src\NetworkNAR\UDPNAR.h:35,      
                 from [...]\src\NetworkNAR\UDPNAR.c:25:      
[...]\src\NetworkNAR\UDP.h:38:10: fatal error: sys/socket.h: No such file or directory
   38 | #include <sys/socket.h>
      |          ^~~~~~~~~~~~~~
compilation terminated.
patham9 commented 1 month ago

I agree. Portability branch has no NetworkNAR, so this issue would resolve itself there and could simplify the compilation script potentially (to remove any POSIX reference at least)