Skip to content

[WIP] CMake HOW-TOs and Known Issues #5192

Open
@HuidaeCho

Description

@HuidaeCho

Building on Windows

  1. Install Visual Studio Community Edition. Select these two components:
    • MSVC v143 - VS 2022 C++ x64/x86 build tools (Latest)
    • Windows 11 SDK (10.0.26100.0)
  2. Install Git for Windows
  3. Install Miniconda
curl -O https://repo.anaconda.com/miniconda/Miniconda3-latest-Windows-x86_64.exe
mkdir C:\opt
Miniconda3-latest-Windows-x86_64.exe /S /D=C:\opt\miniconda
C:\opt\miniconda\condabin\conda.bat init
  1. Start Developer Command Prompt for VS 2022
  2. Setup Conda for GRASS build
conda config --add channels conda-forge
conda config --set channel_priority strict
conda create -n grass cmake pkg-config winflexbison proj libgdal pcre fftw openblas pdal wxpython pywin32
  1. Download the source code
cd \opt
git clone git@github.com:OSGeo/grass.git
cd grass
  1. Build GRASS
conda activate grass

mkdir build
cd build
cmake .. -DWITH_OPENGL=OFF > cmake.log 2>&1
msbuild grass.sln -p:Configuration=Release > msbuild.log 2>&1
  1. Run GRASS
set GRASS_BUILD=C:\opt\grass\build
set GISBASE=%GRASS_BUILD%\output\lib\grass85
set PATH=%GISBASE%\bin;%GISBASE%\lib;%PATH%
set GISRC=%GISBASE%\demolocation\.grassrc85

g.proj -p

Yes, g.gui doesn't work yet...

Alternatively, rename grass.py to grass85.py just once to avoid a problem with import grass:

ren output\bin\grass.py grass85.py

and

python output\bin\grass85.py output\lib\grass85\demolocation\PERMANENT

Building on Linux

  1. Install Miniconda
wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh
chmod a+x Miniconda3-latest-Linux-x86_64.sh
mkdir ~/opt
./Miniconda3-latest-Linux-x86_64.sh -b -u -p ~/opt/miniconda
~/opt/miniconda/bin/conda init
. ~/.bashrc
  1. Setup Conda for GRASS build
conda config --add channels conda-forge
conda config --set channel_priority strict
conda create -n grass git cmake pkg-config make gcc gxx flex bison proj gdal xorg-libx11 xorg-xproto libopengl libgl-devel cairo postgresql gettext fftw openblas pdal libglu wxpython
  1. Download the source code
cd ~/opt
git clone [email protected]:OSGeo/grass.git
cd grass
  1. Build GRASS
conda activate grass

# create a missing symlink to libOpenGL.so
ln -sf $CONDA_PREFIX/lib/libOpenGL.so.0 $CONDA_PREFIX/lib/libOpenGL.so

mkdir build
cd build

# LD_LIBRARY_PATH=$CONDA_PREFIX/lib, PKG_CONFIG_PATH=, and -DCMAKE_PREFIX_PATH=$CONDA_PREFIX to avoid system libraries
LD_LIBRARY_PATH=$CONDA_PREFIX/lib PKG_CONFIG_PATH= cmake .. -DCMAKE_PREFIX_PATH=$CONDA_PREFIX -DIconv_IS_BUILT_IN=FALSE &> cmake.log
make -j$(nproc) &> make.log
  1. Run GRASS
./output/bin/grass

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions