Please find attached the code and associated error after compilation... gcc -o test imagescale.cpp -I /usr/include/gdal -lgdal /usr/bin/ld: /tmp/ccrySeCX.o: undefined reference to symbol 'floor@ @GLIBC_2.2.5' //lib/x86_64-linux-gnu/libm.so.6: error adding symbols: DSO missing from command line collect2: error: ld returned 1 exit status
On Mon, Nov 3, 2014 at 1:41 PM, Johan Van de Wauw <johan.vandew...@gmail.com > wrote: > Please include the error. And possibly also the file if it is no > secret, will help you get a much better answer. > > Johan > > BTW: keep the ubuntugis list in cc, other people may benefit from > reading how we solved your problem. > > On Mon, Nov 3, 2014 at 9:39 PM, alassane toure <atou...@gmail.com> wrote: > > Hi Johan, > > I am not a sophisticated user of gdal. I am looking for the easiest way > to > > have the compiler running. As such, I followed your instruction by > running > > the version included in ubuntu "sudo apt-get install libgdal-dev" but the > > compilation of the program test.cpp did not work. This issue started > when i > > install the latest ubuntu version. > > > > Again, thanks for your insight! > > > > On Mon, Nov 3, 2014 at 1:26 PM, Johan Van de Wauw > > <johan.vandew...@gmail.com> wrote: > >> > >> Hello Alassane, > >> > >> First of all, you should tell us what you actually want to achieve. > >> You may be better of using the gdal libraries which are already part > >> of ubuntu rather than compiling your own version. > >> > >> If you want to use the version of gdal included in ubuntu install the > >> package libgdal-dev . You can do so using your favorite package > >> manager or using the command prompt: sudo apt-get install libgdal-dev > >> > >> If you do that your command will probably work without extra effort. > >> > >> If there is a good reason to install your own version, you can still > >> do so, but you should be aware that you are probably installing to > >> /usr/local instead of /usr. > >> > >> In that case you should adjust for the include: > >> gcc -o test test.cpp -I /usr/local/include/gdal -lgdal > >> > >> adjusting the linking is slightly more work.try running ldconfig (as > >> root so sudo ldconfig) first after the installation. If that does not > >> work make sure that the directory /usr/local/lib is part of > >> /etc/ld.so.conf and run ldconfig again. > >> > >> Johan > >> > >> Johan > >> > >> On Mon, Nov 3, 2014 at 9:12 PM, alassane toure <atou...@gmail.com> > wrote: > >> > I was able to run it successfully but the following command did not > >> > work.. > >> > gcc -o test test.cpp -I /usr/include/gdal -lgdal > >> > > >> > Any thoughts? > >> > Thanks, > >> > > >> > On Mon, Nov 3, 2014 at 12:24 PM, Johan Van de Wauw > >> > <johan.vandew...@gmail.com> wrote: > >> >> > >> >> On ubuntu, run "sudo make install" > >> >> > >> >> Alternatively, you may wait a few days until gdal 1.11.1 hits > >> >> ubuntugis-unstable. > >> >> > >> >> Johan > >> >> > >> >> On Mon, Nov 3, 2014 at 8:11 PM, alassane toure <atou...@gmail.com> > >> >> wrote: > >> >> > Group, > >> >> > I downloaded the gdal version 1.11.1 and followed instructions > >> >> > provided > >> >> > in > >> >> > http://trac.osgeo.org/gdal/wiki/BuildingOnUnix > >> >> > > >> >> > % cd gdal > >> >> > % ./configure > >> >> > % make > >> >> > % su > >> >> > Password: ******** > >> >> > # make install > >> >> > # exit > >> >> > > >> >> > All went well but without a 'su' credential, I was unable to > complete > >> >> > the > >> >> > installation. > >> >> > I am running windows and unix on the same machine with the same > >> >> > access > >> >> > username and password. Do i need to create a su account > >> >> > > >> >> > or is there another way to have the gdal compiler working again? > >> >> > > >> >> > I appreciate your help > >> >> > > >> >> > Regards, > >> >> > Alassane > >> >> > > >> >> > > >> >> > > >> >> > On Thu, May 24, 2012 at 1:16 PM, Alassane Toure <atou...@gmail.com > > > >> >> > wrote: > >> >> >> > >> >> >> Group, > >> >> >> I need help to install GDAL 1.9.1 on Ubuntu 12.04. I first > >> >> >> downloaded > >> >> >> gdal-1.9.1.tar.gz, uncompressed it and executed ./configure. > Where > >> >> >> do > >> >> >> I go > >> >> >> from here? > >> >> >> > >> >> >> Thanks for your help > >> >> > > >> >> > > >> >> > > >> >> > _______________________________________________ > >> >> > UbuntuGIS mailing list > >> >> > Ubuntu@lists.osgeo.org > >> >> > http://lists.osgeo.org/mailman/listinfo/ubuntu > >> >> > http://trac.osgeo.org/ubuntugis/wiki > >> > > >> > > > > > >
#include <stdio.h> #include "gdal_priv.h" #include "cpl_conv.h" // for CPLMalloc() #include "cpl_string.h" int main ( int argc, char *argv[] ) { GDALDataset *inDataset,*outDataset; GDALDriver *poDriver; GDALRasterBand *RedBand, *NIRBand,*outBand; double adfGeoTransform[6]; const char *pszFormat = "GTiff"; char **papszOptions = NULL; char *inFilename, *outFilename; float *RedScanline, *NIRScanline, *outScanline; int nXSize, nYSize, iLine, iX; GDALAllRegister(); if ( argc != 3 ) /* argc should be 3 for correct execution */ { /* We print argv[0] assuming it is the program name */ printf( "usage: %s inputfilename outputfilename", argv[0] ); } else { // inFilename = "/home/alassane/Documents/nps.TIF"; inFilename = argv[1]; outFilename = argv[2]; // outFilename = "/home/alassane/Documents/out.tif"; inDataset = (GDALDataset *) GDALOpen( inFilename, GA_ReadOnly ); RedBand = inDataset->GetRasterBand( 3 ); NIRBand = inDataset->GetRasterBand( 4 ); nXSize = RedBand->GetXSize(); nYSize = RedBand->GetYSize(); if( inDataset->GetProjectionRef() != NULL ) printf( "Projection is `%s'\n", inDataset->GetProjectionRef() ); RedScanline = (float *) CPLMalloc(sizeof(float)*nXSize); NIRScanline = (float *) CPLMalloc(sizeof(float)*nXSize); outScanline = (float *) CPLMalloc(sizeof(float)*nXSize); poDriver = GetGDALDriverManager()->GetDriverByName(pszFormat); outDataset = poDriver->Create( outFilename, nXSize, nYSize, 1, GDT_Byte, papszOptions ); outBand = outDataset->GetRasterBand( 1 ); inDataset->GetGeoTransform( adfGeoTransform ); outDataset->SetGeoTransform( adfGeoTransform ); outDataset->SetProjection( inDataset->GetProjectionRef() ); for( iLine = 0; iLine < nYSize; iLine++ ) { // printf( "line # is %d\n", iLine); RedBand->RasterIO( GF_Read, 0, iLine,nXSize, 1, RedScanline, nXSize, 1, GDT_Float32,0, 0 ); NIRBand->RasterIO( GF_Read, 0, iLine,nXSize, 1, NIRScanline, nXSize, 1, GDT_Float32,0, 0 ); for( iX = 0; iX < nXSize; iX++ ) { // printf( "pixel# is %d\n", iX); if (NIRScanline[iX] == 0 && RedScanline[iX] == 0) { outScanline[iX] = 0; } else { outScanline[iX]=100*( NIRScanline[iX] - RedScanline[iX] )/( NIRScanline[iX] + RedScanline[iX] ); /* Binning veg index in 10 bins or 10% bins */ if (outScanline[iX] <=0) { outScanline[iX] =0; } else if (outScanline[iX] >100) { outScanline[iX] =11; } else { outScanline[iX] =floor(outScanline[iX]/10)+1; } /************ End of binning ***************/ } } outBand->RasterIO( GF_Write, 0, iLine,nXSize, 1, outScanline, nXSize, 1, GDT_Float32,0, 0 ); // outBand->RasterIO( GF_Write, 0, iLine,nXSize, 1, outScanline, nXSize, 1, GDT_Byte,0, 0 ); } CPLFree( RedScanline ); CPLFree( NIRScanline ); CPLFree( outScanline ); GDALClose( inDataset ); GDALClose( outDataset ); } }
_______________________________________________ UbuntuGIS mailing list Ubuntu@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/ubuntu http://trac.osgeo.org/ubuntugis/wiki