Posts Tagged ‘ gdal

MB-System and missing link flags

Thanks for the tip, Kurt!!

I guess this is probably a painfully obvious solution to anyone who knows what they’re doing, but it turns out I was missing the link to GDAL in my install_makefiles script. There’s a line in there that looks like this:


$LFLAGS = "-L$NETCDFLIBDIR -lm -lnetcdf";

It should have had a link to GDAL like this:


$LFLAGS = "-L$NETCDFLIBDIR -lm -lnetcdf -lgdal";

So it worked! It ran with no errors, and seemed to build correctly. So one step closer! I then continued along the instructions to setting the .bashrc file. I had left out one line before, so I added it, and then ran:


$ source .bashrc

To test my GMT and MBSystem installs, I tried:


$ psxy
$ man psxy
$ mbgrid
$ man mbgrid

Since I don’t know how to use GMT and MBSystem yet, I don’t know if these did what they were supposed to. But it seemed like they did, except for mbgrid, which came up with an error: “Unable to open data list file: datalist.mb-1“. But at least it recognized mbgrid as a command and tried to do something!

Ah, finally, I’m getting somewhere! :-)

MB-System install

I’m embarrassed to admit that I haven’t even touched MB-System in ages. I had finally succeeded in getting GMT to install without problems, and thought I was in the clear. But, alas, MB-system gave me even more grief. It wasn’t working out for me, and I just haven’t had time to get back to it in months. Now I’m back at it, and here are the problems I’m seeing. Following the instructions on this page, I’m getting more undefined reference errors. And they all seem to be related to GDAL, again:


gmt_customio.c:(.text+0x7cfc): undefined reference to `GDALGetRasterDataType'
/usr/local/GMT452/lib/libgmt.a(gmt_customio.o): In function `.L1109':
gmt_customio.c:(.text+0x7e20): undefined reference to `GDALGetRasterBand'
gmt_customio.c:(.text+0x7e2a): undefined reference to `GDALGetRasterDataType'
gmt_customio.c:(.text+0x7e94): undefined reference to `GDALRasterIO'
gmt_customio.c:(.text+0x7ea6): undefined reference to `GDALGetRasterNoDataValue'
gmt_customio.c:(.text+0x7ee0): undefined reference to `GDALGetRasterDataType'
gmt_customio.c:(.text+0x7f73): undefined reference to `OSRNewSpatialReference'
gmt_customio.c:(.text+0x7f8a): undefined reference to `OSRImportFromProj4'
gmt_customio.c:(.text+0x7fd3): undefined reference to `OSRDestroySpatialReference'
/usr/local/GMT452/lib/libgmt.a(gmt_customio.o): In function `.L1129':
gmt_customio.c:(.text+0x8158): undefined reference to `GDALClose'
/usr/local/GMT452/lib/libgmt.a(gmt_customio.o): In function `.L1134':
gmt_customio.c:(.text+0x8826): undefined reference to `OSRExportToPrettyWkt'
/usr/local/GMT452/lib/libgmt.a(gmt_customio.o): In function `.L1110':
gmt_customio.c:(.text+0x8a3e): undefined reference to `GDALGetRasterBand'
gmt_customio.c:(.text+0x8e3e): undefined reference to `GDALGetRasterXSize'
gmt_customio.c:(.text+0x8e5d): undefined reference to `GDALGetRasterYSize'
gmt_customio.c:(.text+0x8e81): undefined reference to `GDALGetRasterYSize'
gmt_customio.c:(.text+0x8e91): undefined reference to `GDALGetRasterXSize'
gmt_customio.c:(.text+0x8f23): undefined reference to `GDALClose'
gmt_customio.c:(.text+0x8f28): undefined reference to `GDALDestroyDriverManager'
gmt_customio.c:(.text+0x8f35): undefined reference to `CPLGetLastErrorMsg'
collect2: ld returned 1 exit status
make[2]: *** [../../bin/mbprocess] Error 1
make[2]: Leaving directory `/home/michelle/Documents/mbsystem-5.1.2/src/utilities'
make[1]: *** [all] Error 2
make[1]: Leaving directory `/home/michelle/Documents/mbsystem-5.1.2/src'
make: *** [all] Error 2

When I was installing GMT, I was also getting undefined reference errors, but I never did figure out what was wrong. It just worked all of a sudden. I think I attributed it to a reboot because I coudn’t figure out what else I had done differently. This time, rebooting does not result in any magical fixes.

GDAL and GMT – Success (this time for real)

Well.  I honestly am not sure what fixed my problems, but the good news is, the GMT install went smoothly, and I now have a fully functional GMT + GDAL install.  And I’m ready for MB-System!

So I basically sat down tonight, for the first time in ages, prepared to dig into GMT/GDAL again, armed with advice from both Kurt and Monica on how I might fix things. (or at least begin a fruitful investigation into why it wasn’t working). So to get back up to speed, I wanted to display the errors that I’d been seeing before. The problems would arise when I tried installing GMT using the command

sudo sh install_gmt GMTparam.txt

Where GMTparam.txt is the input file that I carefully prepared on the GMT download site. I was previously getting all sorts of errors telling me that all of my GDAL functions were undefined. I ran the GMT installer again, and, lo and behold, it just worked. I suspect it had something to do with me rebooting the system. Is it possible that I hadn’t rebooted after my last GDAL re-install? Maybe. And maybe it needed to reboot to recognize the changes? I’m not sure. But I’m happy that I can finally move on. It feels good.

Back from Peru!

Hey – it’s been a while…but I’m back from Peru, ready to jump back on the Linux/Ubuntu/Python/GMT/MBsystem train – especially since I’ve gotten some tips in the meantime that will hopefully get me back on track with the issues I was having.  (I’m talking about you, GDAL! Thanks Kurt and Monica for your help!)

Happy Pi day, everyone!

Installing packages from source in Ubuntu

I just found these instructions in the Ubuntu documentation:

Compiling Software

I can’t believe I hadn’t read this before, it explains several things I didn’t know. To start with, it recommends installing the following packages using “apt-get install”:

build-essential
automake
checkinstall

I already had build-essential, and I went ahead and got the other two. I knew that the first step was to run the configure script, using “./configure”. But I didn’t realize this is the script that will define where the software gets installed (ie. the lib and include directories).  To see the options for a configure script, use the command <code>./configure –help</code>

Then there’s the make command, which is used to compile the code.

The part that was really different was using “checkinstall” – I have been using “make install”. Using checkinstall actually creates a .deb file, which makes removing the package later on much easier.  If I ever want to remove it later, I just have to use the command dpkg -r gdal171.

So, this is all good, I think I learned some things, but I am *still* getting the same errors when I try to install MB-System – undefined references to anything related to GDAL.

Organizing installed software in Ubuntu

After trying for quite some time now to install MB-System and GMT, I’ve decided to make an effort to organize my file system a bit. So far – not really knowing any better – I have been installing my software in all kinds of different places, basically in whichever folder it ended up, based on mish-mashing instructions that I only half understood from different forums, etc. Figuring out how to build software from source has been a bit frustrating, since I don’t really know enough to have very effective troubleshooting skills. This is a small step, but I’ve been putting my installed software all into my /usr/local/ directory. So I now have:
/usr/local/GMT452
/usr/local/mbsystem512
/usr/local/netcdf363

I then had to change the references for this software in my .bashrc file:
export PATH=$PATH:/usr/local/GMT452/bin:/usr/local/GMT452/src:/usr/local/GMT452
MANPATH=/usr/local/GMT452/man
export NETCDFHOME=/usr/local/netcdf363
export GDAL_INC=/usr/include
export GDAL_LIB=/usr/lib
export GMTLIBDIR=/usr/local/GMT452/lib
export GMTHOME=/usr/local/GMT452
export MGD77_HOME=/usr/local/GMT452/share/mgd77
export X2SYS_HOME=/usr/local/GMT452/share/x2sys
export MBSYSTEM_HOME=/usr/local/mbsystem512

The only one that I didn’t change was the GDAL install, because I don’t really know why the include and lib directories went where they did, so I don’t want to make any changes. (although maybe I should since it’s the one thing that is still giving me trouble).