Building GMT 5.4.2 on WSL (Ubuntu) on Windows 10 Pro
GMT-5.4.2をWindows Subsystem for Linux (WSL)のUbuntu 16.04でビルドします.これまでにいくつかの必要なパッケージはインストール済みですが,不足しているパッケージがあれば適宜インストールが必要です.
必要なパッケージのインストール
GMT-5.4.2のBuild InstructionのUbuntu/Debianに従い,以下の通りインストールを進めます.
[cc]
$ sudo apt update
$ sudo apt install ghostscript
$ sudo apt install subversion build-essential cmake libcurl4-gnutls-dev libnetcdf-dev libgdal1-dev libfftw3-dev libpcre3-dev liblapack-dev
$ sudo apt install graphicsmagick
[/cc]
GMT-5.4.2のビルド
GMT-5.4.2のソースコードとGSHHG,DCWをダウンロードします.これはWindowsでダウンロードすればよいでしょう.Linuxから見たWindowsでのダウンロード先はデフォルトでは以下になります.
[cc]
/mnt/c/Users/username/Downloads/
[/cc]
~/srcに展開します.~/srcが存在しなければ作っておきます.
[cc]
$ cd ~/src
$ tar xf /mnt/c/Users/username/Downloads/gmt-5.4.2-src.tar.gz
[/cc]
GSHHGとDCWを適当なディレクトリに解凍します.ここではrootになり,それぞれ/usr/share/gmt-gshhg/および/usr/share/gmt-dcw/に入れておきます.
[cc]
# sudo su -
# cd /usr/share
# tar xf /mnt/c/Users/username/Downloads/gshhg-gmt-2.3.7.tar.gz
# cd /usr/share
# tar xf /mnt/c/Users/username/Downloads/dcw-gmt-1.1.2.tar.gz
# mv gshhg-gmt-2.3.7 gshhg-gmt
# mv dcw-gmt-1.1.2 dcw-gmt
[/cc]
cmakeの準備をします.
[cc]
$ cd ~/src/gmt-5.4.2/cmake
$ cp ConfigUserTemplate.cmake ConfigUser.cmake
[/cc]
エディタでConfigUser.cmakeを開き,以下のように設定します.CMAKE_INSTALL_PREFIX等で検索をかけて該当する行を見つけ,コメントを外し,編集します.
[cc]
set (CMAKE_INSTALL_PREFIX "/usr/local/gmt-5.4.2")
set (GSHHG_ROOT "/usr/share/gmt-gshhg")
set (DCW_ROOT "/usr/share/gmt-dcw")
[/cc]
いよいよcmakeします.cmakeの後はピリオド2つです.make installのみrootで実行します.
[cc]
$ cd ~/src/gmt-5.4.2
$ mkdir build
$ cd build
$ cmake ..
$ make
# make install
[/cc]
最後に~/.bashrcを編集し,/usr/local/gmt-5.4.2/binにPATHを通します.該当部分の.bashrcは以下のようになります.
[cc]
export PATH=/usr/local/gmt-5.4.2/bin:$PATH
[/cc]
以上でおわりです.
ビルドエラーの対処法
当初,コンパイルは成功するものの,リンク時に以下のようなエラーとなり,ビルドに失敗しました.
[cc]
[100%] Linking C executable gmt
/usr/lib/gcc/x86_64-linux-gnu/5/../../../../lib/libgdal.so: undefined reference to `vtable for std::__cxx11::basic_stringbuf
//usr/lib/x86_64-linux-gnu/libpq.so.5: undefined reference to `SSL_get_peer_certificate@OPENSSL_1.0.0'
/usr/lib/gcc/x86_64-linux-gnu/5/../../../../lib/libgdal.so: undefined reference to `std::__cxx11::basic_string
//usr/lib/x86_64-linux-gnu/libpq.so.5: undefined reference to `CRYPTO_num_locks@OPENSSL_1.0.0'
//usr/lib/x86_64-linux-gnu/libpq.so.5: undefined reference to `SSL_get_current_compression@OPENSSL_1.0.0'
//usr/lib/x86_64-linux-gnu/libpq.so.5: undefined reference to `SSL_CTX_free@OPENSSL_1.0.0'
/usr/lib/gcc/x86_64-linux-gnu/5/../../../../lib/libgdal.so: undefined reference to `std::__cxx11::basic_string
//usr/lib/x86_64-linux-gnu/libpq.so.5: undefined reference to `SSL_CTX_use_certificate_chain_file@OPENSSL_1.0.0'
/usr/lib/gcc/x86_64-linux-gnu/5/../../../../lib/libgdal.so: undefined reference to `std::__cxx11::basic_string
//usr/lib/x86_64-linux-gnu/libpq.so.5: undefined reference to `SSL_get_version@OPENSSL_1.0.0'
/usr/lib/gcc/x86_64-linux-gnu/5/../../../../lib/libgdal.so: undefined reference to `std::__cxx11::basic_string
/usr/lib/gcc/x86_64-linux-gnu/5/../../../../lib/libgdal.so: undefined reference to `std::__cxx11::basic_ostringstream
//usr/lib/x86_64-linux-gnu/libpq.so.5: undefined reference to `BIO_int_ctrl@OPENSSL_1.0.0'
//usr/lib/x86_64-linux-gnu/libpq.so.5: undefined reference to `ENGINE_free@OPENSSL_1.0.0'
//usr/lib/x86_64-linux-gnu/libpq.so.5: undefined reference to `CRYPTO_get_id_callback@OPENSSL_1.0.0'
//usr/lib/x86_64-linux-gnu/libpq.so.5: undefined reference to `ASN1_STRING_data@OPENSSL_1.0.0'
/usr/lib/gcc/x86_64-linux-gnu/5/../../../../lib/libgdal.so: undefined reference to `std::__cxx11::basic_string
//usr/lib/x86_64-linux-gnu/libpq.so.5: undefined reference to `OPENSSL_config@OPENSSL_1.0.0'
//usr/lib/x86_64-linux-gnu/libpq.so.5: undefined reference to `SSL_get_error@OPENSSL_1.0.0'
//usr/lib/x86_64-linux-gnu/libpq.so.5: undefined reference to `X509_NAME_get_entry@OPENSSL_1.0.0'
//usr/lib/x86_64-linux-gnu/libdapclient.so.6: undefined reference to `std::basic_istream
/usr/lib/gcc/x86_64-linux-gnu/5/../../../../lib/libgdal.so: undefined reference to `std::__cxx11::basic_string
//usr/lib/x86_64-linux-gnu/libpq.so.5: undefined reference to `SSL_use_PrivateKey_file@OPENSSL_1.0.0'
//usr/lib/x86_64-linux-gnu/libpq.so.5: undefined reference to `X509_STORE_load_locations@OPENSSL_1.0.0'
/usr/lib/gcc/x86_64-linux-gnu/5/../../../../lib/libgdal.so: undefined reference to `std::logic_error::logic_error(std::__cxx11::basic_string
/usr/lib/gcc/x86_64-linux-gnu/5/../../../../lib/libgdal.so: undefined reference to `std::__cxx11::basic_stringstream
//usr/lib/x86_64-linux-gnu/libpoppler.so.58: undefined reference to `TIFFDefaultStripSize@LIBTIFF_4.0'
//usr/lib/x86_64-linux-gnu/libpq.so.5: undefined reference to `ASN1_STRING_length@OPENSSL_1.0.0'
//usr/lib/x86_64-linux-gnu/libpq.so.5: undefined reference to `SSL_CIPHER_get_name@OPENSSL_1.0.0'
/usr/lib/gcc/x86_64-linux-gnu/5/../../../../lib/libgdal.so: undefined reference to `std::__cxx11::basic_string
/usr/lib/gcc/x86_64-linux-gnu/5/../../../../lib/libgdal.so: undefined reference to `std::__cxx11::basic_string
//usr/lib/x86_64-linux-gnu/libpq.so.5: undefined reference to `sk_num@OPENSSL_1.0.0'
//usr/lib/x86_64-linux-gnu/libpoppler.so.58: undefined reference to `TIFFFdOpen@LIBTIFF_4.0'
//usr/lib/x86_64-linux-gnu/libpq.so.5: undefined reference to `SSL_set_ex_data@OPENSSL_1.0.0'
/usr/lib/gcc/x86_64-linux-gnu/5/../../../../lib/libgdal.so: undefined reference to `std::__cxx11::basic_string
//usr/lib/x86_64-linux-gnu/libpoppler.so.58: undefined reference to `TIFFWriteScanline@LIBTIFF_4.0'
//usr/lib/x86_64-linux-gnu/libkmlbase.so.1: undefined reference to `std::__cxx11::basic_string
//usr/lib/x86_64-linux-gnu/libpq.so.5: undefined reference to `SSL_read@OPENSSL_1.0.0'
/usr/lib/gcc/x86_64-linux-gnu/5/../../../../lib/libgdal.so: undefined reference to `std::__cxx11::basic_string
/usr/lib/gcc/x86_64-linux-gnu/5/../../../../lib/libgdal.so: undefined reference to `std::__cxx11::basic_string
/usr/lib/gcc/x86_64-linux-gnu/5/../../../../lib/libgdal.so: undefined reference to `vtable for std::__cxx11::basic_stringstream
/usr/lib/gcc/x86_64-linux-gnu/5/../../../../lib/libgdal.so: undefined reference to `VTT for std::__cxx11::basic_istringstream
/usr/lib/gcc/x86_64-linux-gnu/5/../../../../lib/libgdal.so: undefined reference to `std::__cxx11::basic_string
//usr/lib/x86_64-linux-gnu/libpq.so.5: undefined reference to `X509_STORE_set_flags@OPENSSL_1.0.0'
/usr/lib/gcc/x86_64-linux-gnu/5/../../../../lib/libgdal.so: undefined reference to `std::__cxx11::basic_string
/usr/lib/gcc/x86_64-linux-gnu/5/../../../../lib/libgdal.so: undefined reference to `std::__cxx11::basic_istringstream
//usr/lib/x86_64-linux-gnu/libpq.so.5: undefined reference to `SSLv23_method@OPENSSL_1.0.0'
/usr/lib/gcc/x86_64-linux-gnu/5/../../../../lib/libgdal.so: undefined reference to `std::__cxx11::basic_string
/usr/lib/gcc/x86_64-linux-gnu/5/../../../../lib/libgdal.so: undefined reference to `std::__cxx11::basic_string
//usr/lib/x86_64-linux-gnu/libpq.so.5: undefined reference to `ENGINE_load_private_key@OPENSSL_1.0.0'
//usr/lib/x86_64-linux-gnu/libpq.so.5: undefined reference to `BIO_new@OPENSSL_1.0.0'
//usr/lib/x86_64-linux-gnu/libpq.so.5: undefined reference to `BIO_set_flags@OPENSSL_1.0.0'
//usr/lib/x86_64-linux-gnu/libpq.so.5: undefined reference to `X509_get_subject_name@OPENSSL_1.0.0'
/usr/lib/gcc/x86_64-linux-gnu/5/../../../../lib/libgdal.so: undefined reference to `std::__cxx11::basic_string
//usr/lib/x86_64-linux-gnu/libpq.so.5: undefined reference to `CRYPTO_get_locking_callback@OPENSSL_1.0.0'
//usr/lib/x86_64-linux-gnu/libpq.so.5: undefined reference to `X509_NAME_ENTRY_get_data@OPENSSL_1.0.0'
//usr/lib/x86_64-linux-gnu/libpq.so.5: undefined reference to `sk_value@OPENSSL_1.0.0'
//usr/lib/x86_64-linux-gnu/libpq.so.5: undefined reference to `CRYPTO_set_id_callback@OPENSSL_1.0.0'
//usr/lib/x86_64-linux-gnu/libpoppler.so.58: undefined reference to `TIFFClose@LIBTIFF_4.0'
/usr/lib/gcc/x86_64-linux-gnu/5/../../../../lib/libgdal.so: undefined reference to `std::__cxx11::basic_string
/usr/lib/gcc/x86_64-linux-gnu/5/../../../../lib/libgdal.so: undefined reference to `std::__cxx11::basic_ostringstream
/usr/lib/gcc/x86_64-linux-gnu/5/../../../../lib/libgdal.so: undefined reference to `std::__cxx11::basic_stringbuf
//usr/lib/x86_64-linux-gnu/libpq.so.5: undefined reference to `SSL_CTX_new@OPENSSL_1.0.0'
//usr/lib/x86_64-linux-gnu/libpq.so.5: undefined reference to `SSL_CTX_get_cert_store@OPENSSL_1.0.0'
/usr/lib/gcc/x86_64-linux-gnu/5/../../../../lib/libgdal.so: undefined reference to `vtable for std::__cxx11::basic_istringstream
//usr/lib/x86_64-linux-gnu/libdap.so.17: undefined reference to `std::__cxx11::basic_string
//usr/lib/x86_64-linux-gnu/libpq.so.5: undefined reference to `SSL_check_private_key@OPENSSL_1.0.0'
//usr/lib/x86_64-linux-gnu/libkmldom.so.1: undefined reference to `std::__cxx11::basic_string
//usr/lib/x86_64-linux-gnu/libkmlbase.so.1: undefined reference to `std::__cxx11::basic_string
/usr/lib/gcc/x86_64-linux-gnu/5/../../../../lib/libgdal.so: undefined reference to `std::__cxx11::basic_stringbuf
/usr/lib/gcc/x86_64-linux-gnu/5/../../../../lib/libgdal.so: undefined reference to `std::__cxx11::basic_string
//usr/lib/x86_64-linux-gnu/libpq.so.5: undefined reference to `ENGINE_by_id@OPENSSL_1.0.0'
/usr/lib/gcc/x86_64-linux-gnu/5/../../../../lib/libgdal.so: undefined reference to `VTT for std::__cxx11::basic_stringstream
/usr/lib/gcc/x86_64-linux-gnu/5/../../../../lib/libgdal.so: undefined reference to `std::__throw_out_of_range_fmt(char const*, ...)@GLIBCXX_3.4.20'
//usr/lib/x86_64-linux-gnu/libpq.so.5: undefined reference to `BIO_s_socket@OPENSSL_1.0.0'
//usr/lib/x86_64-linux-gnu/libpq.so.5: undefined reference to `ERR_put_error@OPENSSL_1.0.0'
//usr/lib/x86_64-linux-gnu/libpq.so.5: undefined reference to `ERR_get_error@OPENSSL_1.0.0'
//usr/lib/x86_64-linux-gnu/libpq.so.5: undefined reference to `CRYPTO_set_locking_callback@OPENSSL_1.0.0'
//usr/lib/x86_64-linux-gnu/libpq.so.5: undefined reference to `SSL_load_error_strings@OPENSSL_1.0.0'
/usr/lib/gcc/x86_64-linux-gnu/5/../../../../lib/libgdal.so: undefined reference to `std::__cxx11::basic_string
//usr/lib/x86_64-linux-gnu/libpq.so.5: undefined reference to `SSL_new@OPENSSL_1.0.0'
//usr/lib/x86_64-linux-gnu/libpq.so.5: undefined reference to `SSL_get_current_cipher@OPENSSL_1.0.0'
//usr/lib/x86_64-linux-gnu/libpq.so.5: undefined reference to `BIO_clear_flags@OPENSSL_1.0.0'
/usr/lib/gcc/x86_64-linux-gnu/5/../../../../lib/libgdal.so: undefined reference to `std::__cxx11::basic_string
/usr/lib/gcc/x86_64-linux-gnu/5/../../../../lib/libgdal.so: undefined reference to `std::__cxx11::basic_stringstream
//usr/lib/x86_64-linux-gnu/libpq.so.5: undefined reference to `SSL_write@OPENSSL_1.0.0'
/usr/lib/gcc/x86_64-linux-gnu/5/../../../../lib/libgdal.so: undefined reference to `std::__cxx11::basic_string
/usr/lib/gcc/x86_64-linux-gnu/5/../../../../lib/libgdal.so: undefined reference to `std::__cxx11::basic_string
/usr/lib/gcc/x86_64-linux-gnu/5/../../../../lib/libgdal.so: undefined reference to `std::runtime_error::runtime_error(std::__cxx11::basic_string
//usr/lib/x86_64-linux-gnu/libpq.so.5: undefined reference to `X509_free@OPENSSL_1.0.0'
//usr/lib/x86_64-linux-gnu/libpq.so.5: undefined reference to `SSL_CTX_load_verify_locations@OPENSSL_1.0.0'
/usr/lib/gcc/x86_64-linux-gnu/5/../../../../lib/libgdal.so: undefined reference to `vtable for std::__cxx11::basic_ostringstream
//usr/lib/x86_64-linux-gnu/libpq.so.5: undefined reference to `SSL_free@OPENSSL_1.0.0'
//usr/lib/x86_64-linux-gnu/libdap.so.17: undefined reference to `std::__cxx11::basic_string
//usr/lib/x86_64-linux-gnu/libpq.so.5: undefined reference to `SSL_ctrl@OPENSSL_1.0.0'
//usr/lib/x86_64-linux-gnu/libpoppler.so.58: undefined reference to `TIFFSetField@LIBTIFF_4.0'
//usr/lib/x86_64-linux-gnu/libpq.so.5: undefined reference to `ERR_clear_error@OPENSSL_1.0.0'
//usr/lib/x86_64-linux-gnu/libicuuc.so.55: undefined reference to `__cxa_throw_bad_array_new_length@CXXABI_1.3.8'
//usr/lib/x86_64-linux-gnu/libpq.so.5: undefined reference to `SSL_set_verify@OPENSSL_1.0.0'
//usr/lib/x86_64-linux-gnu/libdap.so.17: undefined reference to `std::logic_error::logic_error(std::logic_error const&)@GLIBCXX_3.4.21'
//usr/lib/x86_64-linux-gnu/libpq.so.5: undefined reference to `ENGINE_init@OPENSSL_1.0.0'
//usr/lib/x86_64-linux-gnu/libdap.so.17: undefined reference to `std::invalid_argument::invalid_argument(std::__cxx11::basic_string
/usr/lib/gcc/x86_64-linux-gnu/5/../../../../lib/libgdal.so: undefined reference to `sqlite3_column_table_name'
//usr/lib/x86_64-linux-gnu/libpq.so.5: undefined reference to `SSL_CIPHER_get_bits@OPENSSL_1.0.0'
//usr/lib/x86_64-linux-gnu/libgeos_c.so.1: undefined reference to `std::__cxx11::basic_string
//usr/lib/x86_64-linux-gnu/libpq.so.5: undefined reference to `SSL_connect@OPENSSL_1.0.0'
/usr/lib/gcc/x86_64-linux-gnu/5/../../../../lib/libgdal.so: undefined reference to `std::__cxx11::basic_string
//usr/lib/x86_64-linux-gnu/libpq.so.5: undefined reference to `X509_NAME_get_index_by_NID@OPENSSL_1.0.0'
//usr/lib/x86_64-linux-gnu/libpq.so.5: undefined reference to `ERR_reason_error_string@OPENSSL_1.0.0'
//usr/lib/x86_64-linux-gnu/libpq.so.5: undefined reference to `SSL_set_bio@OPENSSL_1.0.0'
//usr/lib/x86_64-linux-gnu/libpq.so.5: undefined reference to `SSL_CTX_ctrl@OPENSSL_1.0.0'
//usr/lib/x86_64-linux-gnu/libpq.so.5: undefined reference to `sk_free@OPENSSL_1.0.0'
//usr/lib/x86_64-linux-gnu/libpq.so.5: undefined reference to `SSL_pending@OPENSSL_1.0.0'
//usr/lib/x86_64-linux-gnu/libpq.so.5: undefined reference to `SSL_use_PrivateKey@OPENSSL_1.0.0'
//usr/lib/x86_64-linux-gnu/libpq.so.5: undefined reference to `ENGINE_finish@OPENSSL_1.0.0'
/usr/lib/gcc/x86_64-linux-gnu/5/../../../../lib/libgdal.so: undefined reference to `VTT for std::__cxx11::basic_ostringstream
//usr/lib/x86_64-linux-gnu/libpq.so.5: undefined reference to `X509_get_ext_d2i@OPENSSL_1.0.0'
//usr/lib/x86_64-linux-gnu/libpq.so.5: undefined reference to `SSL_library_init@OPENSSL_1.0.0'
/usr/lib/gcc/x86_64-linux-gnu/5/../../../../lib/libgdal.so: undefined reference to `std::__cxx11::basic_string
/usr/lib/gcc/x86_64-linux-gnu/5/../../../../lib/libgdal.so: undefined reference to `std::__cxx11::basic_string
//usr/lib/x86_64-linux-gnu/libpq.so.5: undefined reference to `SSL_shutdown@OPENSSL_1.0.0'
/usr/lib/gcc/x86_64-linux-gnu/5/../../../../lib/libgdal.so: undefined reference to `std::__cxx11::basic_string
collect2: error: ld returned 1 exit status
src/CMakeFiles/gmt.dir/build.make:111: recipe for target 'src/gmt' failed
make[2]: *** [src/gmt] Error 1
CMakeFiles/Makefile2:546: recipe for target 'src/CMakeFiles/gmt.dir/all' failed
make[1]: *** [src/CMakeFiles/gmt.dir/all] Error 2
Makefile:149: recipe for target 'all' failed
make: *** [all] Error 2
[/cc]
原因はライブラリ間のバージョンのコンフリクト等にあるようで,先にインストールしていたAnaconda3のライブラリをリンクしようとしていることが問題のようでした.そこで,一時的にAnaconda3がインストールされているディレクトリ名をAnaconda3tmpのように変更し,camkeからAnaconda3が見えないようにしました.このようにしてから,cmakeを実行したところ,問題なくビルドできました.ビルドをやり直すときは作成したbuildディレクトリを削除する必要があります.ビルドに成功したらAnaconda3のディレクトリ名を元に戻しましょう.
“Building GMT 5.4.2 on WSL (Ubuntu) on Windows 10 Pro” に対して1件のコメントがあります。