<div dir="ltr"><div><div><div><div><div><div>Hello,<br><br></div>I try to use a simple test program which must use GDAL and netcdf support. This test is for constraints and specifications. Here's this code (main.cpp)<br>
<br>#include "gdal_priv.h"<br>#include "netcdfdataset.h"<br><br>using namespace std;<br><br>int main() {<br><br>   netCDFDataset child;<br><br>}<br><br></div><div><br>For this, I have built GDAL (1.9.2) and netcdf (netcdf-c-4.3.2).<br>
</div><br></div>I have made 2 choices, firstly I built GDAL with the following option for ./configure :<br><br>./configure --prefix=/usr/local/gdal_without_ncdf/ --with-netcdf=no<br><br></div>After copying <b>netcdfdataset.h</b> and <b>netcdfdataset.cpp</b> in the current directory ( from <b>~/gdal-1.9.2/frmts/netcdf/netcdfdataset.h</b> .) and once <b>libgdal.so</b> and <b>libnetcdf.so</b>  are built, I compile <b>the above main.cpp</b> with the following Makefile :<br>
<br># Makefile for test_gdal<br><br>CPP = g++<br>DIR_GDAL = /usr/local/gdal_without_netcdf<br>DIR_NETCDF = /usr/local/netcdf-gcc<br>INCLUDES = -I. -I$(DIR_GDAL)/include <br>LDFLAGS = -L$(DIR_GDAL)/lib -lgdal -L$(DIR_NETCDF)/lib -lnetcdf<br>
RM = rm -f<br><br>all: test_gdal <br><br>test_gdal: main.o netcdfdataset.o<br>    $(CPP) -o $@ $^ $(LDFLAGS)<br><br>%.o:%.cpp<br>    $(CPP) -o $@ -c $< $(INCLUDES)<br><br>clean: <br>    $(RM) test_gdal *.o<br><br></div>
Everything compiles fine for this case.<br><br></div>But now, I tried another option, installing GDAL with a standard way :<br><br>./configure --prefix=/usr/local/gdal_standard_install/<br><div><br></div><div>I have noticed that "netcdf" is set to "yes" after this ./configure<br>
</div><div><br></div><div>So, I copied only netcdfdataset.h (without netcdfdata.cpp) in the current directory for the "#include" of main.cpp and I compile with the following script :<br><br>#!/bin/bash<br><br>GDAL_HOME=/usr/local/gdal_standard_install<br>
<br>g++ -I$GDAL_HOME/include -I. -c main.cpp<br>g++ -L$GDAL_HOME/lib -lgdal main.o -o test_gdal<br><br></div><div>Unfortunately, this compilation works fine only on <b>Debian/wheezy</b>. On <b>RedHat 6</b>, I have the following error :<br>
<br>main.cpp:(.text+0x73): undefined reference to `netCDFDataset::~netCDFDataset()'<br>main.cpp:(.text+0x8c): undefined reference to `netCDFDataset::~netCDFDataset()'<br><br></div><div>I don't understand why I have this error ; However, on <b>RedHat 6</b>, <b>the symbol netCDFDataset</b> appears well with :<br>
<br>$ nm -C /usr/local/gdal_standard_install/lib/libgdal.so | grep -i netcdfdataset<br><br>...<br>00000000003fac70 T netCDFDataset::netCDFDataset()<br>00000000003fac70 T netCDFDataset::netCDFDataset()<br>0000000000405d00 T netCDFDataset::~netCDFDataset()<br>
0000000000405b90 T netCDFDataset::~netCDFDataset()<br>0000000000405b90 T netCDFDataset::~netCDFDataset()<br>...<br><br></div><div>If someone could see what's wrong <br><br></div><div>Thanks<br></div><div><div><div><br>
</div></div></div></div>