Linux C++

1、Gdal

1.1 visual studio 配置

  • 配置属性 > C++目录 > 包含目录: /usr/local/include
  • 配置属性 > C++目录 > 库目录: /usr/local/lib

image-20220410161455225.png

  • 配置属性 > 连接器 > 常规 > 附加库目录: /usr/local/lib

image-20220410161656508.png

  • 配置属性 > 输入 > 库依赖项:gdal
  • image-20220410161859221.png

1.2 链接 Linux

  • 工具 > 选项 > 跨平台 > 连接器管理

image-20220410162057884.png

1.3 测试

  1. #include "gdal_priv.h"
  2. #include <iostream>
  3. using namespace std;
  4. int main()
  5. {
  6. const char* pszFile;
  7. GDALAllRegister();
  8. pszFile = "/home/test.tif";
  9. GDALDataset* poDataset = (GDALDataset*)GDALOpen(pszFile, GA_ReadOnly);
  10. GDALRasterBand* poBand = poDataset->GetRasterBand(1);
  11. int xsize = poBand->GetXSize();
  12. int ysize = poBand->GetYSize();
  13. cout << xsize << endl;
  14. cout << ysize << endl;
  15. return 0;
  16. }