From 94b0a95d042d5fcb604e01c53747aec3be641e7a Mon Sep 17 00:00:00 2001 From: jpdavis6 Date: Wed, 23 Oct 2024 14:00:52 -0400 Subject: [PATCH 1/8] Added logic statements in the Makefile to not compile 42Nos3.c or the NOS3Time function when on Windows. Added 42.exe to the .gitignore list for when compiled on windows. --- .gitignore | 1 + Makefile | 24 ++++++++++++++++-------- Source/42exec.c | 5 +++++ 3 files changed, 22 insertions(+), 8 deletions(-) diff --git a/.gitignore b/.gitignore index 0be7f8a6..f13c6e9e 100644 --- a/.gitignore +++ b/.gitignore @@ -6,4 +6,5 @@ a.out *.webarchive *.42 42 +42.exe diff --git a/Makefile b/Makefile index 227bae57..f43aa2ec 100755 --- a/Makefile +++ b/Makefile @@ -145,20 +145,19 @@ endif ifeq ($(42PLATFORM),__MSYS__) CINC = - EXTERNDIR = /c/42ExternalSupport/ + # For graphics interface, choose GLUT or GLFW GUI libraries # GLUT is well known, but GLFW is better for newer Mac's hires displays #GLUT_OR_GLFW = _USE_GLFW_ GLUT_OR_GLFW = _USE_GLUT_ ifneq ($(strip $(GUIFLAG)),) - # TODO: Option to use GLFW instead of GLUT? - GLEW = $(EXTERNDIR)GLEW/ - GLUT = $(EXTERNDIR)freeglut/ + # Updated paths for pacman-installed GLEW and GLUT LIBS = -lopengl32 -lglu32 -lfreeglut -lws2_32 -lglew32 - LFLAGS = -L $(GLUT)lib/ -L $(GLEW)lib/ + LFLAGS = GUIOBJ = $(OBJ)42gl.o $(OBJ)42glut.o $(OBJ)glkit.o $(OBJ)42gpgpu.o - GLINC = -I $(GLEW)include/GL/ -I $(GLUT)include/GL/ + # Update include paths to the MSYS2 installed GLEW and GLUT + GLINC = -I /mingw64/include/GL/ ARCHFLAG = -D GLUT_NO_LIB_PRAGMA -D GLUT_NO_WARNING_DISABLE -D GLUT_DISABLE_ATEXIT_HACK else GUIOBJ = @@ -167,6 +166,7 @@ ifeq ($(42PLATFORM),__MSYS__) LFLAGS = ARCHFLAG = endif + XWARN = EXENAME = 42.exe CC = gcc @@ -225,8 +225,16 @@ endif 42OBJ = $(OBJ)42main.o $(OBJ)42exec.o $(OBJ)42actuators.o $(OBJ)42cmd.o \ $(OBJ)42dynamics.o $(OBJ)42environs.o $(OBJ)42ephem.o $(OBJ)42fsw.o \ $(OBJ)42init.o $(OBJ)42ipc.o $(OBJ)42jitter.o $(OBJ)42joints.o \ -$(OBJ)42optics.o $(OBJ)42perturb.o $(OBJ)42report.o $(OBJ)42sensors.o \ -$(OBJ)42nos3.o +$(OBJ)42optics.o $(OBJ)42perturb.o $(OBJ)42report.o $(OBJ)42sensors.o + +# Exclude 42nos3.o for both MSYS2 and generic Windows (MinGW, etc.) since nos3 does not work and wont compile +ifeq ($(42PLATFORM),__MSYS__) + # Exclude 42nos3.o for MSYS +else ifeq ($(42PLATFORM),_WIN32) + # Exclude 42nos3.o for Windows +else + 42OBJ += $(OBJ)42nos3.o +endif KITOBJ = $(OBJ)dcmkit.o $(OBJ)envkit.o $(OBJ)fswkit.o $(OBJ)geomkit.o \ $(OBJ)iokit.o $(OBJ)mathkit.o $(OBJ)nrlmsise00kit.o $(OBJ)msis86kit.o \ diff --git a/Source/42exec.c b/Source/42exec.c index 697f6172..7af1887b 100755 --- a/Source/42exec.c +++ b/Source/42exec.c @@ -158,6 +158,7 @@ long AdvanceTime(void) break; case NOS3_TIME : + #ifndef _WIN32 NOS3Time(&UTC.Year,&UTC.doy,&UTC.Month,&UTC.Day, &UTC.Hour,&UTC.Minute,&UTC.Second); CivilTime = DateToTime(UTC.Year,UTC.Month,UTC.Day, @@ -176,6 +177,10 @@ long AdvanceTime(void) GpsTimeToGpsDate(GpsTime,&GpsRollover,&GpsWeek,&GpsSecond); SimTime = DynTime - DynTime0; + #else + printf("NOS3 time mode is not supported on Windows.\n"); + exit(1); + #endif break; } From 2ddbd8a953b101344c23c486ef29f737d6596cab Mon Sep 17 00:00:00 2001 From: jpdavis6 Date: Wed, 23 Oct 2024 14:02:59 -0400 Subject: [PATCH 2/8] Added a markdown file with instructions for running 42 with MinGW on windows and integrating it with the VS Code terminal. --- Docs/MinGW_42.md | 124 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 124 insertions(+) create mode 100644 Docs/MinGW_42.md diff --git a/Docs/MinGW_42.md b/Docs/MinGW_42.md new file mode 100644 index 00000000..69498029 --- /dev/null +++ b/Docs/MinGW_42.md @@ -0,0 +1,124 @@ +### Why MinGW Instead of WSL? +WSL (Windows Subsystem for Linux) provides a Linux environment running on Windows. While it is a powerful tool, using it introduces some complexity, as the WSL environment must interface with Windows components to access features such as networking, GPU, and window management. For example, to use the internet, WSL must interface with the Windows network adapter, and external programs like XLaunch are required to display graphical applications. Similarly, to access OpenGL features, `mesa-utils` needs to be installed and updated, and there may be issues related to VPN or network configurations. + +On the other hand, **MinGW** compiles 42 as a native Windows executable, which means that you can directly use Windows components for window management, networking, and GPU access without extra dependencies or workarounds. MinGW targets native Windows APIs, so no additional software like XLaunch is needed. + +### Steps to Get 42 Working on Windows Using MinGW: + +1. **Install MSYS2**: + - Download and install MSYS2 from the official website using the `.exe` installer. + +2. **Open an MSYS2 Prompt**: + - MSYS2 should start automatically after installation. If not, open the **MSYS2 MSYS** terminal from the Start menu. + - **Note**: There is a distinction between MSYS2 and MinGW: + - **MSYS2** is a POSIX-like environment that provides a Unix-style shell. + - **MinGW** (within MSYS2) is used for building **Windows-native executables**. + +3. **Update MSYS2**: + - You need to update MSYS2 and MinGW. Run these commands in sequence: + ```bash + pacman -Syu + pacman -Su + ``` + +4. **Open an MSYS2 MinGW Terminal**: + - Once updated, open the **MSYS2 MinGW 64-bit** terminal for compiling 64-bit Windows executables (or **MSYS2 MinGW 32-bit** for 32-bit executables, depending on your target). + +5. **Install FreeGLUT and GLEW**: + - Run the following command to install FreeGLUT and GLEW: + ```bash + pacman -S mingw-w64-x86_64-freeglut mingw-w64-x86_64-glew + ``` + - **Note**: By using **MinGW**, you target Windows binaries, not Unix-like systems. + +6. **Install the GCC Toolchain**: + - To compile 42, you'll need the MinGW GCC toolchain: + ```bash + pacman -S mingw-w64-x86_64-toolchain + ``` + +7. **Install `make`**: + - You'll also need the `make` utility to run the Makefile: + ```bash + pacman -S make + ``` + +8. **Get the 42 Repository**: + - You can clone the 42 repository using **Git**. You can either use a Git client in Windows or install Git in MSYS2: + - If using a Windows Git client: + - Clone the repository into a standard Windows directory (e.g., `C:/Users/jpdavis6/42`). + - From the MinGW terminal, you can access this directory as `/c/Users/jpdavis6/42`. + - Alternatively, you could install Git in MSYS2 and clone the repository from there, but using a Windows Git client simplifies access. + +9. **Navigate to the 42 Root Directory in the MinGW Terminal**: + - Use the MinGW terminal to navigate to the cloned repository: + ```bash + cd /c/Users/jpdavis6/42 + ``` + +10. **Compile the Repository**: + - Run the `make` command to compile the project: + ```bash + make + ``` + - This will compile 42 as a native Windows executable (`42.exe`). + +11. **Run 42**: + - After compilation, you can run the executable: + ```bash + ./42.exe + ``` + +12. **Check for Errors**: + - If there are no errors, 42 should run successfully with native Windows integration. + +### Additional Notes: +- Ensure you are always using the **MSYS2 MinGW terminal** for compiling and running 42, as this targets Windows-native executables. Do not use the **MSYS2 MSYS** terminal for compiling Windows applications. +- If the `42.exe` file is created without the `.exe` extension, you can manually rename it or run it by typing the exact name (`42.exe`). + +### Final Thoughts: +These steps should allow you to successfully compile and run the 42 simulation software on Windows using MinGW. By targeting a native Windows executable, you avoid the complexities of WSL and external dependencies like XLaunch. + + +### To open **MinGW** from **VS Code**, follow these steps to integrate it as your terminal: + +### 1. **Install MSYS2/MinGW** + Make sure you have **MSYS2** installed, which includes MinGW. If not, you can download and install it from [MSYS2.org](https://www.msys2.org/). + +### 2. **Find Your MinGW Path** + Locate the **MinGW** shell executable within the MSYS2 installation directory: + - For **64-bit MinGW**, the path is typically: + ``` + C:\msys64\mingw64.exe + ``` + - For **32-bit MinGW**, the path is: + ``` + C:\msys64\mingw32.exe + ``` + +### 3. **Configure VS Code to Use MinGW Terminal** + You can configure **VS Code** to use the **MinGW** shell as its integrated terminal. + + - Open **VS Code**. + - Go to **File** > **Preferences** > **Settings** (or press `Ctrl + ,`). + - In the search bar at the top of the Settings window, type `terminal integrated shell`. + - Under **Terminal > Integrated > Shell: Windows**, click on **Edit in settings.json** to manually edit the configuration file. + + Add the following configuration to add **MinGW** to the list of terminals: + ```json + "terminal.integrated.profiles.windows": { + "MinGW64": { + "path": "C:\\msys64\\usr\\bin\\bash.exe", + "args": ["-l"], + "env": { + "CHERE_INVOKING": "1", + "MSYSTEM": "MINGW64" + } + } + }, + ``` + +### 4. **Open VS Code Terminal** + After configuring, you can open the terminal in **VS Code** by going to **Terminal** > **New Terminal** (or pressing `Ctrl + `). + +The dropdown should contain an entry of MinGW64. That should open as an integrated terminal in VS Cdoe. You can now compile and run your projects using **gcc**, **make**, and other MinGW tools directly from VS Code. \ No newline at end of file From 6506fc93fc0fea12264d7026fcdaf732bae77ced Mon Sep 17 00:00:00 2001 From: jpdavis6 Date: Wed, 23 Oct 2024 14:05:10 -0400 Subject: [PATCH 3/8] renamed the MinGW file to be consistent --- Docs/MinGW_42.md | 124 ----------------------------------------------- 1 file changed, 124 deletions(-) delete mode 100644 Docs/MinGW_42.md diff --git a/Docs/MinGW_42.md b/Docs/MinGW_42.md deleted file mode 100644 index 69498029..00000000 --- a/Docs/MinGW_42.md +++ /dev/null @@ -1,124 +0,0 @@ -### Why MinGW Instead of WSL? -WSL (Windows Subsystem for Linux) provides a Linux environment running on Windows. While it is a powerful tool, using it introduces some complexity, as the WSL environment must interface with Windows components to access features such as networking, GPU, and window management. For example, to use the internet, WSL must interface with the Windows network adapter, and external programs like XLaunch are required to display graphical applications. Similarly, to access OpenGL features, `mesa-utils` needs to be installed and updated, and there may be issues related to VPN or network configurations. - -On the other hand, **MinGW** compiles 42 as a native Windows executable, which means that you can directly use Windows components for window management, networking, and GPU access without extra dependencies or workarounds. MinGW targets native Windows APIs, so no additional software like XLaunch is needed. - -### Steps to Get 42 Working on Windows Using MinGW: - -1. **Install MSYS2**: - - Download and install MSYS2 from the official website using the `.exe` installer. - -2. **Open an MSYS2 Prompt**: - - MSYS2 should start automatically after installation. If not, open the **MSYS2 MSYS** terminal from the Start menu. - - **Note**: There is a distinction between MSYS2 and MinGW: - - **MSYS2** is a POSIX-like environment that provides a Unix-style shell. - - **MinGW** (within MSYS2) is used for building **Windows-native executables**. - -3. **Update MSYS2**: - - You need to update MSYS2 and MinGW. Run these commands in sequence: - ```bash - pacman -Syu - pacman -Su - ``` - -4. **Open an MSYS2 MinGW Terminal**: - - Once updated, open the **MSYS2 MinGW 64-bit** terminal for compiling 64-bit Windows executables (or **MSYS2 MinGW 32-bit** for 32-bit executables, depending on your target). - -5. **Install FreeGLUT and GLEW**: - - Run the following command to install FreeGLUT and GLEW: - ```bash - pacman -S mingw-w64-x86_64-freeglut mingw-w64-x86_64-glew - ``` - - **Note**: By using **MinGW**, you target Windows binaries, not Unix-like systems. - -6. **Install the GCC Toolchain**: - - To compile 42, you'll need the MinGW GCC toolchain: - ```bash - pacman -S mingw-w64-x86_64-toolchain - ``` - -7. **Install `make`**: - - You'll also need the `make` utility to run the Makefile: - ```bash - pacman -S make - ``` - -8. **Get the 42 Repository**: - - You can clone the 42 repository using **Git**. You can either use a Git client in Windows or install Git in MSYS2: - - If using a Windows Git client: - - Clone the repository into a standard Windows directory (e.g., `C:/Users/jpdavis6/42`). - - From the MinGW terminal, you can access this directory as `/c/Users/jpdavis6/42`. - - Alternatively, you could install Git in MSYS2 and clone the repository from there, but using a Windows Git client simplifies access. - -9. **Navigate to the 42 Root Directory in the MinGW Terminal**: - - Use the MinGW terminal to navigate to the cloned repository: - ```bash - cd /c/Users/jpdavis6/42 - ``` - -10. **Compile the Repository**: - - Run the `make` command to compile the project: - ```bash - make - ``` - - This will compile 42 as a native Windows executable (`42.exe`). - -11. **Run 42**: - - After compilation, you can run the executable: - ```bash - ./42.exe - ``` - -12. **Check for Errors**: - - If there are no errors, 42 should run successfully with native Windows integration. - -### Additional Notes: -- Ensure you are always using the **MSYS2 MinGW terminal** for compiling and running 42, as this targets Windows-native executables. Do not use the **MSYS2 MSYS** terminal for compiling Windows applications. -- If the `42.exe` file is created without the `.exe` extension, you can manually rename it or run it by typing the exact name (`42.exe`). - -### Final Thoughts: -These steps should allow you to successfully compile and run the 42 simulation software on Windows using MinGW. By targeting a native Windows executable, you avoid the complexities of WSL and external dependencies like XLaunch. - - -### To open **MinGW** from **VS Code**, follow these steps to integrate it as your terminal: - -### 1. **Install MSYS2/MinGW** - Make sure you have **MSYS2** installed, which includes MinGW. If not, you can download and install it from [MSYS2.org](https://www.msys2.org/). - -### 2. **Find Your MinGW Path** - Locate the **MinGW** shell executable within the MSYS2 installation directory: - - For **64-bit MinGW**, the path is typically: - ``` - C:\msys64\mingw64.exe - ``` - - For **32-bit MinGW**, the path is: - ``` - C:\msys64\mingw32.exe - ``` - -### 3. **Configure VS Code to Use MinGW Terminal** - You can configure **VS Code** to use the **MinGW** shell as its integrated terminal. - - - Open **VS Code**. - - Go to **File** > **Preferences** > **Settings** (or press `Ctrl + ,`). - - In the search bar at the top of the Settings window, type `terminal integrated shell`. - - Under **Terminal > Integrated > Shell: Windows**, click on **Edit in settings.json** to manually edit the configuration file. - - Add the following configuration to add **MinGW** to the list of terminals: - ```json - "terminal.integrated.profiles.windows": { - "MinGW64": { - "path": "C:\\msys64\\usr\\bin\\bash.exe", - "args": ["-l"], - "env": { - "CHERE_INVOKING": "1", - "MSYSTEM": "MINGW64" - } - } - }, - ``` - -### 4. **Open VS Code Terminal** - After configuring, you can open the terminal in **VS Code** by going to **Terminal** > **New Terminal** (or pressing `Ctrl + `). - -The dropdown should contain an entry of MinGW64. That should open as an integrated terminal in VS Cdoe. You can now compile and run your projects using **gcc**, **make**, and other MinGW tools directly from VS Code. \ No newline at end of file From 39ef2e4cf93c84a7bfaf7efbd891e23a5991efe1 Mon Sep 17 00:00:00 2001 From: jpdavis6 Date: Wed, 23 Oct 2024 14:17:37 -0400 Subject: [PATCH 4/8] Small edit to take out my user name --- Docs/Install-mingw-JD.md | 121 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 121 insertions(+) create mode 100644 Docs/Install-mingw-JD.md diff --git a/Docs/Install-mingw-JD.md b/Docs/Install-mingw-JD.md new file mode 100644 index 00000000..a64c4e54 --- /dev/null +++ b/Docs/Install-mingw-JD.md @@ -0,0 +1,121 @@ +### Why MinGW Instead of WSL? +WSL (Windows Subsystem for Linux) provides a Linux environment running on Windows. While it is a powerful tool, using it introduces some complexity, as the WSL environment must interface with Windows components to access features such as networking, GPU, and window management. For example, to use the internet, WSL must interface with the Windows network adapter, and external programs like XLaunch are required to display graphical applications. Similarly, to access OpenGL features, `mesa-utils` needs to be installed and updated, and there may be issues related to VPN or network configurations. + +On the other hand, **MinGW** compiles 42 as a native Windows executable, which means that you can directly use Windows components for window management, networking, and GPU access without extra dependencies or workarounds. MinGW targets native Windows APIs, so no additional software like XLaunch is needed. + +### Steps to Get 42 Working on Windows Using MinGW: + +1. **Install MSYS2**: + - Download and install MSYS2 from the official website using the `.exe` installer. + +2. **Open an MSYS2 Prompt**: + - MSYS2 should start automatically after installation. If not, open the **MSYS2 MSYS** terminal from the Start menu. + - **Note**: There is a distinction between MSYS2 and MinGW: + - **MSYS2** is a POSIX-like environment that provides a Unix-style shell. + - **MinGW** (within MSYS2) is used for building **Windows-native executables**. + +3. **Update MSYS2**: + - You need to update MSYS2 and MinGW. Run these commands in sequence: + ```bash + pacman -Syu + pacman -Su + ``` + +4. **Open an MSYS2 MinGW Terminal**: + - Once updated, open the **MSYS2 MinGW 64-bit** terminal for compiling 64-bit Windows executables (or **MSYS2 MinGW 32-bit** for 32-bit executables, depending on your target). + +5. **Install FreeGLUT and GLEW**: + - Run the following command to install FreeGLUT and GLEW: + ```bash + pacman -S mingw-w64-x86_64-freeglut mingw-w64-x86_64-glew + ``` + - **Note**: By using **MinGW**, you target Windows binaries, not Unix-like systems. + +6. **Install the GCC Toolchain**: + - To compile 42, you'll need the MinGW GCC toolchain: + ```bash + pacman -S mingw-w64-x86_64-toolchain + ``` + +7. **Install `make`**: + - You'll also need the `make` utility to run the Makefile: + ```bash + pacman -S make + ``` + +8. **Get the 42 Repository**: + - You can clone the 42 repository using **Git**. You can either use a Git client in Windows or install Git in MSYS2: + - If using a Windows Git client: + - Clone the repository into a standard Windows directory (e.g., `C:/Users/jpdavis6/42`). + - From the MinGW terminal, you can access this directory as `/c/Users/jpdavis6/42`. + - Alternatively, you could install Git in MSYS2 and clone the repository from there, but using a Windows Git client simplifies access. + +9. **Navigate to the 42 Root Directory in the MinGW Terminal**: + - Use the MinGW terminal to navigate to the cloned repository: + ```bash + cd /c/Users//42 + ``` + +10. **Compile the Repository**: + - Run the `make` command to compile the project: + ```bash + make + ``` + - This will compile 42 as a native Windows executable (`42.exe`). + +11. **Run 42**: + - After compilation, you can run the executable: + ```bash + ./42.exe + ``` + +12. **Check for Errors**: + - If there are no errors, 42 should run successfully with native Windows integration. + +### Additional Notes: +- Ensure you are always using the **MSYS2 MinGW terminal** for compiling and running 42, as this targets Windows-native executables. Do not use the **MSYS2 MSYS** terminal for compiling Windows applications. +- If the `42.exe` file is created without the `.exe` extension, you can manually rename it or run it by typing the exact name (`42.exe`). + + +### To open **MinGW** from **VS Code**, follow these steps to integrate it as your terminal: + +### 1. **Install MSYS2/MinGW** + Make sure you have **MSYS2** installed, which includes MinGW. If not, you can download and install it from [MSYS2.org](https://www.msys2.org/). + +### 2. **Find Your MinGW Path** + Locate the **MinGW** shell executable within the MSYS2 installation directory: + - For **64-bit MinGW**, the path is typically: + ``` + C:\msys64\mingw64.exe + ``` + - For **32-bit MinGW**, the path is: + ``` + C:\msys64\mingw32.exe + ``` + +### 3. **Configure VS Code to Use MinGW Terminal** + You can configure **VS Code** to use the **MinGW** shell as its integrated terminal. + + - Open **VS Code**. + - Go to **File** > **Preferences** > **Settings** (or press `Ctrl + ,`). + - In the search bar at the top of the Settings window, type `terminal integrated shell`. + - Under **Terminal > Integrated > Shell: Windows**, click on **Edit in settings.json** to manually edit the configuration file. + + Add the following configuration to add **MinGW** to the list of terminals: + ```json + "terminal.integrated.profiles.windows": { + "MinGW64": { + "path": "C:\\msys64\\usr\\bin\\bash.exe", + "args": ["-l"], + "env": { + "CHERE_INVOKING": "1", + "MSYSTEM": "MINGW64" + } + } + }, + ``` + +### 4. **Open VS Code Terminal** + After configuring, you can open the terminal in **VS Code** by going to **Terminal** > **New Terminal** (or pressing `Ctrl + `). + +The dropdown should contain an entry of MinGW64. That should open as an integrated terminal in VS Cdoe. You can now compile and run your projects using **gcc**, **make**, and other MinGW tools directly from VS Code. \ No newline at end of file From ebe5090c34b8c8e428f98cdaa9be3253a0cb5726 Mon Sep 17 00:00:00 2001 From: jondavis847 Date: Thu, 24 Oct 2024 10:44:07 -0400 Subject: [PATCH 5/8] simpler change by just including dlfcn.h if linux. updated documentation. --- Docs/Install-mingw-JD.md | 18 +++++++++++++++--- Makefile | 13 +++++++------ Source/42nos3.c | 2 +- 3 files changed, 23 insertions(+), 10 deletions(-) diff --git a/Docs/Install-mingw-JD.md b/Docs/Install-mingw-JD.md index a64c4e54..62b61621 100644 --- a/Docs/Install-mingw-JD.md +++ b/Docs/Install-mingw-JD.md @@ -3,10 +3,15 @@ WSL (Windows Subsystem for Linux) provides a Linux environment running on Window On the other hand, **MinGW** compiles 42 as a native Windows executable, which means that you can directly use Windows components for window management, networking, and GPU access without extra dependencies or workarounds. MinGW targets native Windows APIs, so no additional software like XLaunch is needed. +NOTE: NOS3 requires linux. If you need NOS3 support, than WSL will be the answer. + ### Steps to Get 42 Working on Windows Using MinGW: 1. **Install MSYS2**: - - Download and install MSYS2 from the official website using the `.exe` installer. + - We use the MSYS2 version of MinGW rather than the standalone versions like on SourceForge.net + - MSYS2 version will come with a package manager (pacman) that is useful for keeping our dependencies up to date, and removes the requirement for the historical 42ExternalSupport folder where dependencies were manually installed and updated + - Download and install MSYS2 from the official website https://www.msys2.org/ using the `.exe` installer. + - The **MSYS2 MinGW 64-bit** comes with the MSYS2 installation. 2. **Open an MSYS2 Prompt**: - MSYS2 should start automatically after installation. If not, open the **MSYS2 MSYS** terminal from the Start menu. @@ -15,7 +20,7 @@ On the other hand, **MinGW** compiles 42 as a native Windows executable, which m - **MinGW** (within MSYS2) is used for building **Windows-native executables**. 3. **Update MSYS2**: - - You need to update MSYS2 and MinGW. Run these commands in sequence: + - You need to update MSYS2 and MinGW. The terminal may need to restart during this process. Run these commands in sequence: ```bash pacman -Syu pacman -Su @@ -36,7 +41,14 @@ On the other hand, **MinGW** compiles 42 as a native Windows executable, which m ```bash pacman -S mingw-w64-x86_64-toolchain ``` - + - Verify that you have access to gcc from the MinGW terminal: + ```bash + gcc --version + ``` + - If not, add MinGW64 to your path from the MinGW terminal and verify that you have access to gcc again: + ```bash + export PATH="/mingw64/bin:$PATH" + ``` 7. **Install `make`**: - You'll also need the `make` utility to run the Makefile: ```bash diff --git a/Makefile b/Makefile index f43aa2ec..32d44ced 100755 --- a/Makefile +++ b/Makefile @@ -225,16 +225,17 @@ endif 42OBJ = $(OBJ)42main.o $(OBJ)42exec.o $(OBJ)42actuators.o $(OBJ)42cmd.o \ $(OBJ)42dynamics.o $(OBJ)42environs.o $(OBJ)42ephem.o $(OBJ)42fsw.o \ $(OBJ)42init.o $(OBJ)42ipc.o $(OBJ)42jitter.o $(OBJ)42joints.o \ -$(OBJ)42optics.o $(OBJ)42perturb.o $(OBJ)42report.o $(OBJ)42sensors.o +$(OBJ)42optics.o $(OBJ)42perturb.o $(OBJ)42report.o $(OBJ)42sensors.o \ +$(OBJ)42nos3.o # Exclude 42nos3.o for both MSYS2 and generic Windows (MinGW, etc.) since nos3 does not work and wont compile -ifeq ($(42PLATFORM),__MSYS__) +#ifeq ($(42PLATFORM),__MSYS__) # Exclude 42nos3.o for MSYS -else ifeq ($(42PLATFORM),_WIN32) +#else ifeq ($(42PLATFORM),_WIN32) # Exclude 42nos3.o for Windows -else - 42OBJ += $(OBJ)42nos3.o -endif +#else + # 42OBJ += $(OBJ)42nos3.o +#endif KITOBJ = $(OBJ)dcmkit.o $(OBJ)envkit.o $(OBJ)fswkit.o $(OBJ)geomkit.o \ $(OBJ)iokit.o $(OBJ)mathkit.o $(OBJ)nrlmsise00kit.o $(OBJ)msis86kit.o \ diff --git a/Source/42nos3.c b/Source/42nos3.c index e9b934f4..d98d54a8 100644 --- a/Source/42nos3.c +++ b/Source/42nos3.c @@ -14,11 +14,11 @@ #define _POSIX_C_SOURCE 1 /* For signal handling */ #include #include -#include #include "42.h" #if defined(__linux__) +#include #include static char BusName[120] = "command"; static char ConnectionString[120] = "tcp://127.0.0.1:12001"; From 293e5818b5dcd0809616bee6a4fc050d26928735 Mon Sep 17 00:00:00 2001 From: jondavis847 Date: Thu, 24 Oct 2024 10:56:24 -0400 Subject: [PATCH 6/8] removed a deprecated comment from makefile. put dlfnc.h behind an if not windows instead of if linux, since its defined for apple. --- Makefile | 9 --------- Source/42nos3.c | 7 ++++++- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/Makefile b/Makefile index 32d44ced..e624ab3e 100755 --- a/Makefile +++ b/Makefile @@ -228,15 +228,6 @@ $(OBJ)42init.o $(OBJ)42ipc.o $(OBJ)42jitter.o $(OBJ)42joints.o \ $(OBJ)42optics.o $(OBJ)42perturb.o $(OBJ)42report.o $(OBJ)42sensors.o \ $(OBJ)42nos3.o -# Exclude 42nos3.o for both MSYS2 and generic Windows (MinGW, etc.) since nos3 does not work and wont compile -#ifeq ($(42PLATFORM),__MSYS__) - # Exclude 42nos3.o for MSYS -#else ifeq ($(42PLATFORM),_WIN32) - # Exclude 42nos3.o for Windows -#else - # 42OBJ += $(OBJ)42nos3.o -#endif - KITOBJ = $(OBJ)dcmkit.o $(OBJ)envkit.o $(OBJ)fswkit.o $(OBJ)geomkit.o \ $(OBJ)iokit.o $(OBJ)mathkit.o $(OBJ)nrlmsise00kit.o $(OBJ)msis86kit.o \ $(OBJ)orbkit.o $(OBJ)radbeltkit.o $(OBJ)sigkit.o $(OBJ)sphkit.o $(OBJ)timekit.o diff --git a/Source/42nos3.c b/Source/42nos3.c index d98d54a8..805edf6b 100644 --- a/Source/42nos3.c +++ b/Source/42nos3.c @@ -15,10 +15,15 @@ #include #include +#if !defined(_WIN32) +// windows has different functions for dynamic linking +// nos3 not compiled for windows so we won't need this header +#include +#endif + #include "42.h" #if defined(__linux__) -#include #include static char BusName[120] = "command"; static char ConnectionString[120] = "tcp://127.0.0.1:12001"; From c11fbd002ab0bb14e0d3870ab7893ffabe6e8bbb Mon Sep 17 00:00:00 2001 From: jondavis847 Date: Thu, 24 Oct 2024 11:32:03 -0400 Subject: [PATCH 7/8] added logic to support people who use the 42ExternalSupport folder instead of pacman --- Makefile | 33 ++++++++++++++++++++++++++------- 1 file changed, 26 insertions(+), 7 deletions(-) diff --git a/Makefile b/Makefile index e624ab3e..8c80f743 100755 --- a/Makefile +++ b/Makefile @@ -145,19 +145,38 @@ endif ifeq ($(42PLATFORM),__MSYS__) CINC = - + EXTERNDIR = /c/42ExternalSupport/ # For graphics interface, choose GLUT or GLFW GUI libraries # GLUT is well known, but GLFW is better for newer Mac's hires displays #GLUT_OR_GLFW = _USE_GLFW_ GLUT_OR_GLFW = _USE_GLUT_ ifneq ($(strip $(GUIFLAG)),) - # Updated paths for pacman-installed GLEW and GLUT - LIBS = -lopengl32 -lglu32 -lfreeglut -lws2_32 -lglew32 - LFLAGS = - GUIOBJ = $(OBJ)42gl.o $(OBJ)42glut.o $(OBJ)glkit.o $(OBJ)42gpgpu.o - # Update include paths to the MSYS2 installed GLEW and GLUT - GLINC = -I /mingw64/include/GL/ + ifneq ($(shell pacman -Qi mingw-w64-x86_64-freeglut >/dev/null 2>&1 && pacman -Qi mingw-w64-x86_64-glew >/dev/null 2>&1 && echo true),) + LFLAGS = + GLINC = -I /mingw64/include/GL/ + $(info pacman) + else + GLEW = $(EXTERNDIR)GLEW/ + GLUT = $(EXTERNDIR)freeglut/ + + # if the directories don't exist, throw an error + ifeq ($(wildcard $(GLEW)),) + $(error The directory $(GLEW) does not exist. Please install GLEW to $(GLEW).) + endif + + ifeq ($(wildcard $(GLUT)),) + $(error The directory $(GLUT) does not exist. Please install GLUT to $(GLUT).) + endif + + LFLAGS = -L $(GLUT)lib/ -L $(GLEW)lib/ + GLINC = -I $(GLEW)include/GL/ -I $(GLUT)include/GL/ + $(info external) + endif + + LIBS = -lopengl32 -lglu32 -lfreeglut -lws2_32 -lglew32 + GUIOBJ = $(OBJ)42gl.o $(OBJ)42glut.o $(OBJ)glkit.o $(OBJ)42gpgpu.o + ARCHFLAG = -D GLUT_NO_LIB_PRAGMA -D GLUT_NO_WARNING_DISABLE -D GLUT_DISABLE_ATEXIT_HACK else GUIOBJ = From 495ed65cf1750ee450c47464ee41e187f393c9c8 Mon Sep 17 00:00:00 2001 From: jpdavis6 Date: Fri, 25 Oct 2024 09:21:07 -0400 Subject: [PATCH 8/8] changed if !defined to ifndef to be consistent. removed a debug statement. --- Makefile | 1 - Source/42nos3.c | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 8c80f743..c0ed9b7f 100755 --- a/Makefile +++ b/Makefile @@ -171,7 +171,6 @@ ifeq ($(42PLATFORM),__MSYS__) LFLAGS = -L $(GLUT)lib/ -L $(GLEW)lib/ GLINC = -I $(GLEW)include/GL/ -I $(GLUT)include/GL/ - $(info external) endif LIBS = -lopengl32 -lglu32 -lfreeglut -lws2_32 -lglew32 diff --git a/Source/42nos3.c b/Source/42nos3.c index 805edf6b..439cc05d 100644 --- a/Source/42nos3.c +++ b/Source/42nos3.c @@ -15,7 +15,7 @@ #include #include -#if !defined(_WIN32) +#ifndef(_WIN32) // windows has different functions for dynamic linking // nos3 not compiled for windows so we won't need this header #include