Saturday, March 26, 2011

linking

I figured out what was going wrong, but I'm not happy about it.

There were two problems.

1) The documentation for the gnuplot_i program said that all I had to do was compile the gnuplot_i.c program into a gnuplot_i.o file and then link that against any .c program using the gnuplot_i.h header and subsequent functions. This works fine (in the terminal) with the example .c programs.

I copied the example programs into XCode and then later Eclipse and despite figuring out how to link .o files in those programs I couldn't get anything to work. The fix (and kudos to me for thinking of this) was to step backwards a bit and just include the gnuplot_i.c program WITH the example program so that you compile both gnuplot_i.c and example.c and link them together at the same time.

This eliminated the compiler errors, but then that led to the next error: "GnuPlot not found".

2) "GnuPlot not found" is an error message the program generates (located in gnuplot_i.c again kudos to me for being able to read someone else's code) when invoking gnuplot fails. The program SEEMS to be smart enough to look in the usual locations such as /usr/bin and /usr/local/bin but that didn't seem to be good enough. Running Gnuplot from the command line works fine because it's in usr/local/bin. On a whim I copied Gnuplot from /usr/local/bin to /usr/bin and now the program works fine. I'll have to take a second look at gnuplot_i.c to see if it REALLY is looking for gnuplot in /usr/local/lib OR maybe if this is something about running the program in the XCode/Eclipse console is preventing my user directories from being in the path.

Tricky tricky.

No comments:

Post a Comment