Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I have problem with gdal. I am currently working on Ubuntu and the IDE is Eclipse CDT i have given my code below and i have also installed the gdal package but it gives build errors

#include <stdio.h>
#include<unistd.h>
#include "gdal/gdal_priv.h"
#include "gdal/cpl_conv.h"
#include<gdal/gdal.h>
int main(int argc,char* argv[])
{
    void *hLib_Comm;
    char exePath[800];
    if(getcwd(exePath,sizeof(exePath))== NULL)  {
        printf("Exe path access error\n");
    }
    GDALDataset  *poDataset;

    GDALAllRegister();

    poDataset = (GDALDataset *) GDALOpen( exePath, GA_ReadOnly );
    if( poDataset == NULL )
    {
        printf("Exe path access error\n");
    }
}

///////////Bulid result///////////////////////////////////

14:51:47 **** Build of configuration Debug for project ReadFrmSoFile ****
make all 
Building file: ../main.cpp
Invoking: GCC C++ Compiler
g++ -lm -I/usr/include/gdal -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"main.d" -MT"main.d" -o "main.o" "../main.cpp"
../main.cpp: In function ‘int main(int, char**)’:
../main.cpp:17:8: warning: unused variable ‘hLib_Comm’ [-Wunused-variable]
Finished building: ../main.cpp

Building target: ReadFrmSoFile
Invoking: GCC C++ Linker
g++ -lm -L/usr/lib -L/usr/lib/ogdi -o "ReadFrmSoFile"  ./main.o   -lgdal
./main.o: In function `main':
/media/Local Disk/workspace2/ReadFrmSoFile/Debug/../main.cpp:24: undefined reference to `GDALAllRegister'
/media/Local Disk/workspace2/ReadFrmSoFile/Debug/../main.cpp:26: undefined reference to `GDALOpen'
collect2: ld returned 1 exit status
make: *** [ReadFrmSoFile] Error 1

Help Me.....

share|improve this question

closed as off-topic by guntbert, Thomas W., Braiam, RolandiXor Sep 2 '13 at 16:49

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "This is not about Ubuntu. Questions about other Linux distributions can be asked on Unix & Linux, those about Windows on Super User, those about Apple products on Ask Different and generic programming questions on Stack Overflow." – guntbert, Thomas W., Braiam, RolandiXor
If this question can be reworded to fit the rules in the help center, please edit the question.

1 Answer 1

According to this you don't have the build-essentials package installed. You solve this just running:

sudo apt-get install build-essential

I tried to run your code, but was hit with another problem due some headers dependencies:

gcc gdal.c 
In file included from gdal.c:3:0:
/usr/include/gdal/gdal_priv.h:38:1: error: unknown type name ‘class’
 class GDALMajorObject;
 ^
/usr/include/gdal/gdal_priv.h:39:1: error: unknown type name ‘class’
 class GDALDataset;
 ^
/usr/include/gdal/gdal_priv.h:40:1: error: unknown type name ‘class’
 class GDALRasterBand;
 ^
/usr/include/gdal/gdal_priv.h:41:1: error: unknown type name ‘class’
 class GDALDriver;
 ^
/usr/include/gdal/gdal_priv.h:42:1: error: unknown type name ‘class’
 class GDALRasterAttributeTable;
 ^
/usr/include/gdal/gdal_priv.h:43:1: error: unknown type name ‘class’
 class GDALProxyDataset;
 ^
/usr/include/gdal/gdal_priv.h:44:1: error: unknown type name ‘class’
 class GDALProxyRasterBand;
 ^
/usr/include/gdal/gdal_priv.h:45:1: error: unknown type name ‘class’
 class GDALAsyncReader;
 ^
In file included from gdal.c:3:0:
/usr/include/gdal/gdal_priv.h:59:18: fatal error: vector: No such file or directory
 #include <vector>
                  ^
compilation terminated.
share|improve this answer

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