2

我对 gdal 有疑问。我目前在 Ubuntu 上工作,IDE 是 Eclipse CDT 我在下面给出了我的代码,我还安装了 gdal 包,但它给出了构建错误

#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");;
    }
}

//////////构建结果/////////////////////////////

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

//////////////////////////////////////

请帮我......

4

0 回答 0