How do I install GMT (6.1.1) on my Windows, using cygwin

Hello everyone,

Please, I have been trying to install GMT on my windows 10 laptop. I have been battling with this for days now…trying to source a solution on google, but all to no successful installation.
I have installed Cygwin and supported libraries that assist the GMT, but, I think I’m having issues appropriating the right algorithm on Cygwin to install the GMT.

I will be elated if I am helped with the step-to-step installation of GMT on Cygwin.
I have downloaded the following- GMT 6.1.1, gdal-3.2.0, dcw-gmt-1.1.4, and gshhg-gmt-2.3.7.

Following the instructions from https://wiki.canterbury.ac.nz/display/QuakeCore/How+to+install+GMT+on+Cygwin, I tried configuring the gdal-3.2.0, but getting this response:
issues

I look forward to your assistance!
Thanks in anticipation.

I’m a bit puzzled with those error messages. Is it really saying that chmod: command not found ??? Do you have experience with unix? That should ring some bells about the Cygwin installation.

Normally you should install dev- versions of the dependencies and then use cmake to build GMT like in any other unix system. But Cygwin is not really a supported environment. Native Windows binaries + MinGW gives a fine, no worries, unix type expeience in Win.

Yes, expr and chmod are basic shell commands so perhaps you are not running these commands in the Unix shell?

Thank you so much for your response, @Joaquim.
I have no experience with Unix. I usually use GUI Idle to code other languages. That’s why I really had to struggle with the installation, as I was literally, ignorantly duplicating codes in the Cygwin terminals.
Thanks again for your solution. So, it’s better I go with the .exe version of GMT, and use MinGW to access the GMT?

Thanks for your response, @pwessel!

I ran the code on the Cygwin terminal, after creating a folder where I extracted the build files.
Also, please pardon my ignorance; I use windows and GUI’s to code and I’m not truly familiar with the Unix environment. I am willing to learn if it will assist in completing my assignment and for future application.

For our GMT workshops we recommend Windows users to install GMT from the Windows installer, then get Git for WIndows with bash and simply run GMT in that bash window.

I even seldom use the bash. Most of times pure cmd is more than enough. But nowadays I also use other things more and more.

Okay, I get the first part, and I can do that immediately, but, how do I get Git for Windows with bash?
Is it through the MinGW?

Please mentor me @Joaquim :grinning:
I am eager to learn! How do run it with bash, I even installed Ubuntu hoping to run GMT from its bash interface, but, didn’t just go through.

@Johnie, If you prefer using Windows, but would like to use e.g. bash, I would highly recommend you to at least try the Windows Subsystem for Linux. See https://docs.microsoft.com/en-us/windows/wsl/faq and https://docs.microsoft.com/en-us/windows/wsl/install-win10 for more info. This basically lets you run Ubuntu alongside Windows.

I havent much experience with Cygwin, but I’ve tried it, and WSL is in my opinion a much more pleasant way of doing it.

1 Like

Thanks @Andreas
I have successfully installed it on my Windows. What I really want to know is how to access GMT on Ubuntu!

Super! Remember that you are actually running Ubuntu, so all tutorials, how-to’s etc. that are written for Ubuntu - you can use.

Here’s a simple primer that’ll make you set ut GMT from source in no time (if you want to do it the simple way, just run $ sudo apt install gmt). Execute the commands in the terminal:

# install dependencies - see https://github.com/GenericMappingTools/gmt/wiki/Install-dependencies-on-Ubuntu-and-Debian
$ sudo apt-get install build-essential cmake libcurl4-gnutls-dev libnetcdf-dev gdal-bin libgdal-dev libfftw3-dev libpcre3-dev liblapack-dev libblas-dev libglib2.0-dev ghostscript

#set up folders for all gmt-stuff
mkdir -p ~/gmt/gmt
mkdir -p ~/gmt/b
mkdir -p ~/gmt/share/coast
mkdir -p ~/gmt/share/dcw

#clone the repo
$ git clone --depth 20 https://github.com/GenericMappingTools/gmt ~/gmt/gmt

#download gshhg and dcw
wget -O ~/gmt/share/coast/gshhg-gmt-2.3.7.tar.gz "https://github.com/GenericMappingTools/gshhg-gmt/releases/download/2.3.7/gshhg-gmt-2.3.7.tar.gz"
tar zxvf ~/gmt/share/coast/gshhg-gmt-2.3.7.tar.gz
mv gshhg-gmt-*/* ~/gmt/share/coast
rm -rf gshhg-gmt*

wget -O ~/gmt/share/dcw/dcw-gmt-1.1.4.tar.gz "https://github.com/GenericMappingTools/dcw-gmt/releases/download/1.1.4/dcw-gmt-1.1.4.tar.gz"
tar zxvf ~/gmt/share/dcw/dcw-gmt-1.1.4.tar.gz
mv dcw-gmt-*/* ~/gmt/share/dcw
rm -rf dcw-gmt*

#build and install
cd ~/gmt/b \
cmake ~/gmt/gmt \
-DCOPY_GSHHG=TRUE \
-DCOPY_DCW=TRUE \
-DGSHHG_ROOT=~/gmt/share/coast \
-DDCW_ROOT=~/gmt/share/dcw \
-DGMT_OPENMP=ON \
&& cmake --build . \
&& sudo cmake --build . --target install

Hope this helps and gets you going.

Thanks so much @Andreas

I believe this technique would be very fruitful!
I started the $ sudo apt-get…, and got the following result:

oludemilade@DESKTOP-910MB6U:~$ sudo apt-get install build-essential cmake libcurl4-gnutls-dev libnetcdf-dev gdal-bin libgdal-dev libfftw3-dev libpcre3-dev liblapack-dev libblas-dev libglib2.0-dev ghostscript
[sudo] password for oludemilade:
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package libnetcdf-dev
E: Unable to locate package gdal-bin
E: Unable to locate package libgdal-dev
oludemilade@DESKTOP-910MB6U:~$ sudo apt-get install build-essential cmake libcurl4-gnutls-dev libnetcdf-dev
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package libnetcdf-dev
oludemilade@DESKTOP-910MB6U:~$ sudo apt install gmt
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package gmt
oludemilade@DESKTOP-910MB6U:~$

What can I do to fix this @Andreas
Thank you for your time once again

WSL has very rough edges. I wouldn’t recommend it for un-experienced unix user. If one use it together with the file manager it will screw the file permissions in such a way that … I give up.

Chances are very high that you don’t even need bash to start with. Just use plain cmd, and when you need Google for Git for windows and install it.

Not to mention that being a Ubuntu you are doomed to used OLD GMT versions or GMT with old dependencies.

Wow!
Thanks for following
So, please could you explain how I can use plain cmd to run GMT after installing the .exe file on my PC
@Joaquim

Well, open a command window and type GMT commands in it like one do in any other shell environment. The limitation with cmd is that the batch language is either very poor or complicated but being a beginner you won’t need (yet) the more advanced features of the bash language. And at any time you can start using the bash provided by Git for Win.

1 Like

Thanks @Joaquim for the elucidation!

I will go ahead with your instructions,
At the end of the installation, I am posed with the completion of plotting a simple map, topography map, and plot earthquake epicenters on a map.

I trust I could always reach out to you, if faced with other challenges.
I really appreciate your time, @Joaquim @Andreas

Me and others. That’s what the forums are good to.

1 Like

@Johnie Sorry, I should mention that you should first do:

$ sudo apt update
$ sudo apt upgrade

In order to get your packages system (apt) up-to-date (assuming you just set WSL up).

Then try again with:

$ sudo apt-get install build-essential cmake libcurl4-gnutls-dev libnetcdf-dev gdal-bin libgdal-dev libfftw3-dev libpcre3-dev liblapack-dev libblas-dev libglib2.0-dev ghostscript

Once you have installed dependencies, try to continue with the rest of the commands I gave.

This is what you should do if you want to build gmt yourself from source. In that case do not run sudo apt install gmt or else, as Joaquim said, you may get an old version of gmt installed. If you don’t want to bother building it yourself, you may run sudo apt install gmt.

I agree with Joaquim that if you’re only going to do super simple oneliners, installing gmt on windows and using cmd is OK. But as soon as you want to do scripts that are > 2 lines, cmd becomes a royal pain in my opinion. If I could talk to my former self I would say “start to use bash immediately”. I wrote scripts in cmd for years. Now I refuse to touch it.

1 Like