khartmansjsu / khartmansjsu/MOC-Linux
## Get MOC_GridDlg.cpp to compile
- Dominant language
- Gnuplot
- Stars
- 0
- Forks
- 0
- PR merge metrics
- No merged PRs in 30d
Description
## Goal: compile MOC_GridDlg.cpp
### Summary
Changelog:
- On `line 4` of `MOC_GridDlg.cpp`, comment out dependency on `stdafx.h`
At first glance, and referring to the last comment on this issue (where CreatMOCGrid is seen to be called from only '`MOC_GridDlg.cpp` on line 540), I identify a function method of the class CMOC_GridDlg, CMOC_GridDlg::OnCalcMOCBUTTON(). CreatMOCGrid is called from within this function. Additionally, this appears to be the only block of code thus far which could be run standalone, with the replacement of some lines of code, such as line 517, where AfxMessageBox() is used to print a fatal error message. I think that a `main.cpp` script which contains a form of lines 503-547 is a good path to take in implementing the above **plan of action**. Still, I will go through the steps to remove dependencies of `MOC_GridDlg.cpp` on packages which cannot exist in linux. Attempts 1 - ___ itemize these steps.
### Attempt 1:
```
[khartm12@integrity MOC_Grid_BDE]$ g++ MOC_GridDlg.cpp -o MOC_GridDlgTest
MOC_GridDlg.cpp:4:10: fatal error: stdafx.h: No such file or directory
4 | #include "stdafx.h"
| ^~~~~~~~~~
compilation terminated.
[khartm12@integrity MOC_Grid_BDE]$
```
- Change: On `line 4` of `MOC_GridDlg.cpp`, comment out dependency on `stdafx.h`
- Reason: `stdafx.h` is another Windows MFC library. It doesn't exist, and we don't want it to in order for this code to compile.
### Attempt 2:
```
[khartm12@integrity MOC_Grid_BDE]$ g++ MOC_GridDlg.cpp -o MOC_GridDlgTest
MOC_GridDlg.cpp:4:10: fatal error: stdafx.h: No such file or directory
4 | #include "stdafx.h"
| ^~~~~~~~~~
compilation terminated.
[khartm12@integrity MOC_Grid_BDE]$ g++ MOC_GridDlg.cpp -o MOC_GridDlgTest
In file included from MOC_GridDlg.cpp:5:
MOC_Grid.h:12:3: error: #error include 'stdafx.h' before including this file for PCH
12 | #error include 'stdafx.h' before including this file for PCH
| ^~~~~
MOC_GridDlg.cpp:14:10: fatal error: direct.h: No such file or directory
14 | #include "direct.h"
| ^~~~~~~~~~
compilation terminated.
[khartm12@integrity MOC_Grid_BDE]$
```
- Still getting a compile time issue related `stdafx.h`, but the issue is coming from `MOC_Grid.h` now instead of `MOC_GridDlg.cpp`.
- Change: On `line 5` of `MOC_GridDlg.cpp`, comment out the include statement for `MOC_Grid.h`.
- Reason: `MOC_Grid.h` is the main header file for the application, but doesn't appear to contain any important code blocks for calculations of MOC contours or streamlines, etc. Rather, it declares a class CMOC_GridApp of type CWinApp. While this is useful for the GUI and application, it is not necessary for the linux version we are developing. Remove it.
- Change: On `line 14` of `MOC_GridDlg.cpp`, comment out the include statement for `direct.h`.
- Reason: `direct.h` does not exist in any of this package's three subdirectories. This is why the compiler does not find it. [Here](https://stackoverflow.com/questions/6193607/cannot-find-direct-h), we see some stackoverflow contributors citing wikipeadia that `direct.h` is a Microsoft Windows specific header file, the utilities of which replaced by including `unistd.h` in a linux system. I will not do this just yet. I want to first confirm that `direct.h` is being used in a way that `unistd.h` can also be used.
- **Note:** I further corroborated the stackoverflow contributors' citation by finding the [official Digital Mars documentation](https://digitalmars.com/rtl/direct.html) for direct.h. Its compatibility is listed, and does not include Linux systems.
### Attempt 3:
see [compile_errors2.txt](https://github.com/khartmansjsu/MOC-Linux/files/8543321/compile_errors2.txt)
tons of compile time error, unrelated to missing header files or undeclared header files.
- Below, we see the compiler complaining about DECLARE_DYNAMIC, an MFC object which is of course not available in linux.
```
MOC_GridDlg.h:18:2: error: ISO C++ forbids declaration of ‘DECLARE_DYNAMIC’ with no type [-fpermissive]
18 | DECLARE_DYNAMIC(CMOC_GridDlg);
| ^~~~~~~~~~~~~~~
```
The plethora of compile-time errors further supports the idea that I should try to extract `lines 503-547` from MOC_GridDlg.cpp and make a script which can run in linux, not requiring all the windows dependencies that pop up in the header files' function declarations. There will undoubtedly be more windows dependencies buried in the aforementioned lines of code, but it will at least be a smaller code base to start, and will still ultimately generate output files as the original code does.
_Originally posted by @khartmansjsu in https://github.com/khartmansjsu/MOC-Linux/issues/1#issuecomment-1106734644_
Contributor guide
No contributing guide indexed for this repository
Research direction
Start by reviewing MOC_GridDlg.cpp, especially lines 503-547 and the dependencies on stdafx.h, MOC_Grid.h, and direct.h. Run the documented g++ compilation attempt and inspect compile_errors2.txt to map the remaining Windows/MFC dependencies. Done means the relevant MOC calculation code compiles on Linux and can generate the original output files.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- build-system, operating-systems
- Issue type
- Refactor
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100