Re: Compiling regex-posix-0.93.2 on windows

I am not sure what is going wrong. I have not been using Haskell on windows. I am also copying this reply to haskell-cafe and libaries mailing lists. Does anyone know? Parnell Flynn wrote:
I am having a terrible time compiling the 0.93.2 version of the regex-posix library on windows XP.
I have Cygwin and MinGW installed and I have a version of the regex.h header in C:/cygwin/usr/include what shared libraries do I need?
Here is a copy of the error it finds the include but is unable to link.
This links to the standard c library version of regular expressions.
The corresponding c header file is regex.h and there is a chance you
will need to edit the end of the regex-posix.cabal file to find the
include directory and/or library.
Preprocessing library regex-posix-0.93.2...
dist/build/Text/Regex/Posix/Wrap_hsc_make.o(.text+0x85):Wrap_hsc_make.c: undefined reference to `_impure_ptr'
dist/build/Text/Regex/Posix/Wrap_hsc_make.o(.text+0xc9):Wrap_hsc_make.c: undefined reference to `_impure_ptr'
dist/build/Text/Regex/Posix/Wrap_hsc_make.o(.text+0xf1):Wrap_hsc_make.c: undefined reference to `_impure_ptr'
dist/build/Text/Regex/Posix/Wrap_hsc_make.o(.text+0x125):Wrap_hsc_make.c: undefined reference to `_impure_ptr'
dist/build/Text/Regex/Posix/Wrap_hsc_make.o(.text+0x159):Wrap_hsc_make.c: undefined reference to `_impure_ptr'
dist/build/Text/Regex/Posix/Wrap_hsc_make.o(.text+0x18d):Wrap_hsc_make.c: more undefined references to `_impure_ptr' follow
collect2: ld returned 1 exit status
linking dist\build\Text\Regex\Posix\Wrap_hsc_make.o failed
command was: y:\ghc\ghc-6.8.2\bin\ghc.exe -optl-LC:/cygwin/lib dist\build\Text\Regex\Posix\Wrap_hsc_make.o -o dist\build\Text\Regex\Posix\Wrap_hsc_make.exe
bash-3.2$
Thanks,
Parnell
Parnell Flynn • 230 South Lasalle Street • Suite 400 • Chicago, IL 60604 • 312.244.5317 (o) • parnell___.flynn@ronin-capital.com_ mailto:parnell.flynn@ronin-capital.com

Hi Chris et al:
On Fri, Oct 17, 2008 at 4:33 PM, Chris Kuklewicz
I am not sure what is going wrong. I have not been using Haskell on windows. I am also copying this reply to haskell-cafe and libaries mailing lists. Does anyone know?
I get passed that error on Cygwin by installing it like this: $ cabal update $ cabal install --extra-include-dirs="c:\cygwin\usr\include" regex-posix However, when I try using regex-posix, I get: $ ghci GHCi, version 6.10.1: http://www.haskell.org/ghc/ :? for help Loading package ghc-prim ... linking ... done. Loading package integer ... linking ... done. Loading package base ... linking ... done. Prelude> import Text.Regex.Posix Prelude Text.Regex.Posix> "Hello World" =~ "W" :: String Loading package syb ... linking ... done. Loading package base-3.0.3.0 ... linking ... done. Loading package array-0.2.0.0 ... linking ... done. Loading package containers-0.2.0.0 ... linking ... done. Loading package bytestring-0.9.1.4 ... linking ... done. Loading package mtl-1.1.0.2 ... linking ... done. Loading package regex-base-0.93.1 ... linking ... done. Loading package regex-posix-0.93.2 ... linking ... ghci-haskeline.exe: unable to load package `regex-posix-0.93.2' Prelude Text.Regex.Posix> :q Leaving GHCi. <interactive>: C:\Program Files\Haskell\regex-posix-0.93.2\ghc-6.10.1\HSregex-posix-0.93.2.o: unknown symbol `_regerror' Compiling reveals more details: $ cat > reg.hs << EOF
import Text.Regex.Posix
test = "Hello World!" =~ "W" :: String
main = putStrLn test EOF
$ ghc --make reg.hs Linking reg.exe ... C:\Program Files\Haskell\regex-posix-0.93.2\ghc-6.10.1/libHSregex-posix-0.93.2.a(Wrap.o):fake:(.text+0xa2f): undefined reference to `regerror' C:\Program Files\Haskell\regex-posix-0.93.2\ghc-6.10.1/libHSregex-posix-0.93.2.a(Wrap.o):fake:(.text+0xa83): undefined reference to `regerror' C:\Program Files\Haskell\regex-posix-0.93.2\ghc-6.10.1/libHSregex-posix-0.93.2.a(Wrap.o):fake:(.text+0xb6b): undefined reference to `regfree' C:\Program Files\Haskell\regex-posix-0.93.2\ghc-6.10.1/libHSregex-posix-0.93.2.a(Wrap.o):fake:(.text+0xd39): undefined reference to `regcomp' C:\Program Files\Haskell\regex-posix-0.93.2\ghc-6.10.1/libHSregex-posix-0.93.2.a(Wrap.o):fake:(.text+0xf8f): undefined reference to `regexec' C:\Program Files\Haskell\regex-posix-0.93.2\ghc-6.10.1/libHSregex-posix-0.93.2.a(Wrap.o):fake:(.text+0x3656): undefined reference to `regexec' C:\Program Files\Haskell\regex-posix-0.93.2\ghc-6.10.1/libHSregex-posix-0.93.2.a(Wrap.o):fake:(.text+0x3aaa): undefined reference to `regexec' C:\Program Files\Haskell\regex-posix-0.93.2\ghc-6.10.1/libHSregex-posix-0.93.2.a(Wrap.o):fake:(.text+0x3e06): undefined reference to `regexec' C:\Program Files\Haskell\regex-posix-0.93.2\ghc-6.10.1/libHSregex-posix-0.93.2.a(Wrap.o):fake:(.text+0x4bcd): undefined reference to `regexec' C:\Program Files\Haskell\regex-posix-0.93.2\ghc-6.10.1/libHSregex-posix-0.93.2.a(Wrap.o):fake:(.text+0x512e): more undefined references to `regexec' follow collect2: ld returned 1 exit status Any ideas? I feel like I'm missing something very simple. Thanks, Paulo

Paulo: I suggest doing this more carefully. Get the source from hackage. Edit the regex-posix.cabal file to add the include and lib directories you need on Cygwin. cabal "configure" it. cabal "build" it. cabal "install" it. Then in an unrelated directory try and run "ghci -package regex-posix". This should load regex-posix-VERSION. If this fails then I think that the cabal file needs fixing. If that works then please test it with these commands:
Prelude> :m + Text.Regex.Posix Prelude Text.Regex.Posix> (Text.Regex.Posix.=~) "ab" "(()|[ab])(b)" :: (String,String,String,[String])
The right answer by the way is:
("","ab","",["a","","b"])
But on FreeBSD/NetBSD/OS X there is a bug that I have found and it prints:
("a","b","",["","","b"])
Which just goes to show that a mountain of QuickCheck is what is sometimes needed to catch really hard to trigger bugs. This is the other bug I reported:
Prelude Text.Regex.Posix> (Text.Regex.Posix.=~) "XababaY" "(X)(aba|ab|b)*(Y)" :: (String,String,String,[String]) ("","XababaY","",["X","b","Y"])
The above answer is impossible (what matched "a" next to "b"?), but I now think I know WTF the library code is doing wrong (I think it is matching "ababa" in two passes and the second pass is greedy which is a broken strategy). The right answer is:
("","XababaY","",["X","aba","Y"])
Cheers, Chris PS: Yes, I have reported these bug to Apple, FreeBSD, and NetBSD this month.

On Thu, 2009-01-15 at 22:00 +0000, ChrisK wrote:
Paulo: I suggest doing this more carefully.
Get the source from hackage.
Edit the regex-posix.cabal file to add the include and lib directories you need on Cygwin.
I should note that you do not need to edit the .cabal file to do this. As of Cabal-1.4 there are extra command line flags to configure (or equivalently to cabal install) --extra-include-dirs=dir --extra-lib-dirs=dir Duncan

Duncan,
On Thu, Jan 15, 2009 at 4:35 PM, Duncan Coutts
I should note that you do not need to edit the .cabal file to do this. As of Cabal-1.4 there are extra command line flags to configure (or equivalently to cabal install)
--extra-include-dirs=dir --extra-lib-dirs=dir
Duncan
Thanks, Duncan, I did notice those flags and was using them. It's a nice addition! Paulo

I should note that you do not need to edit the .cabal file to do this. As of Cabal-1.4 there are extra command line flags to configure (or equivalently to cabal install)
--extra-include-dirs=dir --extra-lib-dirs=dir
Duncan
I have seen the new cabal arguments. All I was giving was debugging advice on a platform I have never tested on. And regex-posix has a very "old school" Setup.hs file with a small addition:
#!/usr/bin/env runhaskell
-- I usually compile this with "ghc --make -o setup Setup.hs"
import Distribution.Simple(defaultMainWithHooks, defaultUserHooks) main = do putStrLn msg defaultMainWithHooks defaultUserHooks
msg = "This links to the standard c library version of regular expressions.\n\ \The corresponding c header file is regex.h and there is a chance you\n\ \will need to edit the end of the regex-posix.cabal file to find the\n\ \include directory and/or library.\n"
Hmmm...the next version will probably need to mention the cabal command line flags as well.

On Fri, 2009-01-16 at 21:17 +0000, Chris Kuklewicz wrote:
And regex-posix has a very "old school" Setup.hs file with a small addition:
#!/usr/bin/env runhaskell
-- I usually compile this with "ghc --make -o setup Setup.hs"
import Distribution.Simple(defaultMainWithHooks, defaultUserHooks) main = do putStrLn msg defaultMainWithHooks defaultUserHooks
msg = "This links to the standard c library version of regular expressions.\n\ \The corresponding c header file is regex.h and there is a chance you\n\ \will need to edit the end of the regex-posix.cabal file to find the\n\ \include directory and/or library.\n"
Hmmm...the next version will probably need to mention the cabal command line flags as well.
Perhaps you'd like to help us implement this ticket: Check for required C libraries during configure http://hackage.haskell.org/trac/hackage/ticket/262 As part of that ticket we should make sure the error message explains what it was that the package needed and what to do if they are in a non-standard location. The implementation basically just needs to do exactly what autoconf does in this circumstance, compile a little .c program. We have one advantage which is that we can probably do it faster in the best case since we ought to be able to make one .c program and try linking it against everything, rather than doing one compile for each C lib and C header. Of course if it fails then we have to go and do it for each one individually to figure out which is the cause of the problem. Duncan

Hi Chris,
Good call, I'm following your advice. ghci fails to load with the
package that it seemed to compile just fine. Here are some details
(also see file attached).
Thank you!
Paulo
$ wget http://hackage.haskell.org/packages/archive/regex-posix/0.93.2/regex-posix-0...
$ vim regex-posix.cabal
-----------------------------------------------------------------
CC-Options: -DHAVE_REGEX_H
-- Includes:
Include-Dirs: f:\cygwin\usr\include
-- Extra-Libraries:
-- Extra-Lib-Dirs:
-----------------------------------------------------------------
$ ghci -package regex-posix
WARNING: GHCi invoked via 'ghci.exe' in *nix-like shells (cygwin-bash,
in particular)
doesn't handle Ctrl-C well; use the 'ghcii.sh' shell wrapper instead
GHCi, version 6.10.1: http://www.haskell.org/ghc/ :? for help
Loading package ghc-prim ... linking ... done.
Loading package integer ... linking ... done.
Loading package base ... linking ... done.
Loading package syb ... linking ... done.
Loading package array-0.2.0.0 ... linking ... done.
Loading package base-3.0.3.0 ... linking ... done.
Loading package bytestring-0.9.1.4 ... linking ... done.
Loading package containers-0.2.0.0 ... linking ... done.
Loading package mtl-1.1.0.2 ... linking ... done.
Loading package regex-base-0.93.1 ... linking ... done.
Loading package regex-posix-0.93.2 ... linking ... : unable to load
package `regex-posix-0.93.2'
:
C:\Program Files\Haskell\regex-posix-0.93.2\ghc-6.10.1\HSregex-posix-0.93.2.o:
unknown symbol `_regerror'
On Thu, Jan 15, 2009 at 4:00 PM, ChrisK
Paulo: I suggest doing this more carefully.
Get the source from hackage.
Edit the regex-posix.cabal file to add the include and lib directories you need on Cygwin.
cabal "configure" it.
cabal "build" it.
cabal "install" it.
Then in an unrelated directory try and run "ghci -package regex-posix". This should load regex-posix-VERSION. If this fails then I think that the cabal file needs fixing.
If that works then please test it with these commands:
Prelude> :m + Text.Regex.Posix Prelude Text.Regex.Posix> (Text.Regex.Posix.=~) "ab" "(()|[ab])(b)" :: (String,String,String,[String])
The right answer by the way is:
("","ab","",["a","","b"])
But on FreeBSD/NetBSD/OS X there is a bug that I have found and it prints:
("a","b","",["","","b"])
Which just goes to show that a mountain of QuickCheck is what is sometimes needed to catch really hard to trigger bugs.
This is the other bug I reported:
Prelude Text.Regex.Posix> (Text.Regex.Posix.=~) "XababaY" "(X)(aba|ab|b)*(Y)" :: (String,String,String,[String]) ("","XababaY","",["X","b","Y"])
The above answer is impossible (what matched "a" next to "b"?), but I now think I know WTF the library code is doing wrong (I think it is matching "ababa" in two passes and the second pass is greedy which is a broken strategy). The right answer is:
("","XababaY","",["X","aba","Y"])
Cheers, Chris
PS: Yes, I have reported these bug to Apple, FreeBSD, and NetBSD this month.
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
participants (4)
-
Chris Kuklewicz
-
ChrisK
-
Duncan Coutts
-
Paulo Tanimoto