[gdal-dev] compiling GDAL API with gcc
Norman Vine
nhv at cape.com
Sun Jan 27 13:41:17 EST 2008
Mattia writes:
>
> I installed GDAL by installing FWTools (I currently have it
> under /opt)
> Using Ubuntu 7.10
> For some reason I try to compile :
>
> #include <stdio.h>
> #include "gdal.h"
>
> int main() {
>
> printf("test\n");
>
> GDALAllRegister();
>
> }
>
>
> but get:
>
> /tmp/cc4QzAsI.o: In function `main':
> helloworld.c:(.text+0x1e): undefined reference to `GDALAllRegister'
> collect2: ld returned 1 exit status
This is a linker error not a compiler error
You need to link with libgdal
> the compile command I use is:
>
> gcc -I/opt/FWTools/FWTools2.4.0/include/ helloworld.c
try something like
gcc -I/opt/FWTools/FWTools2.4.0/include/ -L/opt/FWTools/FWTools2.4.0/lib
-lgdal helloworld.c
HTH
Norman
More information about the gdal-dev
mailing list