pateto777
pateto777

Reputation: 249

Reading From OGR error in c++

I'm trying to compile the following code using the gdal libraries in Centos 7:

The name of the file is rungdal.cpp

#include "/usr/include/gdal/ogrsf_frmts.h"
int main(){
    // Register all format drivers
    GDALAllRegister();
}

I run the program using: g++ rungdal.cpp -o rungdal, and I have the following message:

error: ‘GDALAllRegister’ was not declared in this scope

I also include the whole path from the header file, if I don't use it the program doesn't work, maybe it's something related.

What can I do for executing the program?

Thanks for your help!

Upvotes: 0

Views: 471

Answers (1)

pateto777
pateto777

Reputation: 249

I fixed the code with your suggestions:

#include <gdal/gdal.h>

int main(){
    // Register all format drivers
    GDALAllRegister();  
}

In addition, I have to add the line -lgdal for the compilation and it works.

g++ rungdal.cpp -o rungdal -lgdal

Thanks for your help!

Alvaro

Upvotes: 1

Related Questions