Reputation: 1498
I am trying to compile a C program which uses regexes on FreeBSD. I have checked in /usr/local/include and the file pcre.h is definitely there.
However, no matter what I do, I get the following compiler error:
/usr/home/myname/project/include/pcre_wrap.h:4:18: error: pcre.h: No such file or directory
What could be going wrong? My understanding of C libraries on Unix could be better...
Upvotes: 0
Views: 3356
Reputation: 1975
I got a slightly different error when building a Golang module in M1 MacOS, brew install pcre
only did not work for me.
github.com/glenn-brown/golang-pkg-pcre/src/pkg/pcre ../../../../.gvm/pkgsets/go1.20/global/pkg/mod/github.com/glenn-brown/[email protected]/src/pkg/pcre/pcre.go:52:10: fatal error: 'pcre.h' file not found #include <pcre.h> ^~~~~~~~ 1 error generated.
it can be solved by creating a symlink:
sudo ln -s /opt/homebrew/include /usr/local/include
Upvotes: 0
Reputation: 4050
As the comment above says you need to use #include. If this isn't working you may want to export an environment variable C_INCLUDE_PATH
that points to the header file.
Failing that why not try adding -I/usr/local/include
to your gcc
call, something like gcc myfile.c -I/usr/local/include -o myexe
Upvotes: 4