How to use GeographicLib in Qt

842 Views Asked by At

Hi I am new to qt and CMake , this is probably an easy fix but I have been struggling with it the entire day.

I am trying to use GeographicLib in a Qt project. I instaled CMake and downloaded the files from https://geographiclib.sourceforge.io/html/intro.html. On the Geographiclib website there is a guide for Building the library for use with Qt. There are a couple of commands you have to run :

 export PATH="`cygpath -m c:/QtSDK/mingw/bin`:$PATH"
 mkdir BUILD
 cd BUILD
 cmake -G "MinGW Makefiles" -D CMAKE_INSTALL_PREFIX="C:/Program Files/GeographicLib" ..
 mingw32-make
 mingw32-make install

after running the above I get the following:

C:\Users\koos>  export PATH="`cygpath -m c:/QtSDK/mingw/bin`:$PATH"
'export' is not recognized as an internal or external command,
operable program or batch file.

C:\Users\koos>  mkdir BUILD
A subdirectory or file BUILD already exists.

C:\Users\koos>  cd BUILD

C:\Users\koos\BUILD>  cmake -G "MinGW Makefiles" -D CMAKE_INSTALL_PREFIX="C:/Program 
Files/GeographicLib" ..
CMake Error: The source directory "C:/Users/koos" does not appear to contain CMakeLists.txt.
Specify --help for usage, or press the help button on the CMake GUI.

the website said that if cmake complains you have to run the following:

env PATH="$( echo $PATH | tr : '\n' |
while read d; do test -f "$d/sh.exe" || echo -n "$d:"; done |
sed 's/:$//' )" \
cmake -G "MinGW Makefiles" -D CMAKE_INSTALL_PREFIX="C:/Program Files/GeographicLib" ..

then I get :

C:\Users\koos\BUILD>  env PATH="$( echo $PATH | tr : '\n' |
'env' is not recognized as an internal or external command,
operable program or batch file.

C:\Users\koos\BUILD>  while read d; do test -f "$d/sh.exe" || echo -n "$d:"; done |
The syntax of the command is incorrect.

C:\Users\koos\BUILD>  sed 's/:$//' )" \
'sed' is not recognized as an internal or external command,
operable program or batch file.

C:\Users\koos\BUILD>  cmake -G "MinGW Makefiles" -D CMAKE_INSTALL_PREFIX="C:/Program 
Files/GeographicLib" ..

I am using Desktop Qt 13.0 MinGw 64-bit. I think there is a problem with the following: ""mingw32-make"" (being 32 in stead of 64 but i tried changing it and got no where). Can someone please explain to me how i should go about installing the Geographic lib library in Qt(maybe how to use the cmake qui to accomplish the task because i don't know much about cmake)

Edit :

So I installed cygwin and now it gives me the following:

koos@computer ~
$   mkdir BUILD
export PATH="`cygpath -m C:\Qt\Tools\mingw730_64\bin`:$PATH"
  cd BUILD
  cmake -G "MinGW Makefiles" -D CMAKE_INSTALL_PREFIX="C:/Program 
Files/GeographicLib" ..
 mingw32-make
mingw32-make install
koos@computer ~
$   mkdir BUILD

koos@computer ~
$   cd BUILD

koos@computer ~/BUILD
$   cmake -G "MinGW Makefiles" -D CMAKE_INSTALL_PREFIX="C:/Program 
Files/GeographicLib" ..
CMake Error: The source directory "C:/cygwin64/home/koos" does not appear 
to contain CMakeLists.txt.
Specify --help for usage, or press the help button on the CMake GUI.

koos@computer ~/BUILD
$   mingw32-make
-bash: mingw32-make: command not found

koos@computer ~/BUILD
$   mingw32-make install
-bash: mingw32-make: command not found

After running from the top-level directory of GeographicLib I get the following errors :

CMake Error: CMake was unable to find a build program corresponding to 
"MinGW Makefiles".  CMAKE_MAKE_PROGRAM is not set.  You probably need to 
select a different build tool.
CMake Error: CMake was unable to find a build program corresponding to 
"MinGW Makefiles".  CMAKE_MAKE_PROGRAM is not set.  You probably need to 
select a different build tool.
CMake Error: CMAKE_C_COMPILER not set, after EnableLanguage
CMake Error: CMAKE_CXX_COMPILER not set, after EnableLanguage
-- Configuring incomplete, errors occurred!

The path C:\Qt\Tools\mingw730_64\bin does contain mingw32-make.

Thanks for your patience!

Regards Koos

2

There are 2 best solutions below

0
On BEST ANSWER

Typing the following commands in Cygwin worked for me :

 set CC=C:/Qt/Tools/mingw730_64/bin/x86_64-w64-mingw32-gcc
 set CXX=C:/Qt/Tools/mingw730_64/bin/x86_64-w64-mingw32-g++

 cd C:/path/to/my/GeographicLib
 rm -rf BUILD; mkdir BUILD; cd BUILD
 export PATH="`cygpath C:/Qt/Tools/mingw730_64/bin`:$PATH"
 cmake -G "MinGW Makefiles" -D CMAKE_INSTALL_PREFIX="C:/Program Files/GeographicLib" ..
 mingw32-make
 mingw32-make install

 env PATH="$( echo $PATH | tr : '\n' |
 while read d; do test -f "$d/sh.exe" || echo -n "$d:"; done |
 sed 's/:$//' )" \
 cmake -G "MinGW Makefiles" -D CMAKE_INSTALL_PREFIX="C:/Program Files/GeographicLib" ..
 mingw32-make
 cygstart --action=runas mingw32-make install

NB: Make sure you have Cmake Installed, you can download the installer for windows here. Do not install the cygwin version of cmake because it does not have the MinGW Makefiles generator and make sure to check the "Add to system PATH" checkbox in the cmake installer. When installing cygwin make sure to select the "make" (gnu version of the make utility) package.

5
On

The instructions from the GeographicLib site say to run the commands with Cygwin:

If you are using the mingw compiler on Windows for Qt, then you need to build GeographicLib with mingw. You can accomplish this with cmake under cygwin with, for example, ...

The commands like export, env, and sed are not native to Windows, but are Linux commands. These must be run in a Cygwin command prompt. Your question does not mention Cygwin in your setup so I'm guessing you either haven't installed it or are not using it. Try installing Cygwin for your machine and running the listed commands from within a Cygwin command prompt.

The instructions assume you are running the commands from the top-level directory of the GeographicLib package, so you must navigate to that directory first. The updated commands would look something like this:

 cd C:/path/to/your/GeographicLib
 export PATH="`cygpath -m c:/QtSDK/mingw/bin`:$PATH"
 mkdir BUILD
 cd BUILD
 cmake -G "MinGW Makefiles" -D CMAKE_INSTALL_PREFIX="C:/Program Files/GeographicLib" ..
 mingw32-make
 mingw32-make install