Posts Tagged ‘ GMT

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.

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).

Another attempt at installing GMT and MB-System

After getting some advice from Monica I felt I was ready to attempt installing GMT and MB-System again.  It looks like my problems might have been due to some incorrect path names.  My install_gmt script keeps crashing in the same place – at the part where it looks for GDAL files (ie gdal.h, and others).  I think it assumes that GMT lib and include subdirectories are under the same folder.  This doesn’t seem to be the case when I used the default Synaptic install.  So I uninstalled it, and am trying to install from source.

I grabbed the tar file from here:
http://download.osgeo.org/gdal/gdal-1.7.1.tar.gz

I extracted it, navigated to that directory in a terminal window, and ran the following commands:
./configure
make
sudo make install

Summarizing what these do:
./configure: checks for required dependencies, reports an error is they’re not there
make: compiles the source code
make install: installs the program

This time, my GDAL lib and include directories were put into /usr/local. Unfortunately, they are also still in the previous location, and I think I will need to manually remove them.

I added a couple of things to my .bashrc environmental variables – including the MANPATH, and the NETCDF path.

Next – installing MB-System! Finally!

First I installed the following packages using apt-get install:
xorg-dev
libmotif-dev
libxp-dev
mesa-common-dev
libsdl1.2-dev
libsdl-image1.2-dev

Downloaded the MB-System.tar.gz file from the ftp site.

…to be continued

Installing GMT

(Warning: This is a long, and probably confusing post. Read at your own risk!)

My life for the last 7 years has basically revolved around oceans and maps in one way or another.  Since I’m now trying to embrace the wonderful world of open source, I thought it would be a good idea to combine my passions and finally figure out GMT and MB System.  I thought this tutorial on installing MB-System on Ubuntu would be helpful, but I was doing something wrong and couldn’t even get past the very first step.

So the way it works is that on the GMT home page, you can use a form to automatically generate a script that you can save as a text file and use as an argument to the install_gmt command. I tried to do this for (literally) hours. I kept getting an error message about how it couldn’t find my netcdf directory. So a couple of minutes ago, I finally ran the install_gmt script without the GMTparams.txt argument, and I think I got a little further. It installed the necessary netcdf stuff, appeared to be installing GMT, and then gave me errors about not being able to find some files or directories. I think that the errors were all related to a missing GDAL directory. The GDAL thing is an optional feature that you can set up during installation that is supposed to allow you to create geo-tiffs. But I think I must haave set it up wrong…

So in the end, I am not certain whether I successfully installed GMT or not. But it’s now getting too late, and I’m too tired to figure it out. To be be continued…

**** a bit later *****
Ah-ha! I started the installation again found this little tidbit:
GMT offers experimental and optional support for other grid formats
and plotting of geotiffs via GDAL. To use this option you must already
have the GDAL library and include files installed.

I think this means it’s getting late and I’m starting to miss obvious things. More tomorrow!