GLFPE IDEs and build systems 17 Jul 2020 GLF ------------------------------------------------------------------------------- Gary L. Flispart (GLF) publishes custom Linux OS "Remix" distributions (see YouTube "CustomOSMaker") and compendia of personal historical and current C/C++ program code along with build instructions for intersted programmers. In process of program development, GLF has adopted an uses certain Integrated Development Environment (IDE) tools, and provides those within the Linux OS distribution for use personally and by others. The following discussion explains which tools are used, and why, and which aren't, and why not. GLFPE sample source code supports multiple OS and CPU platforms ---------------------------------------------------------------- The GLF Programming Environment (GLFPE) has been designed by GLF mostly to compile his own C/C++ programming projects. GLF develops almost exclusively using C and C++, but has changed OS platforms and compiler versions many times over more than 40 years of professional and personal experience, aiming for mostly platform-portable code. However, GLF does not find it practical to attempt to make all build systems work (cross-compile) over the same set of source code files in the same directory locations. GLF has experimented with other programming languages (COBOL, FORTRAN, Python, Java, NodeJS) and has installed a few basic IDEs for some of these languages (e.g. BlueJ for Java, IDLE for Python), but has no real preferences or specific recommendations or support for these IDEs. Most GLF programming continues to use C/C++. The Arduino IDE uses Processing, which is NEARLY C++. Therefore GLF chooses to focus on support for C/C++ in the IDEs chosen for GLFPE sample source projects. There are some 700+ source programs in the GLFPE sample source code suite, and the suite includes local libraries on which other modules depend, so keeping all the related, proven compatible code in one subtree matters. When porting to a substantially different OS/CPU/compiler platform, rather than try to force conditionally portable code for all files, GLF chooses to make blanket copies of working code projects from one platform subtree to another. After copying code trees, any necessary platform changes are made to project files, Makefiles, test scripts, etc. to work on the alternate target platform. On Linux most such changes are minimal, but not always trivial. For example, GLF targets IBM PC compatible x86-64 (64-bit amd64) and i386 (32-bit 686) OS platforms, but also the armhf (32-bit) platform to support Raspbian OS on raspberry Pi computers. Many if the Linux support libraries and facilities port readily, but not all, and some resources are available on PC or RPi, but not both. RPi armhf is a 32-bit platform, and that forces some critical differences in source files and project specifications at compile time. GLF also continues to personally support legacy MSDOS (16-bit x86) programs in another separate tree. GLF has been programming for over 50 years. Many of the current Windows and Linux programs were originally ports of MSDOS command line programs, themselves previously ported from minicomputer FORTRAN. Many still work on modern platforms, but available C library and system services are quite different across MSDOS, Windows, And Linux. GLF tries to make most code generally portable, but not all required source variations are implemented using conditional code macros, and some manual editing may be necessary across platforms. Not all programs apply to all platforms. Raspberry Pi has low-level digital control circuitry not available on PCs, and programs relying on those features do not generally port to PCs. Windows executables use an entirely different set of build assumptions and tools, and executable format is quite different. GLF finds an advantage keeping the working executables and compatible libraries near the respective source files for each platform. Hence, GLF chooses to maintain as many otherwise redundant copies of source code suites as needed for the various supported platforms. Source organization and build systems preferred by GLF -------------------------------------------------------------------------- GLF has tended over the years to use language-specific IDEs, beginning with Borland Turbo Pascal and Turbo C under MS-DOS, Bloodshed Dev-C++ (later forked to Orwell Dev-C++) under Windows, and (obscure and little-known) V IDE under both Windows and Linux. GLF has also experimented with and attempted to support other C/C++ build systems or IDEs on Linux platforms, especially CMake, Code::Blocks, and CodeLite. GLF has recently looked at porting GLFPE code to other, more modern/popular IDEs such as Eclipse and VSCode, and how these tools affect project structure. GLF chooses to organize personal programming projects as a structured directory tree separated by IDE/language/compiler/version. That is, 64-bit Linux source code using the V IDE with GCC 8.3 is kept separate (~/src/v64_830/) from say, Windows code using the 32-bit Orwell Dev-C++ IDE with MinGW (GCC) 6.3 compiler (c:\prg\win\orw630\). Each platform-level subtree may contain many apparently redundant copies of original C/C++ source code, but all objects and binaries built within each subtree are compatible within that subtree. GLF projects are associated with each source level subfolder, and for the most part, object files and binaries are built within the same folders as source. The easy part of alternate IDEs ----------------------------------------- GLF prefers to build projects for the most part with IDEs. IDEs make it relatively easy to add libraries, source files, or include files to projects during development, and generally automatically generate associated Makefiles which can be used later to efficiently rebuild the same projects in automated batch scripts. Makefiles are not terribly complicated, but there are many pitfalls to hand-edit a correct Makefile, and project conversions remove most of the tedium and arcanery. For the most part, IDEs work well for reatively simple projects with maybe a few hundreds or thousands of lines of code, and not too many files from far-flung sources. Standardized open source libraries aren't a big problem as long as they are readily portable to all platforms. For some platforms open libraries are simply downloaded from repositories. On others (Windows?) they must be downloaded and built from source using the locally available compiler, which can sometimes take considerable time and effort up front. After initially compiling the library, it tends to be easily included in otherwise simple projects. therefore even large open libraries (such as libgmp, libpng, libogg, etc.) are still compatible with simple IDE based development. GLF started using IDEs in the 1980s with Turbo Pascal and Turbo C, which had very simple ASCII plaintext project files. When moving to Windows programming, GLF found Dev-C++ provided another convenient ASCII plaintext format, more complicated than Turbo C but readily convertible by manual or automated means. That made it fairly easy to make the first ports of GLF MSDOS code to equivalent Windows code. Over time Dev-C++ became GLF's personal IDE of choice, and all new development started with a Windows version, which was then backported to DOS as appropriate. Later, GLF wished to port over to Linux platforms. GLF experimented with various similar distributions (Ubuntu and Mint) and ultimately settled on Debian Mate as primary target platform, originally 32-bit and later 64-bit. Dev-C++ worked well under Windows, but the program was not portable to Linux. To make the port to Linux work, GLF looked for a cross-platform IDE with a similarly simple project scheme. GLF found an old open project online which implemented a GUI framework called V, which included an IDE (the V IDE) to develop C and C++ programs under either Windows or Linux (X). GLF was eventually able to port the source for V IDE to Windows and begin testing it. The V IDE also used a simple ASCII plaintext project file format, which made it fairly easy to convert Dev-C++ *.dev project files to *.vpj V IDE project files. They both used the same compiler toolchains, so they produced equivalent binary executables. That made it easy to check the correctness of each port from Dev-C++ to V IDE. GLF then succeeded in porting the same V IDE to Linux using X resources, and that made it finally possible to convert original Windows projects to Linux projects which may use different OS resources, but perform the same way. That made V IDE GLF's preferred mechanism for porting programs from Windows to Linux and maintaining the Linux code. Both Dev-C++ and V IDE used the data in their respective project files to generate local Makefiles which were used in turn to perform the actual project build using Gnu Make. By saving and renaming those Makefies, and creating wrapper scripts to string them together, GLF was able to produce automated build scripts for both Windows and Linux platforms which could successfully rebuild all the GLFPE programs in a few minutes, with feedback on success or failure, to test the suite integrity. Over time, as GLF took more interest in Linux and less in Windows, GLF gravitated to using V IDE and Linux for all new development, and that is current practice. GLF uses the OS built-in editor (Pluma or Gedit or Geany) to edit the code in Linux, but then V IDE to compile it. The hard part of alternate IDEs ----------------------------------------- However, the tools GLF relied on were showing age related problems. The original Dev-C++ had been abandoned in the 1990s, but forked and redesigned a couple of times into the early 2010s. The V IDE is fully cross-platform, but somewhat rudimentary. It us also effectively obsolete and all but abandned by its author (though it was still discoverable on the web as of this writing -- see http://vgui.sourceforge.net/). In fact more than once GLF was forced to modify the source code to handle changes in the GCC compiler over the years. GLF looked for a more current IDE to perhaps move to a more popular, better supported framework. The closest fit GLF found was Code::Blocks, an IDE optimized for C++ and wxWidgets, but had the important feature of autotranslating the Dev-C++ project format to *.cbp Code::Blocks format. It was available for both Windows and Linux. It is a fully functional replacement IDE on both platforms, but GLF tended not to use it, because it used its own internal build system and did not by default produce makefiles usable by automated build scripts. GF attempted to use CodeLite, but found it had ideosyncrasies which argued agianst adoption. All the above IDEs tried by GLF so far use one project file per project, and allow these project files to be organized as part of the normal source tree structure. When GLF looked at some of the more recently popular full-featured IDEs, GLF found the situation considerably more complicated. GLF has attempted to use VSCode (Microsoft's open variant of Visual C++), but finds the menus quite confusing. It is not obvious exactly which optional plugins are needed to actually get started with the FIRST project, nor how much space the program might ultimately take up. It seems to be difficult to organize individual projects in a tree as GLF has done for years. VSCode seems to push the notion of workspaces which jump across many folders and even networked computer files. That may be appropriate for multideveloper corporate projects, which may restrict the focus at any gven time to a single overall large project, but did not fit a collection of freely interchangeable small projects. Google search showed many other developers are similarly confused by the similarities and differences between workspaces and projects within VSCode, and Microsoft seems to be changing the definitions on the fly. However, because of the wide popularity of VSCode, GLF has provisionally included a recent version of VSCode as a .deb file into GFPERS for testing and evaluation. It appears that for simple projects adding the C/C++ extension and including a ".vscode" folder containing a custom crafted .json file under each project folder might work to adapt the GLF sample source code to VSCode. GLF recently tried Eclipse as an IDE. GLF was initially put off by the large size of the essentially monolithic program (200+ Mb installation vs. a few mb or even kb for IDEs already in use). However, Eclipse is popular, so GLF tried it. The initial test was promising, owing to the Import feature which can start a new project based on an existing Makefile. GLF succeeded in porting a couple of existing projects to Eclipse by copying an existing makefile autogenerated by V IDE to "Makefile" in the same folder. The imported Makefile built an equivalent executable in both cases. However, the stopper was finding where the data was being stored which defined each new project. The simpler IDEs stored a single simple, ACII projrect file in the same flder the project could be built in. Eclipse instead put all data related to the new projects into a smattering of obscure XML files under a group of (hidden) folders under the "home" directory. Instead if project specs belonging to the project source, the s[ecs were organized to belong to the user himself, which GLF found inappropriate. The scattered data was cryptic and not completely documented, so automatic generation of a project tree is not completely practical. However, GLF has experimentally adapted projects to Eclipse and has begun to include WIP support for it in the GLFOE sample source tree. By trial and error GLF has found the following structure to allow Eclipse to work: All source is located under a subfolder "src" under the user's home folder. Underneath "src" is a folder (currently v64_830) which contains the GLF C/C++ source tree. Parallel to that is another folder named "Eclipsews_v64_830", which contains a parallel tree with all the same subfolder names to identify projects using the same names for Eclipse that are used by other IDEs. The "Eclipsews_v64_830" workspace folder tree is used to store ONLY the workspace configurations (under ".metadata" subfolders) for each named project (tree folder name). All project source code remains under the source (v64_830) folder tree. GLF by standard organizes groups of similar projects under an overriding category folder. For example, src/v64_830/astro/sid-clk and src/v64-830/testlibs/GL_bounce contain the source files for those two projects. Many of the GLF source files refer to header files and link libaries found in the src/v64_830/clibrary folder, which contains copies of headers and *.a static library files compiled from source projects one more layer down under clibrary (e.g. src/v64_830/clibrary/06_gflib). By design all GLF *.c and *.cpp fles are found two layers down below "v64_830". Therefore most projects may use the relative reference "../../clibrary" to include GLF-specific headers and link libraries. CMake has been important to GLF mainly because certain other open source library projects use it as a build system. GLF sometimes must acquire a needed open surce library by compiling it from source code. CMake is widely used for both large and small projects, but is quite different from the conventional edit-make-install cycle familiar for Linux projects. There is no IDE per se with CMake, just a command line build system. A GUI is provided only to set the variables in the configuration file. However, many large projects have adopted it because it provides many build time automation and testing options. CMake by default builds all binaries and other products in a subfolder separate from the original source files. This has advantages, especially when multiple versions (say release and debug) of targets must be maintained. The CMake process is relatively simple to RUN when everything is PRECONFIGURED (as when provided by an existing open source library). Therein lies the rub. Starting such a configuration from scratch or by conversion from an existing project can be maddeningly difficult. The build configuration file starts in a single CMakeLists.txt file, but that's where simplicity ends. The "language" expressed in the CMakeLists.txt file is anything but straightforward to the uninitiated. The system provides little to no advantage over the existing Makefiles for GLF projects, and GLF chooses NOT to convert to CMake. Recommendations for GLF and any other interested user of GLFPE sample source ---------------------------------------------------------------------------- GLF will continue to support personal development projects using Orwell Dev-C++ on Windows, Borland Turbo C 2.01 on MSDOS, and V IDE on Linux. GLF also supports equivalent Code::Blocks project files autogenerated (by a GLF program) from V IDE projects. An interested user may thus use either V IDE (rudimentary and obscure) or Code::Blocks (well equipped and popular) to build any of the GLF projects on either Linux or Windows. If the user needs Eclipse or Cmake, good luck. GLF won't bother. A user who insists on using the Eclipse IDE may invest his own time and readily convert projects one at a time to Eclipse from existing GLFPE Makefiles. In general, one may copy "Makefile.v" (or locally *.vmk) to "Makefile" and "Import Project" to Eclipse. The user will have to maintain and organize his own project data folders, since they will be stored within the user's personal data area. As for CMake, there isn't enough benefit to justify the effort to convert GLF projects to CMake. GLF has little interest in VSCode for personal use, but has begun provisional experimentation with it. If possible, GLF will try to include individual .vscode project configuration folders to make the GLF projrect tree compatible with VSCode, whether or not VSCode is actually included by default in the distribution. It is relatively easy for a user to install VSCode from the Microsoft website if desired.