I'm new to GDAL and am just learning the inner-workings of C++ compilation at the moment so please bear with me.

I am trying to define a pixel function to produce a VRT from input TIFs, with a band being some computation of other bands, which I can translate into a TIF. Let's say something simple like the min of each band.

The top voted answer here suggests that these functions cannot exist outside the program where they are registered. There is a nice post from the GDAL mailing list which summarises the process which suggests otherwise however. This post indicates that I should be able to build a shared library, and define the GDAL_DRIVER_PATH environment variable to point at the directory containing this. This looks promising, since now a call to gdal_translate on the command-line shows that it's trying to access this library but can't find the GDALRegisterMe or GDALRegister_pixelFunctions function (my library is called gdal_pixelFunctions.so)

$ gdal_translate testVrt.vrt testVrt.tif
ERROR 1: build/gdal_pixelFunctions.so: undefined symbol: GDALRegisterMe
ERROR 1: build/gdal_pixelFunctions.so: undefined symbol: GDALRegister_pixelFunctions
Input file size is 1000, 1000
0ERROR 5: VRTDerivedRasterBand::IRasterIO:Derived band pixel function 'OneFunction' not registered.

My src looks like

CPLErr OneFunction(
    void **papoSources,
    int nSources,
    void *pData,
    int nXSize,
    int nYSize,
    GDALDataType eSrcType,
    GDALDataType eBufType,
    int nPixelSpace,
    int nLineSpace
    // trivial implementation

void GDALRegisterMe()
    GDALAddDerivedBandPixelFunc("OneFunction", OneFunction);

Attempting this on Arch Linux if that helps.


In case this is helpful - This link shows how GDAL tries to load drivers from shared libraries, searching first for the GDALRegister_pixelFunction() function (in this case) and then GDALRegisterMe() if not found, but my shared library seems to be failing to provide these for some reason.

  • I suggest to ask this question from the gdal-dev mailing list because the GDAL C++ developers are there.
    – user30184
    Commented Jan 12, 2021 at 8:20
  • 1
    @user30184 thank you, indeed they were able to quickly point out the issue, posted below
    – mcindoe
    Commented Jan 12, 2021 at 12:50

1 Answer 1


The GDAL developer mailing list helped me resolve - simply add

extern "C" {
    void GDALRegisterMe();

to the top of the src file

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.