【问题标题】:Load ecw file using EWS SDK Linux on Mac OS X -> Error link symbol在 Mac OS X 上使用 EWS SDK Linux 加载 ecw 文件 -> 错误链接符号
【发布时间】:2014-02-08 14:22:17
【问题描述】:

所以我想加载 ecw 文件。 我在 Mac OSX 10.9.1 上。

我正在尝试使用这种方法:

//*****************************************************************
//* Lecture d'un fichier ECW dont le nom est passÈ en paramËtre.
//*****************************************************************
int charge_ecw( char *nom_fichier )
 {
 NCSFileView *pNCSFileView;
 NCSFileViewFileInfo    *pNCSFileInfo;

 NCSError eError = NCS_SUCCESS;
 UINT8  **p_p_output_line = NULL;
 UINT8  *p_output_buffer = NULL;
 UINT32 x_size, y_size, number_x, number_y;
 UINT32 start_x, start_y, end_x, end_y;
 UINT32 line;
 UINT32 band;
 UINT32 nBands;
 UINT32 *band_list = NULL;  // list of individual bands to read, may be subset of actual bands

 // Open the input NCSFileView
 eError = NCScbmOpenFileView(nom_fichier, &pNCSFileView, NULL);

 if (eError != NCS_SUCCESS) {
 printf("Could not open view for file:%s\n",nom_fichier);
 printf("Error = %s\n", NCSGetErrorText(eError));
 return(1);
 }
 NCScbmGetViewFileInfo(pNCSFileView, &pNCSFileInfo);
 x_size = pNCSFileInfo->nSizeX;         // Largeur en pixels de l'image ECW
 y_size = pNCSFileInfo->nSizeY;         // Hauteur en pixels de l'image ECW
 nBands = pNCSFileInfo->nBands;         // Nombre de canaux par pixel de l'image ECW (7 pour une image Landsat)
 printf("Input file is [%ld x %ld by %d bands]\n", (long)x_size, (long)y_size, nBands);

 // Have to set up the band list. Compatible with ER Mapper's method.
 // In this example we always request all bands.
 band_list = (UINT32 *) malloc(sizeof(UINT32) * nBands);
 if( !band_list ) {
 printf("Error - unable to malloc band list\n");
 NCScbmCloseFileView(pNCSFileView);
 return(1);
 }
 for( band = 0; band < nBands; band++ )
 band_list[band] = band;

 // On donne les coordonnÈes du coin supÈrieur gauche (start_x,start_y)
 // et du coin infÈrieur droit (end_x,end_y) de la zone qu'on souhaite
 // lire dans l'image source ECW.
 start_x = 0;
 start_y = 0;
 end_x = 799;
 end_y = 599;

 // On donne la largeur (number_x) et la hauteur (number_y) qu'on souhaite
 // pour l'image de destination. Dans cet exemple, le bloc de pixels lu dans
 // l'image source sera donc redimensionnÈ, car il sera rÈduit de 800x600
 // pixels ‡ 400x300 pixels.
 number_x = 400;
 number_y = 300;

 printf("Region : [%d,%d] to [%d,%d] for [%d,%d]\n", start_x, start_y, end_x, end_y, number_x, number_y);

 eError = NCScbmSetFileView(pNCSFileView,
 nBands, band_list,
 start_x, start_y, end_x, end_y,
 number_x, number_y);
 if( eError != NCS_SUCCESS) {
 printf("Error = %s\n", NCSGetErrorText(eError));
 NCScbmCloseFileView(pNCSFileView);
 free(band_list);
 return(1);
 }

 p_output_buffer = (UINT8 *) malloc( sizeof(UINT8) * number_x * nBands);
 p_p_output_line = (UINT8 **) malloc( sizeof(UINT8 *) * nBands);

 if( !p_p_output_line || !p_output_buffer) {
 printf("Malloc error for output buffers\n");
 NCScbmCloseFileView(pNCSFileView);
 free(band_list);
 if( p_p_output_line )
 free((char *) p_p_output_line);
 if( p_output_buffer )
 free((char *) p_output_buffer);
 return(1);
 }

 for(band = 0; band < nBands; band++ )
 p_p_output_line[band] = p_output_buffer + (band * number_x);

 // Read each line of the compressed file
 for( line = 0; line < number_y; line++ ) {
 NCSEcwReadStatus eReadStatus;
 eReadStatus = NCScbmReadViewLineBIL( pNCSFileView, p_p_output_line);
 if (eReadStatus != NCSECW_READ_OK) {
 printf("Read line error at line %d\n",line);
 printf("Status code = %d\n", eReadStatus);
 NCScbmCloseFileView(pNCSFileView);
 free(band_list);
 free((char *) p_p_output_line);
 free((char *) p_output_buffer);
 return(1);
 }

 // ---------------------------------------------------------------------------------------
 // Dans le tableau unidimensionnel p_output_buffer on a les valeurs des pixels d'une ligne
 // dÈcompressÈe de l'image.
 // Dans ce tableau 1D, les unes ‡ la suite des autres, on a tout d'abord les valeurs du
 // 1er canal pour tous les pixels, puis les valeurs du 2Ëme canal pour tous les pixels,
 // puis les valeurs du 3Ëme canal pour tous les pixels, et ainsi de suite.
 // On peut donc ici utiliser les valeurs contenues dans p_output_buffer pour remplir les
 // pixels de la classe Image_ms.
 // ...
 // ...
 // ---------------------------------------------------------------------------------------

 }
 free((char *) p_p_output_line);
 free((char *) p_output_buffer);


 // Make the second argument below TRUE if this is the last view of the file and you
 // want the file closed, otherwise it will be kept open in the cache. This can
 // sometimes be an problem when writing plugins.
 NCScbmCloseFileViewEx(pNCSFileView, FALSE);
 free(band_list);

 return(0);
 }

我包括:

#include "path/Downloads/libecwj2-3.3/Source/include/NCSECWClient.h"
#include "path/Downloads/libecwj2-3.3/Source/include/NCSErrors.h"

但我有一些这样的错误:

error: call to member function 'Add' is ambiguous
                            bRet = a.Add(0,1);

那么,有什么解决办法吗?我想到了一个忘记的选项?还是根本无法使用?

PS:我还没有编译。 我在做:

./configure
make ( here the errors )

【问题讨论】:

  • 在使用 libecwj2-3.3 之前,您是否正确构建和安装了它?看来您刚刚下载了源代码...
  • 你好,当我使用make文件时,似乎有typedef redefinition或error: out-of-line definition of 'Copy' does not match any declaration in 'CNCSJPCBuffer'这样的无限错误,也就是说有4个错误,当我尝试解决它们时,有x 其他错误等..
  • 所以现在我有:../C/NCSEcw/NCSJP2/NCSJPCResolution.cpp:1107:11: error: call to member function 'Add' is ambiguous a.Add(0, 1); ~~^~~
  • 我不知道这个库,但是你如何运行configure 脚本?有哪些选择?编辑您的问题以显示您如何尝试构建它。
  • 我没有使用任何选项.. ./configure then make ( errors )

标签: c++ c linux macos file


【解决方案1】:

您缺少一些链接器标志。可能类似于-lecwj2,我不确定,但它会“-l”加上ECWJ安装的.a文件的名称,减去“lib”前缀。将其作为 GCC/Clang 的参数放在命令行中(如果您使用的是 Xcode,这将隐藏在某个对话框中。)

【讨论】:

  • 谢谢。现在我正在尝试调试库中的一些错误,因为它尚未编译
猜你喜欢
  • 2012-12-12
  • 2013-10-19
  • 1970-01-01
  • 2011-01-04
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-12-14
相关资源
最近更新 更多