0

I aim to compile gdal cpp files as a mini-stage of compiling a hydrological model. To do so, on Ubuntu, I installed Intel OneAPI base toolkit. Using its compiler, icpx, I tried to compile gdal cpp files. However, it throws errors related of not finding header files and reading needed classes from these headers. All headers are included in the cpp file, and they are exactly in the same directory of the cpp file. Any help would be so much appreciated.

 icpx /media/sf_Share/IMWEBsModel/imwebs_Linux/WetSpaInterface2/gdal/gdal-3.3.0/port/cpl_error.cpp -Imedia/sf_Share/IMWEBsModel/imwebs_Linux/WetSpaInterface2/gdal/gdal-3.3.0/port '''

Error:

media/sf_Share/IMWEBsModel/imwebs_Linux/WetSpaInterface2/gdal/gdal-3.3.0/port/cpl_error.cpp:1341:17: error: use of undeclared identifier 'CPLErrorHandlerAccumulatorStruct'; did you mean 'CPLErrorHandlerAccumulator'?
    std::vector<CPLErrorHandlerAccumulatorStruct>* paoErrors =
                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                CPLErrorHandlerAccumulator
/media/sf_Share/IMWEBsModel/imwebs_Linux/WetSpaInterface2/gdal/gdal-3.3.0/port/cpl_error.cpp:1338:18: note: 'CPLErrorHandlerAccumulator' declared here
void CPL_STDCALL CPLErrorHandlerAccumulator( CPLErr eErr, CPLErrorNum no,
                 ^
/media/sf_Share/IMWEBsModel/imwebs_Linux/WetSpaInterface2/gdal/gdal-3.3.0/port/cpl_error.cpp:1341:52: error: use of undeclared identifier 'paoErrors'
    std::vector<CPLErrorHandlerAccumulatorStruct>* paoErrors =
                                                   ^
/media/sf_Share/IMWEBsModel/imwebs_Linux/WetSpaInterface2/gdal/gdal-3.3.0/port/cpl_error.cpp:1342:26: error: no template named 'vector' in namespace 'std'
        static_cast<std::vector<CPLErrorHandlerAccumulatorStruct> *>(
                    ~~~~~^
/media/sf_Share/IMWEBsModel/imwebs_Linux/WetSpaInterface2/gdal/gdal-3.3.0/port/cpl_error.cpp:1342:33: error: use of undeclared identifier 'CPLErrorHandlerAccumulatorStruct'; did you mean 'CPLErrorHandlerAccumulator'?
        static_cast<std::vector<CPLErrorHandlerAccumulatorStruct> *>(
                                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                                CPLErrorHandlerAccumulator
/media/sf_Share/IMWEBsModel/imwebs_Linux/WetSpaInterface2/gdal/gdal-3.3.0/port/cpl_error.cpp:1338:18: note: 'CPLErrorHandlerAccumulator' declared here
void CPL_STDCALL CPLErrorHandlerAccumulator( CPLErr eErr, CPLErrorNum no,
                 ^
/media/sf_Share/IMWEBsModel/imwebs_Linux/WetSpaInterface2/gdal/gdal-3.3.0/port/cpl_error.cpp:1344:5: error: use of undeclared identifier 'paoErrors'
    paoErrors->push_back(CPLErrorHandlerAccumulatorStruct(eErr, no, msg));
    ^
/media/sf_Share/IMWEBsModel/imwebs_Linux/WetSpaInterface2/gdal/gdal-3.3.0/port/cpl_error.cpp:1344:26: error: use of undeclared identifier 'CPLErrorHandlerAccumulatorStruct'; did you mean 'CPLErrorHandlerAccumulator'?
    paoErrors->push_back(CPLErrorHandlerAccumulatorStruct(eErr, no, msg));
                         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                         CPLErrorHandlerAccumulator
/media/sf_Share/IMWEBsModel/imwebs_Linux/WetSpaInterface2/gdal/gdal-3.3.0/port/cpl_error.cpp:1338:18: note: 'CPLErrorHandlerAccumulator' declared here
void CPL_STDCALL CPLErrorHandlerAccumulator( CPLErr eErr, CPLErrorNum no,
                 ^
/media/sf_Share/IMWEBsModel/imwebs_Linux/WetSpaInterface2/gdal/gdal-3.3.0/port/cpl_error.cpp:1348:6: error: variable has incomplete type 'void'
void CPLInstallErrorHandlerAccumulator(std::vector<CPLErrorHandlerAccumulatorStruct>& aoErrors)
     ^
/media/sf_Share/IMWEBsModel/imwebs_Linux/WetSpaInterface2/gdal/gdal-3.3.0/port/cpl_error.cpp:1348:45: error: no member named 'vector' in namespace 'std'
void CPLInstallErrorHandlerAccumulator(std::vector<CPLErrorHandlerAccumulatorStruct>& aoErrors)
                                       ~~~~~^
/media/sf_Share/IMWEBsModel/imwebs_Linux/WetSpaInterface2/gdal/gdal-3.3.0/port/cpl_error.cpp:1348:52: error: use of undeclared identifier 'CPLErrorHandlerAccumulatorStruct'; did you mean 'CPLErrorHandlerAccumulator'?
void CPLInstallErrorHandlerAccumulator(std::vector<CPLErrorHandlerAccumulatorStruct>& aoErrors)
                                                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                                                   CPLErrorHandlerAccumulator
/media/sf_Share/IMWEBsModel/imwebs_Linux/WetSpaInterface2/gdal/gdal-3.3.0/port/cpl_error.cpp:1338:18: note: 'CPLErrorHandlerAccumulator' declared here
void CPL_STDCALL CPLErrorHandlerAccumulator( CPLErr eErr, CPLErrorNum no,
                 ^
/media/sf_Share/IMWEBsModel/imwebs_Linux/WetSpaInterface2/gdal/gdal-3.3.0/port/cpl_error.cpp:1348:87: error: use of undeclared identifier 'aoErrors'
void CPLInstallErrorHandlerAccumulator(std::vector<CPLErrorHandlerAccumulatorStruct>& aoErrors)
                                                                                      ^
/media/sf_Share/IMWEBsModel/imwebs_Linux/WetSpaInterface2/gdal/gdal-3.3.0/port/cpl_error.cpp:1348:96: error: expected ';' after top level declarator
void CPLInstallErrorHandlerAccumulator(std::vector<CPLErrorHandlerAccumulatorStruct>& aoErrors)
                                                                                               ^
                                                                                               ;
12 errors generated.
'''

UPDATE: For more clarification: The main cpp program has the following class:

static
void CPL_STDCALL CPLErrorHandlerAccumulator( CPLErr eErr, CPLErrorNum no,
                                              const char* msg )
{
    std::vector<CPLErrorHandlerAccumulatorStruct>* paoErrors =
        static_cast<std::vector<CPLErrorHandlerAccumulatorStruct> *>(
            CPLGetErrorHandlerUserData());
    paoErrors->push_back(CPLErrorHandlerAccumulatorStruct(eErr, no, msg));
}


void CPLInstallErrorHandlerAccumulator(std::vector<CPLErrorHandlerAccumulatorStruct>& aoErrors)
{
    CPLPushErrorHandlerEx( CPLErrorHandlerAccumulator, &aoErrors );
}

void CPLUninstallErrorHandlerAccumulator()
{
    CPLPopErrorHandler();
}

Inside this class it tries to call CPLErrorHandlerAccumulatorStruct which is another class in the header file called cpl_error_internal , which is included in the main cpp file at the beginning of it -->

#include "cpl_error_internal.h"

The problem I guess is that the main program cannot find the header! while 1) it's included 2) the directory has no problem.

  • It looks you are using `CPLErrorHandlerAccumulator*Struct*` instead of `CPLErrorHandlerAccumulator`, and that you are missing an `#include `. At least. – rturrado Jun 23 '21 at 14:26
  • You are also missing a `;` at the end of line `cpl_error.cpp:1348`. The rest of the errors should be solved fixing these 3. – rturrado Jun 23 '21 at 14:28
  • @rturrado thank you so much, can you see the update? – user1268890 Jun 23 '21 at 14:39
  • Hmm... I think that second line `include ` shouldn't be there. If `CPLErrorHandlerAccumulatorStruct` actually exists, and you want to use it in a cpp file, you need to know in which header it is declared (probably `cpl_error_internal.h`) and `#include "cpl_error_internal.h"` in the cpp file. – rturrado Jun 23 '21 at 14:46
  • @rturrado Thank you! I deleted but no changes in errors – user1268890 Jun 23 '21 at 15:28

1 Answers1

0

I think you did not configure the gdal properly. Before compiling the code try configuring gdal by using ./configure command in the gdal home directory After doing that make the port directory correctly as the errors related to undeclared identifiers to "paoErrors" etc appear if you have not configured it properly and instead just try to compile the files in the 'port' directory.