'not recognized as a supported file format ECW gdal api

I'm trying to use ECW files in my application. I've built GDAL Library whit this command:

./configure --with-ecw:/usr/local/hexagon

after completion of build process, when I Entered:

gdalinfo --formats | grep ECW

I got:

ECW -raster- (rw+): ERDAS Compressed Wavelets (SDK 5.5)
JP2ECW -raster,vector- (rw+v): ERDAS JPEG2000 (SDK 5.5)

also when I've used

gdalinfo map.ecw

it returns all metadata of ECW files. but when I compile my C++ program, it returns:

Error: GDAL Dataset returned null from read

ERROR 4: `map.ecw' not recognized as a supported file format.

Dose anyone know why I can't use ECW files in C++ program?

By the way, I use Cmake ,GDAL 3.3.0 ,Erdas-ECW SDK 5.5 hexagon for building the program.



Solution 1:[1]

I found the answer. This problem occurs if the gdal_bin binary package is installed before creating GDAL. Just make sure gdal_bin is deleted before installing the version you created.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Alireza Rahimi