How to check where my GMT is installed on ubuntu?

I’m trying to install GMT on my Ubuntu computer, by following this page: https://github.com/GenericMappingTools/gmt/blob/master/BUILDING.md

I copied the downloaded gmt gshhg and dcw files in to /opt/ and uncompressed them, configured the cmake files, and created the build folder at /opt/gmt-6.3.0/build/. The installation seemed to go through well.

Here is the problem. I have no idea where my GMT is installed. gmt --version will give me an error saying gmt is not installed. So what would be the path I need to add to my .bashrc? Is there a command that will enable me to find the path?

Many thanks.

I guess ‘which gmt’ doesnt work either then.

Try:
find -type f -name «gmt»

1 Like

The installation directory is set by CMAKE_INSTALL_PREFIX in cmake/ConfigUser.cmake. According to the template, it usually defaults to usr/local but I always set this rather than relying on the defaults (see https://github.com/GenericMappingTools/gmt/blob/master/BUILDING.md#configuring)

1 Like

Thanks!

I returns nothing in my current directory, so I went all the way to the root directory but got the below error:

find -type f -name «gmt»
find: ‘./run/user/1000/gvfs’: Permission denied

Thank you.

Here is my ConfigUser setting:
set (CMAKE_INSTALL_PREFIX “/opt/gmt-6.3.0”)

Unfortunately, this below command returned nothing:
$/opt/gmt-6.3.0/gmt --version
bash: /opt/gmt-6.3.0/gmt: No such file or directory

Well, presumably it is /opt/gmt-6.3.0/bin/gmt then. Look around in the build dir.

1 Like

Many thanks, Paul.

I’m able to find the info from a install_manifest.txt file. It turns out to be the below. Note the double quotation :slight_smile:
/opt/gmt-6.3.0/build/“/opt/gmt-6.3.0”/bin/

I thought that cmake link was supposed to be the link to the gmt installation file, without realizing it should be the destination file.

I would delete the build dir and rebuild after removing those quotes from the ConfigUser file.

1 Like

OK. Thanks. I plan to start over the process.

BTW, where is the best location for the "build" folder, considering that my desired destination location for gmt is /usr/local/ (default) and my downloaded and uncompressed sourced files for gmt, gshhg, and dcw are all located at /opt/?

The instruction says this:
“To keep generated files separate from source files in the source tree, you should create a build directory in the top-level directory.”

I tried to create the “build” directory under /opt/, but got the below error:
CMake Error: The source directory "/opt" does not appear to contain CMakeLists.txt.

Does that mean I would have to create the “build” file at /opt/gmt-6.3.0?

If you want to install the GMT binaries and libraries in /opt/gmt-6.3.0/lib,include,bin.share etc then I would use /opt/gmt-6.3.0 as the prefix in the configure but where you do the configuration and build can be anywhere - it can be deleted when you are done anyway. SO I would do that in my home dir. I dont think you want the build dir and the prefix install dir to be the same.

1 Like

Got you! Many thanks, Paul! Happy holidays.

Sorry leon6j for my bad example of find and wrong quotation marks.

$ find [dir] -type f -name "gmt"

I have a gmt folder in my home directory where I put all gmt-related stuff. I install to the standard destination (/usr/local/bin/).

$ ls -l
total 16
drwxr-xr-x  9 anbj anbj 4096 Dec 23 10:58 b      <-- build directory
drwxr-xr-x 11 anbj anbj 4096 Nov 24 20:03 gmt    <-- gmt repo (from git clone)
drwxr-xr-x  4 anbj anbj 4096 Oct 23 20:28 share  <-- gshhs and dcw

If you want to compile from source always, consider making an alias in your .bashrc;

gmtbuild() {
	cd ~/gmt/gmt
	git pull
	cd ~/gmt/b
	time (cmake ~/gmt/gmt -DCOPY_GSHHG=TRUE -DCOPY_DCW=TRUE -DGSHHG_ROOT=~/gmt/share/coast -DDCW_ROOT=~/gmt/share/dcw -DGMT_ENABLE_OPENMP=ON \
	&& cmake --build . --parallel $(getconf _NPROCESSORS_ONLN) \
	&& sudo cmake --build . --target install
	}

Then you’ll get bleeding edge gmt with a single command.

1 Like

Many thanks, Andreas!