0

I've installed a library to ~/.local. The environment variables are set as shown below:

$ echo $LD_LIBRARY_PATH
/home/saga//.local/lib
$ echo $PKG_CONFIG_PATH
/home/saga//.local/lib/pkgconfig

There's an re2.pc file in /home/saga//.local/lib/pkgconfig whose contents are:

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

There's an re2 directory in /home/saga//.local/include which contains re2.h. But when I try to compile a program which includes re2.h, I get the following error:

$ g++ tst.cpp
tst.cpp:1:9: fatal error: re2/re2.h: No such file or directory
 #include<re2/re2.h>
         ^~~~~~~~~~~
compilation terminated.

and

$ g++ tst2.cpp
tst.cpp:1:9: fatal error: re2.h: No such file or directory
 #include<re2.h>
         ^~~~~~~
compilation terminated.

The output of pkg-config --libs re2 is -L/home/saga//.local/lib -pthread -lre2

How can I fix this?

5
  • Did you try querying pkgconfig so you can find out where the header is located? Nov 10, 2017 at 17:34
  • @Ignacio Vazquez-Abramshow do I do that?
    – saga
    Nov 10, 2017 at 17:35
  • @IgnacioVazquez-Abrams The output of pkg-config --libs re2 is -L/home/saga//.local/lib -pthread -lre2
    – saga
    Nov 10, 2017 at 17:44
  • Okay. Did you try telling that to g++? Nov 10, 2017 at 17:44
  • Tried the solution offered below, getting the same error.
    – saga
    Nov 10, 2017 at 17:50

2 Answers 2

0

You're not actually using pkg-config...

$ g++ $(pkg-config --cflags re2) tst.cpp
8
  • Just tried it, I'm getting the same error.
    – saga
    Nov 10, 2017 at 17:42
  • "There's an re2 directory in /home/saga//.local/include which contains re2.h." Nov 10, 2017 at 17:42
  • @saga I first misread the question. Sorted now.
    – Kusalananda
    Nov 10, 2017 at 17:47
  • Still getting the same error. The output of pkg-config --cflags re2 is -std=c++11 -pthreads
    – saga
    Nov 10, 2017 at 17:48
  • Shouldn't there be an -I/ there as well.
    – saga
    Nov 10, 2017 at 17:49
0

You can try running pkg-config in debug mode with:

$ pkg-config --cflags-only-I re2 --debug

It should print something like this:

< 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

You can see that the last line is what you're currently missing.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .