라이브러리를 설치했습니다 ~/.local
. 환경변수 설정은 다음과 같습니다.
$ echo $LD_LIBRARY_PATH
/home/saga//.local/lib
$ echo $PKG_CONFIG_PATH
/home/saga//.local/lib/pkgconfig
/home/saga//.local/lib/pkgconfig
내용이 다음과 같은 re2.pc 파일이 있습니다 .
prefix=/home/saga//.local
exec_prefix=/home/saga//.local
includedir=/home/saga//.local/include
libdir=/home/saga//.local/lib
Name: re2
Description: RE2 is a fast, safe, thread-friendly regular expression engine.
Version: 0.0.0
Cflags: -std=c++11 -pthread -I${includedir}
Libs: -pthread -L${libdir} -lre2
.re2.h가 포함 된 re2
프로그램 을 컴파일하려고 하면 다음 오류가 발생합니다 ./home/saga//.local/include
re2.h
$ g++ tst.cpp
tst.cpp:1:9: fatal error: re2/re2.h: No such file or directory
#include<re2/re2.h>
^~~~~~~~~~~
compilation terminated.
그리고
$ g++ tst2.cpp
tst.cpp:1:9: fatal error: re2.h: No such file or directory
#include<re2.h>
^~~~~~~
compilation terminated.
의 출력은 pkg-config --libs re2
다음과 같습니다-L/home/saga//.local/lib -pthread -lre2
이 문제를 어떻게 해결할 수 있나요?
답변1
당신은 그렇지 않다사용 pkg-config
...
$ g++ $(pkg-config --cflags re2) tst.cpp
답변2
디버그 모드에서 pkg-config를 실행해 볼 수 있습니다.
$ pkg-config --cflags-only-I re2 --debug
다음과 같이 인쇄되어야 합니다.
< cut >
Looking for package 're2'
Looking for package 're2-uninstalled'
Reading 're2' from file '/home/saga/.local/lib/pkgconfig/re2.pc'
Parsing package file '/home/saga/.local/lib/pkgconfig/re2.pc'
line>prefix=/home/saga//.local
Variable declaration, 'prefix' has value '/home/saga//local'
line>exec_prefix=/home/saga//.local
Variable declaration, 'exec_prefix' has value '/home/saga//local'
line>includedir=/home/saga//.local/include
Variable declaration, 'includedir' has value '/home/saga//.local/include'
line>libdir=/home/saga//.local/lib
Variable declaration, 'libdir' has value '/home/saga//.local/lib'
line>
line>Name: re2
line>Description: RE2 is a fast, safe, thread-friendly regular expression engine.
line>Version: 0.0.0
line>Cflags: -std=c++11 -pthread -I${includedir}
line>Libs: -pthread -L${libdir} -lre2
Path position of 're2' is 1
Adding 're2' to list of known packages
pre-remove: re2
post-remove: re2
original: re2
sorted: re2
adding CFLAGS_I string "-I/home/saga//.local/include "
returning flags string "-I/home/saga//.local/include "
-I/home/saga//.local/include
마지막 줄이 현재 누락된 줄임을 알 수 있습니다.