markdown · 1376 bytes Raw Blame History

Sniffly Development Notes

2025-11-04: gtk-fortran Installation on macOS ARM64

Issue

gtk-fortran doesn't build cleanly on Apple Silicon (M2) due to c_long_double type not supported by gfortran on ARM64.

Solution

  1. Install dependencies:

    brew install meson ninja gfortran gtk4 pkg-config cmake
    
  2. Clone and patch gtk-fortran:

    cd ~/Downloads
    git clone https://github.com/vmagnin/gtk-fortran.git
    cd gtk-fortran
    
  3. Patch src/glib-auto.f90 to comment out c_long_double usage:

    • Lines 5832-5845: Comment out g_assertion_message_cmpnum subroutine
    • This function is rarely used and not needed for Sniffly
    • Patched file saved as glib-auto.f90.patched for reference
  4. Build with explicit flags to avoid ARM march issues:

    FC=gfortran cmake -B build \
      -DCMAKE_BUILD_TYPE=Release \
      -DEXCLUDE_PLPLOT=true \
      -DCMAKE_Fortran_FLAGS_RELEASE="-O3"
    
    cmake --build build
    sudo cmake --install build
    
  5. Verify installation:

    pkg-config --modversion gtk-4-fortran
    # Should output: 4.8.0
    

Result

gtk-fortran 4.8.0 installed successfully at /usr/local/lib

References

View source
1 # Sniffly Development Notes
2
3 ## 2025-11-04: gtk-fortran Installation on macOS ARM64
4
5 ### Issue
6 gtk-fortran doesn't build cleanly on Apple Silicon (M2) due to `c_long_double` type not supported by gfortran on ARM64.
7
8 ### Solution
9 1. Install dependencies:
10 ```bash
11 brew install meson ninja gfortran gtk4 pkg-config cmake
12 ```
13
14 2. Clone and patch gtk-fortran:
15 ```bash
16 cd ~/Downloads
17 git clone https://github.com/vmagnin/gtk-fortran.git
18 cd gtk-fortran
19 ```
20
21 3. Patch `src/glib-auto.f90` to comment out `c_long_double` usage:
22 - Lines 5832-5845: Comment out `g_assertion_message_cmpnum` subroutine
23 - This function is rarely used and not needed for Sniffly
24 - Patched file saved as `glib-auto.f90.patched` for reference
25
26 4. Build with explicit flags to avoid ARM march issues:
27 ```bash
28 FC=gfortran cmake -B build \
29 -DCMAKE_BUILD_TYPE=Release \
30 -DEXCLUDE_PLPLOT=true \
31 -DCMAKE_Fortran_FLAGS_RELEASE="-O3"
32
33 cmake --build build
34 sudo cmake --install build
35 ```
36
37 5. Verify installation:
38 ```bash
39 pkg-config --modversion gtk-4-fortran
40 # Should output: 4.8.0
41 ```
42
43 ### Result
44 gtk-fortran 4.8.0 installed successfully at `/usr/local/lib`
45
46 ### References
47 - gtk-fortran repo: https://github.com/vmagnin/gtk-fortran
48 - Issue tracker: Known ARM64 compatibility issue
49 - Patched file: See `glib-auto.f90.patched` in this directory