Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

ARCJ137442
Copy link
Contributor

@ARCJ137442 ARCJ137442 commented Sep 29, 2024

Feature

Translated shell script build.cmd for Windows

  • Aiming to build NAR.exe
  • Changed variable NoWarn to fit the platform environments
    • +-Wno-implicit-function-declaration -Wno-pointer-to-int-cast -Wno-int-to-pointer-cast
    • --Wno-dollar-in-identifier-extension

Environment of testing

  • Windows version: Windows 11
  • GCC version: gcc (x86_64-posix-seh) 12.2.0
  • GCC source: MinGW
  • Terminal: CMD, PowerShell
  • Compilation target: .\NAR.exe

Previews

Compilation on Terminal

CMD & PowerShell:

CMD&PowerShell

Runtime

ONA Running

Translate shell script `build.sh` into Windows, aiming to build `NAR.exe` and changing variable `NoWarn` to fit the platform environments
- +`-Wno-implicit-function-declaration -Wno-pointer-to-int-cast -Wno-int-to-pointer-cast`
- -`-Wno-dollar-in-identifier-extension`
Environment of testing:
- Windows version: Windows 11
- GCC version: gcc (x86_64-posix-seh) 12.2.0
- GCC source: MinGW
- Terminal: CMD, PowerShell
- Compilation target
@ARCJ137442 ARCJ137442 changed the title [compilation] New script build.cmd for compilation on Windows [build] New script build.cmd for compilation on Windows Sep 29, 2024
@patham9
Copy link
Member

patham9 commented Oct 2, 2024

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
Copy link
Member

patham9 commented Oct 2, 2024

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
Copy link
Contributor Author

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
Copy link
Contributor Author

ARCJ137442 commented Oct 3, 2024

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
Copy link
Member

patham9 commented Oct 3, 2024

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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants