-
Notifications
You must be signed in to change notification settings - Fork 9
Developer notes
Thomas Nipen edited this page Jun 15, 2021
·
3 revisions
To build the python package, you should just need to run "make install-python-user". This basically does the following
- compiles the C++ code into .o files (CMakeFiles/titanlib.dir/src/*.cpp.o)
- runs SWIG on the titanlib.h file, which creates the autogenerated file CMakeFiles/_titanlib.dir/titanlibPYTHON_wrap.cxx as well as the python module file extras/SWIG/python/titanlib.py
- links the titanlibPYTHON_wrap.cxx with the C++ .o files from 1) producing _titanlib.so
_titanlib.so together with titanlib.py is a fully functioning python package that gets installed into your python environment (probably ~/.local/lib/python*/site-packages/ if on linux).
Importing the titanlib package in python can sometimes give a segmentation fault. This typically happens if there is a function declaration in titanlib.h that is not defined in any of the .cpp files. Two common reasons are:
- After added a new .cpp file, cmake must be rerun so that the makefile knows of its existence.
- The new function declaration in titanlib.h doesn't match exactly the definition in a .cpp file (e.g. the input arguments differ). To find undefined functions, use something like
nm build/extras/SWIG/python/_titanlib.so | c++filt | grep " U " | grep "titanlib"
Copyright © 2019-2023 Norwegian Meteorological Institute