How to run modified C++ files

16 views
Skip to first unread message

Panji Brotoisworo

unread,
Aug 20, 2022, 4:38:30 AM8/20/22
to RSGISLib Support
Hi,

I am learning how RSGISLib works and I see that it has a lot of intergration with C++ files. Is there a way to edit the C++ files and compile them so it can run the modified C++ code? I'm mainly going to be adding a lot of stdout so I can see the values.

I installed RSGISLib using conda. Is it possible to just edit the TAR file contents with the modified C++ code then perform an offline installation?

Thanks

Peter Bunting

unread,
Aug 22, 2022, 3:25:46 AM8/22/22
to Panji Brotoisworo, RSGISLib
Hi Panji,

I have a docker image setup for this purpose:

https://github.com/remotesensinginfo/docker_builds/blob/master/rsinfo_rsgislib_build/Dockerfile

However, you can also do locally installing a new conda environment:

# Minimum Install
conda install --yes -c au-eoed -c conda-forge python=3.9 gdal geos gsl kealib xerces-c muparser boost-cpp rios

# With more python dependencies
conda install --yes -c au-eoed -c conda-forge python=3.9 gdal geos gsl kealib xerces-c muparser boost-cpp rios scikit-learn scikit-image scikit-optimize imbalanced-learn scikit-plot scikit-fuzzy bayesian-optimization matplotlib pandas geopandas statsmodels h5py scipy shapely networkx sqlalchemy pycurl xgboost lightgbm seaborn numba pip sphinx rtree tqdm jinja2 keras parallel pygal jupyterlab psutil pysal libpysal esda; sync \


# You’d need to update this path for your conda environment
export CONDA_ENV_PATH=/Users/pete/.conda/envs/rsgislib_v5_dev

# You’d need to update the install path
cmake -D CMAKE_INSTALL_PREFIX=/Users/pete/Temp/rsgislib_v5_dev_install \
-D BOOST_INCLUDE_DIR=$CONDA_ENV_PATH/include \
-D BOOST_LIB_PATH=$CONDA_ENV_PATH/lib \
-D GDAL_INCLUDE_DIR=$CONDA_ENV_PATH/include \
-D GDAL_LIB_PATH=$CONDA_ENV_PATH/lib \
-D HDF5_INCLUDE_DIR=$CONDA_ENV_PATH/include \
-D HDF5_LIB_PATH=$CONDA_ENV_PATH/lib \
-D GSL_INCLUDE_DIR=$CONDA_ENV_PATH/include \
-D GSL_LIB_PATH=$CONDA_ENV_PATH/lib \
-D MUPARSER_INCLUDE_DIR=$CONDA_ENV_PATH/include \
-D MUPARSER_LIB_PATH=$CONDA_ENV_PATH/lib \
-D KEA_INCLUDE_DIR=$CONDA_ENV_PATH/include \
-D KEA_LIB_PATH=$CONDA_ENV_PATH/lib \
-D Python_EXECUTABLE=$CONDA_ENV_PATH/bin/python \
-D Python_INCLUDE_DIR=$CONDA_ENV_PATH/include/python3.9/ \
-D Python_LIBRARY_RELEASE=$CONDA_ENV_PATH/lib/libpython3.9.dylib \
-D CMAKE_VERBOSE_MAKEFILE=ON \
-D CMAKE_BUILD_TYPE=Debug \
-D CMAKE_SKIP_RPATH=ON \
..

To run things you’d need to point python etc. at your local install by exporting the following paths:

export LD_LIBRARY_PATH=/Users/pete/Temp/rsgislib_v5_dev_install/lib:$LD_LIBRARY_PATH
export PYTHONPATH=/Users/pete/Temp/rsgislib_v5_dev_install/lib/python3.9/site-packages:$PYTHONPATH
export PATH=/Users/pete/Temp/rsgislib_v5_dev_install/bin:$PATH

Hope that helps.

Best wishes,

Pete
> --
> You received this message because you are subscribed to the Google Groups "RSGISLib Support" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to rsgislib-suppo...@googlegroups.com.
> To view this discussion on the web, visit https://groups.google.com/d/msgid/rsgislib-support/291f5191-77a5-4fd9-9797-f78c2b15202fn%40googlegroups.com.

Panji Brotoisworo

unread,
Aug 23, 2022, 4:58:25 AM8/23/22
to Peter Bunting, RSGISLib
Thanks Peter.

Just one clarification regarding installing a new local envirobment because my experience is mainly with Python.

If I want to edit the C++ files. Where would I save and compile the files to so that RSGISLib will load them?

Peter Bunting

unread,
Aug 23, 2022, 5:58:04 AM8/23/22
to Panji Brotoisworo, RSGISLib
Hi Panji,

It you don’t have much experience with C++ you might find it quite hard to get into that side of RSGISLib. However, if you edit any of the C++ files you will need to recompile rsgislib and then install it. So once you have run cmake (command below in original email) then you need to run:

# to compile the c++ code the -j switch allow multiple cores to be used for the build, in this case 4.
make -j 4

# install the new rsgislib version (includes all the pure python parts of rsgislib as well)
make install

Depending on where you install it to, as I said in the last email, you might then need to export paths etc. to access the version of rsgislib you have just installed.

Best wishes,

Pete

Panji Brotoisworo

unread,
Aug 25, 2022, 2:00:33 PM8/25/22
to RSGISLib Support
Hi Peter,

Thanks for the detailed response. I will update if I need additional info.

Thanks,
Panji
Reply all
Reply to author
Forward
0 new messages