How AI Helped Me Build a Windows Installer for CP2K: A Graduate Student's Vibe Coding Experience
This article walks through the real process of packaging CP2K, an open-source scientific computing program designed for Linux, into a double-click Windows installer with the help of an AI coding agent. It covers dependency analysis, compilation configuration, error log debugging, Inno Setup packaging, DLL bundling, testing on a clean VM, and writing end-user documentation, plus practical lessons on using AI as a step-by-step problem-solving assistant rather than a one-shot code generator.
How AI Became My Unofficial Engineer: A Graduate Student’s Journey to Windows-ify CP2K
Where It Started: A Message Asking for Help
Last December, my cousin, a graduate student, sent me a message out of the blue: “Hey, how do I install a scientific computing package? Our lab needs it, but I can’t make sense of any of the online guides…”
The software she meant was CP2K, an open-source computational program widely used in quantum chemistry and materials simulation. Its code is open, it is powerful, and it has been cited in thousands of academic papers, but for a Windows user, the installation barrier is absurdly high.
I skimmed the official documentation and roughly understood the problem: CP2K is built for a Linux environment. It depends on a complete Fortran/C compilation toolchain, BLAS/LAPACK math libraries, the FFTW fast Fourier transform library, an MPI parallel framework, plus optional add-ons like Libxc and Libint. On Linux, all of this can be resolved with a single apt install or conda install. For Windows users, however, every step is a trap.
Users typically have three options:
- WSL (Windows Subsystem for Linux): Install an Ubuntu subsystem and wrestle with it inside. But many lab computers have IT policies that disable WSL, and for laptops with limited memory, running a full Linux environment is a heavy load.
- A virtual machine: Heavier than WSL, but with better compatibility. The problem is that the idea of “installing a Linux VM just to install software” already scares off 80% of chemistry and biology graduate students.
- Finding pre-built Cygwin/MinGW binaries: People have compiled them, but the versions are old, dependencies are missing, there is no GUI, and ordinary users can hardly judge whether “this build is trustworthy.”
In the end, my cousin chose WSL, struggled with it for three days, hit version conflicts between the MPI library and math libraries, failed compilation three times, and gave up.
At that moment, a thought popped into my head: this thing ought to have a one-click installer! Most software on Windows is installed by double-clicking an .exe and clicking “Next” all the way. Why can’t scientific computing software work the same way?
But that thought lasted only five seconds, because I knew how hard this was: I would need to figure out CP2K’s complete runtime dependency chain, write an installer script with Inno Setup or NSIS, handle DLL registration and PATH environment variables on Windows, and write an uninstaller to make sure it “installs cleanly and uninstalls cleanly”… None of these were areas I knew well.
So the idea sat on the shelf for half a year.
The Turning Point: “Probing” in the Vibe Coding Era
Time moved to this year. Generative AI has evolved beyond recognition, and I had long since woven intelligent coding tools into my daily work, from code review to log analysis to writing regular expressions.
The shelved idea popped back into my mind, and I wondered: could this be the time to actually try it?
So one evening, I opened a coding tool with AI assistance (the exact tool doesn’t matter, LLM-driven coding agents are largely similar nowadays) and started a conversation about it.
I said: “I want to package CP2K into a Windows installer that runs on double-click and installs with Next-Next-Finish. Do you have any ideas?”
Instead of dumping a pile of code on me, it first asked me a few questions:
- What Windows version are your target machines running? (This determines whether you can compile with MSVC.)
- Which CP2K version do you plan to compile? Serial or MPI parallel?
- Do you plan to use Conda-forge or an MSYS2 environment to provide dependencies?
- Do you prefer NSIS or Inno Setup for the installer?
My reaction was: uh? I don’t understand any of these. Can you choose for me?
It made recommendations: target Windows 10/11 64-bit; use a recent stable CP2K release (such as 2023.1 or 2024.1); use MSYS2 for the dependency environment because some Conda-forge packages are not very stable on Windows; and use Inno Setup because its scripting syntax is friendlier and its multilingual support is better.
The key point of this conversation was that the AI did not treat me as a total beginner who needed everything explained, nor did it assume I obviously knew what MSYS2 was. With a rhythm of “I know you don’t understand, but I can walk you through it step by step,” it explained the reasoning behind each decision.
Step 1: Dependency Analysis: Let AI Be the “Architect”
Next, I asked the AI to list all the dependencies CP2K needs to compile and run on Windows, along with the purpose of each one.
It produced a dependency list, roughly as follows:
| Dependency | Purpose | How to Get It on Windows |
|---|---|---|
| MSYS2 MinGW64 environment | Provides a Unix-like compilation toolchain | Official installer |
| GCC/GFORTRAN | Fortran/C compilers | pacman -S mingw-w64-x86_64-gcc-fortran |
| BLAS/LAPACK (OpenBLAS) | Foundational matrix operation library | MSYS2 package |
| FFTW3 | Fast Fourier transform | MSYS2 package |
| Libint | Multi-particle integrals | Must be compiled separately |
| Libxc | Exchange-correlation functionals | Must be compiled separately |
| Optional: MPICH or OpenMPI | MPI parallel | MSYS2 package |
The greatest value of this table was not the information itself, since all of it can be found in CP2K’s official documentation, but that the AI organized it into a format a beginner could understand, annotating each dependency’s purpose, how to obtain it, and whether it had known Windows compatibility issues.
For example, it noted that OpenBLAS works properly in the MSYS2 MinGW64 environment, but ATLAS has no official pre-built Windows version, needs to be compiled from source, and is prone to failure, so it recommended skipping it.
These are details that neither the official documentation (which “only covers Linux”) nor community guides (which say “I got it working, just copy me”) will tell you.
Step 2: Compilation Configuration: Wrestling with Error Logs
With dependencies installed, it was time to compile.
CP2K’s compilation is controlled by an arch configuration file. You need to tell the compiler which compiler to use, which libraries to link, and which compilation options to apply. On Linux, this file typically looks like this:
# cp2k/arch/Darwin-m1-omp.arch (macOS example)FC = mpifortCC = mpiccLD = mpifortDFLAGS = -D__parallel -D__SCALAPACKFCFLAGS = -O2 -fopenmpLDFLAGS = -lfftw3 -lopenblas
The AI wrote the corresponding configuration for the Windows MinGW64 environment for me:
# cp2k/arch/Windows-x86_64-serial.archFC = gfortranCC = gccLD = gfortranDFLAGS = -D__FFTW3 -D__LIBXCFCFLAGS = -O2 -fopenmp -I/mingw64/includeLDFLAGS = -L/mingw64/lib -lfftw3 -lopenblas -lpthread
Sounds simple, right? In reality, the first compilation produced over a hundred lines of errors, all of them undefined reference.
The AI asked me to paste the complete error log, then analyzed it item by item:
undefined reference to 'dgemm_'→ OpenBLAS wasn’t linked. Check the library path inLDFLAGS.cannot find -lfftw3→ FFTW3 was installed in/mingw64/binbut there was no symlink in the lib directory, so the full path needed to be specified manually.dereferencing type-punned pointer will break strict-aliasing rules→ This is a warning, not an error, but adding-fno-strict-aliasingcould silence it to avoid flooding the screen.
Each cycle of modifying the configuration, recompiling, pasting the log, and AI analysis took about 5 to 10 minutes. After roughly a dozen-plus compilation attempts, it finally built successfully.
Worth noting is that the AI occasionally suggested unreliable solutions. Once it recommended “try changing -O2 to -O0, lowering the optimization level might bypass the compile error.” I tried it and it did skip a certain error, but the resulting binary produced incorrect numerical results when running test cases, so I eventually had to revert and fix it properly. This is the everyday reality of Vibe Coding: AI can do 70% to 80% of the work for you, but the final 20% still requires your own verification and judgment.
Step 3: Writing the Installer: Let AI Be the “Product Manager”
A successful build was only the first step of a long journey. Next, I had to turn it into something ordinary users could install by double-clicking.
I had the AI write an installer script with Inno Setup, which roughly looked like this:
; CP2K Inno Setup Script[Setup]AppName=CP2K Scientific ComputingAppVersion=2024.1DefaultDirName={pf}\CP2KDefaultGroupName=CP2KOutputBaseFilename=CP2K-Windows-InstallerCompression=lzma2SolidCompression=yesArchitecturesAllowed=x64compatibleArchitecturesInstallIn64BitMode=x64compatible[Files]Source: "build\cp2k.pdb"; DestDir: "{app}\bin"; Flags: ignoreversionSource: "build\cp2k_shell.exe"; DestDir: "{app}\bin"; Flags: ignoreversionSource: "mingw64\bin\*.dll"; DestDir: "{app}\bin"; Flags: ignoreversionSource: "examples\*"; DestDir: "{app}\examples"; Flags: recursesubdirs[Icons]Name: "{group}\CP2K Command Line"; Filename: "{app}\bin\cp2k_shell.exe"Name: "{group}\Uninstall CP2K"; Filename: "{uninstallexe}"[Registry]Root: HKLM; Subkey: "SYSTEM\CurrentControlSet\Control\Session Manager\Environment"; \ValueType: expandsz; ValueName: "Path"; ValueData: "{olddata};{app}\bin"; \Check: NeedsAddPath('{app}\bin')
Several key points:
DLL bundling: CP2K compiles into an
.exefile, but at runtime it depends on a bunch of DLLs from the MSYS2 MinGW64 environment (libgfortran, libgcc_s_seh, libwinpthread, libfftw3, libopenblas…). I initially didn’t know which DLLs to package. The AI had me runobjdump -p cp2k_shell.exe | grep "DLL Name"to list all direct dependencies, then recursively find each DLL’s dependencies, and finally compile a complete DLL list. Along the way, the AI also reminded me: “libwinpthread-1.dll is often missed, because it isn’t a direct dependency of CP2K, but a dependency of OpenBLAS.”Environment variable injection: The installer needed to add
{app}\binto the system PATH so users could open a terminal in any directory and runcp2k_shell.exedirectly. Inno Setup’s[Registry]section can do this, but you need to check whether the path already exists in PATH to avoid adding it twice, so the AI wrote me aNeedsAddPath()function.Uninstall cleanup: The AI specifically reminded me that uninstalling can’t just mean deleting the installation directory; you also have to remove the PATH entry. This part used the
[UninstallDelete]section and a customUninstallprocedure.
Step 4: Testing and Release: From “It Works for Me” to “It Works for Others”
Once the package was built, I didn’t test it on my own machine (which is full of various development environments and can’t surface problems). Instead, I found a clean Windows 11 virtual machine, copied the installer over, and double-clicked it.
First test: installation succeeded, but double-clicking the icon caused an instant crash.
Cause: a DLL version conflicted with one bundled with the system. Solution: I added a [Dirs] entry in the installer to put all DLLs in a separate lib directory, then wrote a launch script that sets PATH before starting the exe. This essentially simulated the behavior of LD_LIBRARY_PATH on Linux.
Second test: installation succeeded, ran a test input file, and the output was correct.
Third test: uninstall, check the registry and PATH, clean.
Only at this point was the installer truly “usable.”
Step 5: Write Documentation “For Humans”
AI can write code, but it can’t write “documentation for users” for you, so I had it draft a version and then reviewed and revised it. The document structure was roughly:
- System requirements (Windows 10/11 64-bit, at least 8GB of memory recommended)
- Installation steps (with screenshots)
- First-use tutorial (how to open the command line, how to run a sample input file)
- FAQ (Chinese-path issues in the UI, handling antivirus false positives)
- Uninstallation instructions
The AI produced the first draft quickly, but it had one obvious problem: it tended to write too much like “technical documentation.” For example, it would write “run cp2k_shell.exe input.inp in cmd,” but the users in my cousin’s lab don’t necessarily even know how to open cmd. So I had the AI revise it: “Press Win+R, type cmd, press Enter, and then…”
This collaboration mode of “AI writes, humans calibrate audience perception” is one of the most valuable uses of Vibe Coding, in my view.
Epilogue: Not Exactly Spectacular, but It Really Solved the Problem
When I sent the packaged installer to my cousin, she installed it, ran her first computational case, and replied: “It’s that simple?”
Yes, it’s that simple, for you it’s “double-click, Next, Finish.” But for me, it was five evenings, dozens of conversations, over a dozen failed compilations before getting it right, and countless error screenshots.
The AI’s role in this was not “writing code for me,” but “helping me break down the problem.” It turned a vague anxiety like “I don’t understand Fortran compilation” into small tasks I could execute step by step: install MSYS2 → install dependency libraries → compile → package → test → fix bugs.
Before, this kind of project would need a full-stack engineer who understood both scientific computing, Windows packaging, and writing installer scripts, with an estimated timeline of two to three weeks. Now, a graduate student who is “willing to describe the problem clearly, willing to paste error logs, and willing to follow AI step by step” can build it in a few evenings.
Vibe Coding isn’t magic. It can’t think for you, can’t debug for you, and certainly can’t guarantee success on the first try. But it lowers the barrier from “you must first become an expert in some field” to “you are willing to spend time working through the problem with AI.”
The significance of this lowered barrier might be more practical than any single benchmark improvement in model capability.
A Few Practical Tips
If you also want to use AI to complete similar “cross-domain toolchain integration” tasks, here are some lessons I’ve summarized after stepping into the traps:
First let AI do a “feasibility assessment,” then let it write code. Don’t start by saying “help me write an installer.” Instead, ask “What steps does this require? What are the potential pitfalls at each step?” The roadmap the AI gives is often more valuable than the code it writes directly.
The more complete the error logs, the better. Don’t just throw “compilation failed” at the AI. Paste the complete stdout/stderr. Compiler error messages may be verbose, but the accuracy of AI extracting key information from them is much higher than your own paraphrasing.
Verify every step. When the AI says “this step is done,” you need to actually run it and see. It might say “in theory this should be fine,” but theory ≠ reality, especially for problems involving specific system environments (DLL version conflicts, Chinese characters in file paths, insufficient permissions, etc.). These are things AI can’t predict; you can only find out by running it.
Make good use of AI’s “role-playing” ability. You can tell it “assume you are a Windows software packaging expert and review my installer script for issues,” or “assume you are a graduate student using CP2K for the first time and see if this installation guide is clear enough.” Switching perspectives often reveals blind spots.
Accept that “rework” is normal. AI doesn’t write correct code on the first try. Eight or nine times out of ten it needs modification, retries, and a change of approach. This isn’t a sign AI is bad; software development itself is full of iterative “get it running first, then optimize” cycles.
Wrapping Up
The biggest takeaway from this process isn’t “I learned how to package a Windows installer,” since that knowledge is all over the internet, but that I verified one thing: when a person has a clear intention, AI can help them turn “I don’t know how to do this” into “I can build it step by step.”
The CP2K installer is done and now sits on the lab’s internal shared drive. New students in my cousin’s group no longer need to wrestle with WSL.
This wish that dragged on for half a year finally came to an end after five evenings.
Not because AI is so powerful, but because I finally got started.
