LoginSignup
0
0

More than 1 year has passed since last update.

【R Studio server】 Leaflet をInstallするときの 'libproj.so.15: cannot open' 'proj_api.h you must define' エラーに対処する

Last updated at Posted at 2022-05-05

Centos7サーバーの
R Studioで
install.packages("leaflet")
を行おうとすると下記エラーが出ます。

checking PROJ: checking whether PROJ and sqlite3 are available for linking:... yes
./proj_conf_test: error while loading shared libraries: libproj.so.15: cannot open shared object file: No such file or directory

問題解決のために参考にしたのは下記サイト。
https://amisha2016.wordpress.com/tag/osm2pgsql-error-while-loading-shared-libraries-libproj-so-0-cannot-open-shared-object-file-no-such-file-or-directory/

# find -name libproj.so.15

でどこにあるかを調べます。
返ってくる答えは

# ./usr/local/lib/libproj.so.15

上記を参照するシンボリックリンクを張りました。

# ln -s /usr/local/lib/libproj.so.15 /usr/lib/libproj.so.15

この後, R Studioに戻って再び

install.packages("leaflet")

すると新たなエラーが表示。(先ほども表示されていたのですが)

In file included from RcppFunctions.cpp:26:0:
/usr/local/include/proj_api.h:37:2: エラー: #error 'To use the proj_api.h you must define the macro ACCEPT_USE_OF_DEPRECATED_PROJ_API_H'
 #error 'To use the proj_api.h you must define the macro ACCEPT_USE_OF_DEPRECATED_PROJ_API_H'

https://stackoverflow.com/questions/67518451/accept-use-of-deprecated-proj-api-h-error-when-installing-cartopy
を参考にして下記を実行。proj_api.hのバックアップを一旦とっておいて、vim(テキストエディタ)を使って書き換える作戦です。

# cp /usr/local/include/proj_api.h /usr/local/include/proj_api.h.backup
# vim /usr/local/include/proj_api.h

上記を実行してproj_api.hを覗いてみます。

ちなみにvimの使い方は私自身、全く慣れていませんが、下記を参照にさせて頂きました。
https://www.rouge.gr.jp/~fuku/tips/editor/

本格作業の前に少し試してみます。
下記は次の画面コピーのようにカーソルのある行を試しに書き換えた結果です。

#error 'To use the proj_api.h .................

#error 'Hello To use the proj_api.h .................

image.png
↑上記画面はHello を追記した後の様子です。

このように試しにvimを使って書き換えて、 R Studioに戻って再び
install.packages("leaflet") を入力すると、Helloの文字が出現します。エラーメッセージはここから読みだされていたのですね。
なんだ、そのような仕組みなのかと理解しました。

In file included from RcppFunctions.cpp:26:0:
/usr/local/include/proj_api.h:37:2: エラー: #error 'Hello To use the proj_api.h you must define the macro ACCEPT_USE_OF_DEPRECATED_PROJ_API_H'
#error 'To use the proj_api.h you must define the macro ACCEPT_USE_OF_DEPRECATED_PROJ_API_H'

理解したところで、確信を抱きつつ作業開始。
再びvimを起動して下記の中の#error 'Hello .... を

/*
  * This version number should be updated with every release!
  *
  * This file is expected to be removed from the PROJ distribution
  * when a few minor-version releases has been made.
  *
  */

#ifndef ACCEPT_USE_OF_DEPRECATED_PROJ_API_H
#error 'Hello To use the proj_api.h you must define the macro ACCEPT_USE_OF_DEPRECATED_PROJ_API_H'
#endif

#ifndef PJ_VERSION
#define PJ_VERSION 620
#endif

#ifdef PROJ_RENAME_SYMBOLS
#include "proj_symbol_rename.h"
#endif
In file included from RcppFunctions.cpp:26:0:
/usr/local/include/proj_api.h:37:2: エラー: #error 'Hello To use the proj_api.h you must define the macro ACCEPT_USE_OF_DEPRECATED_PROJ_API_H'
 #error 'Hello To use the proj_api.h you must define the macro ACCEPT_USE_OF_DEPRECATED_PROJ_API_H'

下記のように(#define ACCEPT_USR_OF_DEPRECATED_PROJ_API_H 1)書き換えました。(前後関係がわかるようにしています)

/*
  * This version number should be updated with every release!
  *
  * This file is expected to be removed from the PROJ distribution
  * when a few minor-version releases has been made.
  *
  */

#ifndef ACCEPT_USE_OF_DEPRECATED_PROJ_API_H
#define ACCEPT_USR_OF_DEPRECATED_PROJ_API_H 1
#endif

#ifndef PJ_VERSION
#define PJ_VERSION 620
#endif

#ifdef PROJ_RENAME_SYMBOLS
#include "proj_symbol_rename.h"
#endif
In file included from RcppFunctions.cpp:26:0:
/usr/local/include/proj_api.h:37:2: エラー: #error 'Hello To use the proj_api.h you must define the macro ACCEPT_USE_OF_DEPRECATED_PROJ_API_H'
 #error 'Hello To use the proj_api.h you must define the macro ACCEPT_USE_OF_DEPRECATED_PROJ_API_H'

これでやっとLeafletがインストールされました。
実は知識不足の為か、これらの問題解決に1週間かかりました。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0