Posts Tagged ‘ MB-System

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

MB-System: progress update

I left off yesterday with some unresolved issues. These issues are still unresolved today, however, I think I’ve narrowed it down to GDAL – surprise, surprise… It seems like my ‘undefined references’ are all related to GDAL functions. Since I know next to nothing about C libraries and header files it’s a bit tough reading through the forums that might otherwise be helpful. I wonder if I messed things up by installing GDAL using Synaptic, and then from source… I noticed that I have gdal-type files replicated in more than one place. Something tells me that can’t be good.

Here are the last few lines where things started to go haywire when running the MB-System sudo make all (it goes on and on and on, this is just a little snippet):

cd utilities; make all
make[2]: Entering directory `/home/michelle/Documents/mbsystem-5.1.2/src/utilities'
cc -g -w -DLINUX -DBYTESWAPPED mbprocess.o ../../lib/libmbio.a ../../lib/libmbproj.a ../../lib/libmbgsf.a ../../lib/libmr1pr.a ../../lib/libsapi.a ../../lib/libmbaux.a \
/home/michelle/Documents/GMT/GMT4.5.2/lib/libgmt.a /home/michelle/Documents/GMT/GMT4.5.2/lib/libpsl.a \
-L/home/michelle/Documents/GMT/netcdf-3.6.3/lib -lm -lnetcdf -L/home/michelle/Documents/GMT/netcdf-3.6.3/lib -lnetcdf -o ../../bin/mbprocess
/home/michelle/Documents/GMT/GMT4.5.2/lib/libgmt.a(gmt_customio.o): In function `ComputeRasterMinMax':
gmt_customio.c:(.text+0x65a7): undefined reference to `GDALGetRasterNoDataValue'
gmt_customio.c:(.text+0x65b5): undefined reference to `GDALGetRasterDataType'

Still working on MB-System

Yeah, I really should’ve realized it was just too easy.  I just tried installing MB-System, and I am getting a ton of errors because my c compiler is not recognizing simple math functions like sin, cos, sqrt, pow, etc.  I’m sure this is a really simple issue, and I’m just clueless about c in general.  But I really don’t know how to fix this.

Googling around, I did find some information – I think I’m missing a ‘-lm’ option somewhere (so that c links to the math library).  I found this conversation on an Ubuntu forum. Someone else was having the same problem, and part of the troubleshooting involved created a simple test program in C that uses some a math function (sin in this case). Here’s the little script that they use to create the test program. It’s called ‘test1.c’.

#include <stdio.h>
#include <stdlib.h>
#include <math.h>
main()
{
float x,y;
printf("enter the value of x\n");
scanf("%f",&amp;x);
printf("Hello world\n");
y=sin(x);
printf("value of y is %f \n",y);
printf("\nEnd of program\n");
}

Then if I type gcc -o test1 -lm test1.c in the terminal window, it creates a compliled program test1 from the test1.c code. I was then able to run it by type ./test1. Now, this didn’t exactly solve my problem, but it was pretty cool, and it worked. Which is significant in its own right since it is, quite literally, my VERY FIRST C PROGRAM. Ever. Yup, I just skipped right over “Hello, world”.

So, eventually I did manage to get past the above problem. I had a typo in my install_makefiles script, so I had to re-run it:
./install_makefiles
then sudo make all.

I was then able to find and use the appropriate math library. But I was still getting a ton of ‘undefined reference’ errors for a bunch of GDAL files. Not sure how to fix that. I think it’ll have to wait until tomorrow…

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