Chapter 32 Self-Assessment Quiz: Deploying Your Application


Section 1: Multiple Choice

Q1. What is the primary benefit of stripping symbols from a release build?

(a) It makes the code run faster (b) It significantly reduces the executable file size (c) It prevents users from decompiling the application (d) It removes compiler warnings

Answer (b) Stripping debug symbols removes the mapping between compiled code and source lines. This typically reduces executable size by 60-80% (e.g., from 20 MB to 4 MB). It does not significantly affect runtime speed (minor improvement from smaller cache footprint) and does not prevent decompilation (only removes debug metadata).

Q2. On Windows, sqlite3.dll must be:

(a) Compiled into the executable using static linking (b) Placed alongside the executable or in the system PATH (c) Installed through a separate SQLite installer (d) Registered in the Windows registry

Answer (b) SQLite3 is dynamically linked on Windows. The DLL must be in the same directory as the executable, or in a directory listed in the system PATH. The simplest approach is to ship it alongside the executable.

Q3. An Inno Setup .iss script is used to:

(a) Compile Pascal source code (b) Create a Windows installer executable (c) Cross-compile for multiple platforms (d) Generate .deb packages for Linux

Answer (b) Inno Setup reads a .iss script that describes the files to install, shortcuts to create, and registry entries to make. It produces a single .exe installer that handles installation, uninstallation, and Start Menu integration on Windows.

Q4. A macOS .app bundle is:

(a) A compressed archive like a ZIP file (b) A directory structure that the Finder treats as a single application (c) A virtual machine image (d) A script that downloads the application from the internet

Answer (b) A .app bundle is a directory with a specific structure (Contents/MacOS/executable, Contents/Info.plist, Contents/Resources/icon.icns). The macOS Finder displays it as a single clickable application icon rather than as a folder.

Q5. GetAppConfigDir(False) returns:

(a) The application's installation directory (b) The per-user configuration directory for the application (c) The system-wide configuration directory (d) The temporary directory

Answer (b) GetAppConfigDir(False) returns the per-user configuration directory (e.g., %APPDATA%\AppName on Windows, ~/.config/appname on Linux). The False parameter means per-user (not system-wide). This is where you should store user-specific settings and data.

Q6. Cross-compilation means:

(a) Compiling the same code for different Pascal compilers (b) Compiling for a different target platform from the one you are running on (c) Compiling with both debug and release settings (d) Compiling the same code with different optimization levels

Answer (b) Cross-compilation produces a binary for a different OS/CPU combination than the host. For example, building a Windows .exe on a Linux machine, or building a Linux binary on Windows. Free Pascal supports this through target OS and CPU flags.

Section 2: True or False

Q7. A Free Pascal/Lazarus application requires the user to install a runtime environment before it can run.

Answer False. Free Pascal compiles to native machine code and statically links the Pascal runtime. The resulting executable is standalone — no runtime, interpreter, or virtual machine needs to be installed. The only potential dependencies are dynamically linked libraries like SQLite3 or GTK.

Q8. An AppImage is a Linux packaging format that runs on any Linux distribution without installation.

Answer True. An AppImage is a single file that bundles the application and its dependencies. The user downloads it, makes it executable (chmod +x), and runs it. No package manager, no root access, no installation needed.

Q9. The -O3 optimization level always produces better results than -O2.

Answer False. -O3 enables aggressive optimizations that can sometimes produce slightly slower code due to increased code size (reduced cache efficiency) or by triggering edge cases in the optimizer. -O2 is generally the safe choice for production builds. Always benchmark if you use -O3.

Section 3: Short Answer

Q10. List the files you would include in a Windows ZIP distribution of PennyWise (portable mode, no installer). Explain the purpose of each file.

Answer
PennyWise/
├── PennyWise.exe     (the compiled application)
├── sqlite3.dll       (SQLite database library)
├── pennywise.ico     (application icon for shortcuts)
├── portable.flag     (signals portable mode — store data locally)
└── README.txt        (installation and usage instructions)
The executable is the application itself. sqlite3.dll is required for database operations. The icon is used if the user creates a manual shortcut. portable.flag triggers portable mode. README provides documentation.

Q11. Why is testing with different regional settings important for deployment? Give a specific example of what can go wrong.

Answer Different regions use different decimal separators: the US uses a period (3.14) while most European countries use a comma (3,14). If your application uses StrToFloat to parse user input or saved data, and the system locale changes the decimal separator, a file saved on a US system may fail to load on a German system (or vice versa). Fix: use FormatSettings with an explicit decimal separator for file I/O, or use the database (which has consistent formatting).

Q12. Explain why you should use Application.Location instead of hardcoded paths when locating data files that ship alongside the executable.

Answer Application.Location returns the directory containing the executable at runtime, regardless of where the application is installed. Hardcoded paths (like C:\Program Files\PennyWise\) break when the user installs the application in a different location, runs it from a USB drive, or uses a different operating system. Application.Location is always correct.