Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Undocumented build dependency: PCRE #8

Closed
almostimplemented opened this issue May 4, 2017 · 15 comments
Closed

Undocumented build dependency: PCRE #8

almostimplemented opened this issue May 4, 2017 · 15 comments

Comments

@almostimplemented
Copy link

While building on OS X 10.12 I received the following build error:

--  While building package regex-pcre-0.94.4 using:
      /Users/drew/.stack/setup-exe-cache/x86_64-osx/Cabal-simple_mPHDZzAJ_1.24.2.0_ghc-8.0.2 --builddir=.stack-work/dist/x86_64-osx/Cabal-1.24.2.0 build --ghc-options " -ddump-hi -ddump-to-file"
    Process exited with code: ExitFailure 1
    Logs have been written to: /Users/drew/oss/duckling/.stack-work/logs/regex-pcre-0.94.4.log

    Configuring regex-pcre-0.94.4...
    Building regex-pcre-0.94.4...
    Preprocessing library regex-pcre-0.94.4...
    Wrap.hsc:148:10: fatal error: 'pcre.h' file not found
    #include <pcre.h>
             ^
    1 error generated.
    compiling .stack-work/dist/x86_64-osx/Cabal-1.24.2.0/build/Text/Regex/PCRE/Wrap_hsc_make.c failed (exit code 1)
    command was: /usr/bin/gcc -c .stack-work/dist/x86_64-osx/Cabal-1.24.2.0/build/Text/Regex/PCRE/Wrap_hsc_make.c -o .stack-work/dist/x86_64-osx/Cabal-1.24.2.0/build/Text/Regex/PCRE/Wrap_hsc_make.o -m64 -fno-stack-protector -m64 -fno-stack-protector -m64 -D__GLASGOW_HASKELL__=800 -Ddarwin_BUILD_OS=1 -Dx86_64_BUILD_ARCH=1 -Ddarwin_HOST_OS=1 -Dx86_64_HOST_ARCH=1 -DHAVE_PCRE_H -DSPLIT_BASE=1 -I.stack-work/dist/x86_64-osx/Cabal-1.24.2.0/build/autogen -include .stack-work/dist/x86_64-osx/Cabal-1.24.2.0/build/autogen/cabal_macros.h -I/Users/drew/.stack/programs/x86_64-osx/ghc-8.0.2/lib/ghc-8.0.2/bytestring-0.10.8.1/include -I/Users/drew/.stack/programs/x86_64-osx/ghc-8.0.2/lib/ghc-8.0.2/base-4.9.1.0/include -I/Users/drew/.stack/programs/x86_64-osx/ghc-8.0.2/lib/ghc-8.0.2/integer-gmp-1.0.0.1/include -I/Users/drew/.stack/programs/x86_64-osx/ghc-8.0.2/lib/ghc-8.0.2/include -I/Users/drew/.stack/programs/x86_64-osx/ghc-8.0.2/lib/ghc-8.0.2/include/

The error indicates the PCRE library is absent (or unable to be found). My resolution was to install PCRE with my preferred package manager: brew install pcre. The solution will vary depending on OS, and in some cases PCRE may already be installed.

@almostimplemented almostimplemented changed the title Build dependency: PCRE Undocumented Build dependency: PCRE May 4, 2017
@almostimplemented almostimplemented changed the title Undocumented Build dependency: PCRE Undocumented build dependency: PCRE May 4, 2017
@niteria
Copy link

niteria commented May 4, 2017

Thanks for the report. I'm adding a note in the README.

@niteria niteria closed this as completed May 4, 2017
facebook-github-bot pushed a commit that referenced this issue May 4, 2017
Summary: This should resolve #8 and #6.

Reviewed By: xich

Differential Revision: D5000220

fbshipit-source-id: b713931
@almostimplemented
Copy link
Author

Thanks -- and sorry: I hadn't seen #6 before raising the issue.

@camerondavison
Copy link

I am on mac 10.12.3 and ran brew install pcre and have pcre-8.40 installed, but it does not seem to have worked for me. Anything else that needs to be installed?

@niteria
Copy link

niteria commented May 9, 2017

Hmm, interesting.

What does brew info pcre say?
What are the contents of /usr/local/Cellar/pcre/?
What does gcc -lpcre say?
Is the error message the same as above? If not, can you paste it?

@schultz-is
Copy link

i see the same issue. installing pcre from homebrew does install the development headers, but maybe not in the location the compiler is looking for

[10:36:52] schultz @ crux : ~/Repositories/duckling
% brew info pcre
pcre: stable 8.40 (bottled), HEAD
Perl compatible regular expressions library
http://www.pcre.org/
/usr/local/Cellar/pcre/8.40 (204 files, 5.4MB) *
  Built from source on 2017-05-09 at 10:34:10
From: https://github.com/Homebrew/homebrew-core/blob/master/Formula/pcre.rb

[10:36:57] schultz @ crux : ~/Repositories/duckling
% ls /usr/local/Cellar/pcre
8.40

[10:37:03] schultz @ crux : ~/Repositories/duckling
% ls /usr/local/Cellar/pcre/8.40/include
pcre.h  pcre_scanner.h  pcre_stringpiece.h  pcrecpp.h  pcrecpparg.h  pcreposix.h

this is on macOS Sierra 10.12.4

@niteria
Copy link

niteria commented May 9, 2017

@schultz-texas

What does gcc -lpcre return?
How about gcc --version?

@schultz-is
Copy link

[10:55:27] schultz @ crux : ~/Repositories/duckling
% gcc -lpcre
Undefined symbols for architecture x86_64:
  "_main", referenced from:
     implicit entry/start for main executable
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

[10:55:30] schultz @ crux : ~/Repositories/duckling
% gcc --version
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
Apple LLVM version 8.0.0 (clang-800.0.42.1)
Target: x86_64-apple-darwin16.5.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin

i get the same result with actual gcc:

[10:56:24] schultz @ crux : ~/Repositories/duckling
% /usr/local/bin/gcc-7 -lpcre
Undefined symbols for architecture x86_64:
  "_main", referenced from:
     implicit entry/start for main executable
ld: symbol(s) not found for architecture x86_64
collect2: error: ld returned 1 exit status

@niteria
Copy link

niteria commented May 9, 2017

That does look reasonable, are you compiling with stack?
Can you paste the compile error you get?

@schultz-is
Copy link

figured it out. the default pcre install doesn't seem to include development headers. submitted a pull request (#10) that includes updated documentation to pull source along with pcre homebrew package

@camerondavison
Copy link

I did

brew uninstall --ignore-dependencies pcre
HOMEBREW_BUILD_FROM_SOURCE=1 brew install pcre

then ran

stack build

and get

regex-pcre-0.94.4: configure
transformers-compat-0.5.1.4: download
timezone-series-0.1.6.1: download
haskell-src-exts-1.18.2: download
regex-pcre-0.94.4: build
timezone-series-0.1.6.1: configure
timezone-series-0.1.6.1: build
transformers-compat-0.5.1.4: configure
transformers-compat-0.5.1.4: build
haskell-src-exts-1.18.2: configure
haskell-src-exts-1.18.2: build
timezone-series-0.1.6.1: copy/register
transformers-compat-0.5.1.4: copy/register
haskell-src-exts-1.18.2: copy/register
Progress: 4/28
--  While building package regex-pcre-0.94.4 using:
      /Users/cameron/.stack/setup-exe-cache/x86_64-osx/Cabal-simple_mPHDZzAJ_1.24.2.0_ghc-8.0.2 --builddir=.stack-work/dist/x86_64-osx/Cabal-1.24.2.0 build --ghc-options " -ddump-hi -ddump-to-file"
    Process exited with code: ExitFailure 1
    Logs have been written to: /Users/cameron/Code/duckling/.stack-work/logs/regex-pcre-0.94.4.log

    Configuring regex-pcre-0.94.4...
    Building regex-pcre-0.94.4...
    Preprocessing library regex-pcre-0.94.4...
    Wrap.hsc:148:10: fatal error: 'pcre.h' file not found    #include <pcre.h>
             ^
    1 error generated.
    compiling .stack-work/dist/x86_64-osx/Cabal-1.24.2.0/build/Text/Regex/PCRE/Wrap_hsc_make.c failed (exit code 1)
    command was: /usr/bin/gcc -c .stack-work/dist/x86_64-osx/Cabal-1.24.2.0/build/Text/Regex/PCRE/Wrap_hsc_make.c -o .stack-work/dist/x86_64-osx/Cabal-1.24.2.0/build/Text/Regex/PCRE/Wrap_hsc_make.o -m64 -fno-stack-protector -m64 -fno-stack-protector -m64 -D__GLASGOW_HASKELL__=800 -Ddarwin_BUILD_OS=1 -Dx86_64_BUILD_ARCH=1 -Ddarwin_HOST_OS=1 -Dx86_64_HOST_ARCH=1 -DHAVE_PCRE_H -DSPLIT_BASE=1 -I.stack-work/dist/x86_64-osx/Cabal-1.24.2.0/build/autogen -include .stack-work/dist/x86_64-osx/Cabal-1.24.2.0/build/autogen/cabal_macros.h -I/Users/cameron/.stack/programs/x86_64-osx/ghc-8.0.2/lib/ghc-8.0.2/bytestring-0.10.8.1/include -I/Users/cameron/.stack/programs/x86_64-osx/ghc-8.0.2/lib/ghc-8.0.2/base-4.9.1.0/include -I/Users/cameron/.stack/programs/x86_64-osx/ghc-8.0.2/lib/ghc-8.0.2/integer-gmp-1.0.0.1/include -I/Users/cameron/.stack/programs/x86_64-osx/ghc-8.0.2/lib/ghc-8.0.2/include -I/Users/cameron/.stack/programs/x86_64-osx/ghc-8.0.2/lib/ghc-8.0.2/include/
$ brew info pcre
pcre: stable 8.40 (bottled), HEAD
Perl compatible regular expressions library
http://www.pcre.org/
/usr/local/Cellar/pcre/8.40 (204 files, 5.3MB) *
  Built from source on 2017-05-09 at 14:25:15
From: https://github.com/Homebrew/homebrew-core/blob/master/Formula/pcre.rb
/usr/local/Cellar/pcre/
└── 8.40
    ├── AUTHORS
    ├── COPYING
    ├── ChangeLog
    ├── INSTALL_RECEIPT.json
    ├── LICENCE
    ├── NEWS
    ├── README
    ├── bin
    │   ├── pcre-config
    │   ├── pcregrep
    │   └── pcretest
    ├── include
    │   ├── pcre.h
    │   ├── pcre_scanner.h
    │   ├── pcre_stringpiece.h
    │   ├── pcrecpp.h
    │   ├── pcrecpparg.h
    │   └── pcreposix.h
    ├── lib
    │   ├── libpcre.1.dylib
    │   ├── libpcre.a
    │   ├── libpcre.dylib -> libpcre.1.dylib
    │   ├── libpcre16.0.dylib
    │   ├── libpcre16.a
    │   ├── libpcre16.dylib -> libpcre16.0.dylib
    │   ├── libpcre32.0.dylib
    │   ├── libpcre32.a
    │   ├── libpcre32.dylib -> libpcre32.0.dylib
    │   ├── libpcrecpp.0.dylib
    │   ├── libpcrecpp.a
    │   ├── libpcrecpp.dylib -> libpcrecpp.0.dylib
    │   ├── libpcreposix.0.dylib
    │   ├── libpcreposix.a
    │   ├── libpcreposix.dylib -> libpcreposix.0.dylib
    │   └── pkgconfig
    │       ├── libpcre.pc
    │       ├── libpcre16.pc
    │       ├── libpcre32.pc
    │       ├── libpcrecpp.pc
    │       └── libpcreposix.pc

... clipped out share/docs/man

$ gcc -lpcre
Undefined symbols for architecture x86_64:
  "_main", referenced from:
     implicit entry/start for main executable
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

@schultz-is
Copy link

well dang. i'll run back through my terminal history and see if there is some other intermediate step or path that caused it to work for me

@niteria
Copy link

niteria commented May 9, 2017

Ok, I checked on my system and gcc finds pcre.h in /usr/local/include/.
I've checked that it's brew that installs it there.

I'd suggest running brew doctor and fix the issues that it detects.
I expect it to find the issue described here: http://stackoverflow.com/questions/14527521/brew-doctor-says-warning-usr-local-include-isnt-writable

It may be that you'll have to reinstall pcre after you make /usr/local/include writable.

@schultz-is
Copy link

yeah, it's strange. seems to work fine on other machines for me. i can only imagine the reinstall of pcre i did fixed the issue for me. went ahead and closed out the pull request i opened since it now seems unrelated

facebook-github-bot pushed a commit that referenced this issue May 9, 2017
Summary:
Turns out that `brew` can succeed installing `pcre`, but still
not install development headers in `/usr/local/include/`
if that path is not writable. `brew doctor` should find that
and related problems.

Relevant ticket: #8

Reviewed By: patapizza, JonCoens

Differential Revision: D5031503

fbshipit-source-id: ba0b8e8
@camerondavison
Copy link

I ran brew config and noticed that it said

Xcode: 8.3.2
CLT: N/A

So I installed CLT by running

xcode-select --install

Then I upgraded gcc from 5.3.0 to 7.1.0 using

brew upgrade gcc

and it I was then able to compile everything

@mickume
Copy link

mickume commented Aug 9, 2017

The above worked for me as well, compiling is now OK after I installed gcc from brew.

serapio added a commit to cisco/duckling that referenced this issue Oct 14, 2022
…g-build

Updated Dockerfile to include LANG variable
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants