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

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

Wow!
Thanks again @Andreas

considering the Assignments given, I am posed with several lines of codes to run on bash. Hence, I will continue with your method.
Since you’re using this platform, I believe you’ll continue to assist me!

Update:
I have been able to update and upgrade successfully.
Also, I was able to perform the rest of the previous codes, but with 2 constrains:

  1. I wasn’t able to run ( mv gshhg-gmt-*/* ~/gmt/share/coast) successfully, I skipped it and ran the remaining lines of code.
  2. After successfully downloading and extracting the files, the installation code which is the last task brought the following prompt (-bash: cd: too many arguments)


Should try installing them in batches? @Andreas

Thanks for your time and assistance…
Hoping to hear from you soonest!

Please do a ls -l ~/gmt/share/coast to check that the gshhg files are present.

And I forgot to put && at the end of the cd command.

Try:

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
1 Like

It returned gshhg.tar.gz instead!
install_3

would I need to re-download or unzip the file @Andreas
Also, it is showing gsshg instead of gshhg.

GSSHG is correct, I misspelled. It did not extract the tarball. Try:

cd ~/gmt/share/coast
tar -zxvf gsshg-gmt-2.3.7.tar.gz

and then again:

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
1 Like

Dear @Andreas,

I am satiated with profound joy…What took me several days and abrupt night rest, was solved by your sagacity, patience, and willingness to help me. I bless you from my heart! This is the output!


Thanks once again @Andreas

Going forward, I will need assistance on how to navigate my way around the app. Such as:

  1. Using the given files to plot topo maps, and other maps.
  2. Where do I create my files (is it in the /b directory?)
    3. The next step I need to take from here.

Also, if you have materials that I could peruse in expediting my knowledge on GMT and its environmental functions, I deeply welcome it.
Thanks again and again @Andreas

Glad it worked out for you @Johnie!

If you’re new to GMT, you really should go through the tutorial (https://docs.generic-mapping-tools.org/latest/tutorial.html) and the Cookbook (https://docs.generic-mapping-tools.org/latest/cookbook.html). The most important thing is however; try things out for yourself. Test and play with it. Make mistakes. You’ll learn alot from this.

I don’t know the technical details, but WSL has it’s own kind of filesystem, which is generally hidden from Windows’ that you’re used(?) to. You can run GMT everywhere you want, but assuming that you’ll use Windows programs to e.g. look at the figures, it’s best to work in a place easily accessable from both systems. I tend to use the desktop. To reach the ‘Windows filesystem’ you do:

cd /mnt/c

Try doing an ls -l; what you see should be somewhat familiar. Then go to your desktop:

cd /mnt/c/Users/<your username/Desktop

Make a file:

echo "Hello from WSL" > hello.txt

You should now see a file called hello.txt on your Windows desktop.

Make a folder and try to make a plot or two:

mkdir plot
cd plot
gmt psbasemap -R10/70/-3/8 -JX4i/3i -Bafg -B+glightred+t"My first plot" > my_first_plot.ps

If you’re new to the terminal and bash you might feel that the learning curve is steep, but once you get the hang of it becomes very powerful (as GMT itself).

Yes!

I will give attention to the tutorial sites and I’m truly grateful for all you have done.
I was able to locate the path where Ubuntu saves the folder on the PC via: C:\Users\<PC name>/AppData\Local\Packages\CanonicalGroupLimited... But, using the Desktop directory you highlighted is just perfect!

Also, I tried running the my_first_plot.ps but didn’t see any plotted figure or output!
I downloaded and installed Ghostscript using sudo apt install gv, which was successful, but still didn’t output any figure.

I making the file into an executable file and also tried running the file using the Ghostscript, all resulting in zero output!

Can you please explain what I need to do, in order to output these figures @Andreas!
Thanks in anticipation.

What you’re trying to do is correct if you used a Window manager on Ubuntu (e.g. Xorg). But since you’re on Windows, we can deal with that at a later stage :slight_smile:.

If you want to open the postscript file, I would suggest you install ghostscript and GSview on Windows;
Ghostscript: https://www.ghostscript.com/download/gsdnld.html - choose Ghostscript 9.53.3 for Windows (64 bit) with the Ghostscript AGPL Release
GSview: http://www.ghostgum.com.au/software/gsview.htm - choose Win64 (x86_64)

After you’ve installed those, you should be able to double click my_first_plot.ps and it should open in GSview.

Based on your screenshots: remember that the file plotMap.sh only contains text (commands) for GMT to execute (I assume). GMT interprets those commands and outputs Postscript, which basically is text (it’s a descriptive programming language), that tells a program (GSView in this case) how your figure should look like. So there is no need to make the *.ps executable.

Try to do a gmt psbasemap -R10/70/-3/8 -JX4i/3i -Bafg -B+glightred+t"My first plot" without redirecting to a file, and behold the postscript pouring at you.

PS! If you dont care about the Postscript-files, you can use psconvert -Tf -A my_first_plot.ps to convert the figure to PDF. I’m sure you’re able to look at PDF’s without installing new software.

1 Like

Wow :grinning:
I’m glad I’m catching up! Thanks, @Andreas
So, I performed all the tasks you itemized which was very successful!

But, I wasn’t able to convert the *.ps file to pdf. Which of the libraries would I have to download?

Also, I downloaded and installed the Ghostscript 64 bit, but wasn’t able to install the downloaded gs (x86_64)

GS_install

So, I tried installing the 32 bit Ghostscript and Gsview…, but wasn’t able to view the .ps file as it resulted in the following error:

    GSview 5.0 2012-01-17
    Unknown in Comments section at line 7:
      %%DocumentNeededResources: font Helvetica

Unknown in Page section at line 677:
  %%BeginObject PSL_Layer_1

Unknown in Page section at line 823:
  %%EndObject

Failed to load C:\Program Files (x86)\Ghostgum\gs7.04\bin\gsdll32.dll, error 126
The specified module could not be found.



Failed to load C:\Program Files (x86)\Ghostgum\gsview\gsdll32.dll, error 126
The specified module could not be found.



Failed to load gsdll32.dll, error 126
The specified module could not be found.



Can't load Ghostscript DLL

How do I solve these challenges Sir @Andreas :innocent:

I’m sorry, I forgot to put gmt at the start of the command.

It should be gmt psconvert -Tf -A my_first_plot.ps. (Note -Tf, not -If)

Now for the trouble with GSview, I’m not sure why this. Did you manage to install ghostscript successfully? It looks like GSview doesnt find ghostscript.

1 Like

Spot on: :raised_hands:
Thanks, @Andreas
Converted and it outputted successfully!

I actually installed the Ghostscript prior to the GSview. But, I will try it again.
Thanks once again @Andreas

One more thing It means I have to save the script with the .ps extension?

Great!

You can create a script and call it whatever you want. I use .sh so I know it’s a script. You should not use .ps since that indicates that it’s a postscript file.

Use an editor that you like, e.g. nano and make a simple script, then execute it:

$ nano test.sh

And write:

ps=test.ps
gmt psbasemap -R10/70/-3/8 -JX4i/3i -Bafg -B+glightred+t"My first plot" > $ps
gmt psconvert -Tf -A $ps

Exit and save by pressing Ctrl+x.

Then execute the script with:

bash test.sh

Or

chmod a+x #to make it executable
./test.sh

Hi @Andreas
I trust you have been good. I apologize for the late response, I have been studying :blush:

First, I have installed the gsview on my laptop! The reason for the previous error was that I had downloaded the recent version of the Ghostscript, and the gsview requires a version lesser than 9.99. I was able to solve the puzzle by downloading and installing Ghostscript 9.52. I think I have the full package on my laptop now!
Thanks again @Andreas

Second, I wasn’t able to run your simple code as it brought this error:

Third, I was able to do the first assignment given.
I am truly grateful for all your assistance @Andreas

Thank you.