简体   繁体   English

在Mac OS X上使用EWS SDK Linux加载ecw文件->错误链接符号

[英]Load ecw file using EWS SDK Linux on Mac OS X -> Error link symbol

So I want to load ecw file. 所以我想加载ecw文件。 I'm on Mac OSX 10.9.1. 我在Mac OSX 10.9.1上。

I'm trying to do it using this method : 我正在尝试使用此方法:

//*****************************************************************
//* 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);
 }

I'm including : 我包括:

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

But I have some errors like this : 但是我有一些这样的错误:

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

So, is there any solution ? 那么,有什么解决方案吗? I thought about a forgot options ? 我想到了忘记的选择? Or simply impossible use ? 还是根本无法使用?

PS : I hadn't compiled yet. PS:我还没有编译。 I'm doing : 我正在做 :

./configure
make ( here the errors )

You are missing some linker flags. 您缺少一些链接器标志。 Probably something like -lecwj2, I'm not sure, but it will "-l" plus the name of the .a file installed by ECWJ, minus the "lib" prefix. 我不确定-lecwj2之类的东西,但是它将是“ -l”加上ECWJ安装的.a文件的名称,减去“ lib”前缀。 Put this as arguments to GCC/Clang on the command line (If you're using Xcode, this will be buried in a dialog somewhere.) 在命令行上将其作为GCC / Clang的参数(如果您使用的是Xcode,它将被埋在对话框中的某个位置。)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM