Re: [Nix-dev] How to build a Haskell binding to a C++ library (OpenCV) on OS X

2017-06-19 Thread Linus
On 19 June 2017 18:05:36 BST, Bas van Dijk  wrote:
>Thanks Vincent, you are spot on!
>
>I went with the following change:
>
>https://github.com/LumiGuide/haskell-opencv/commit/6b78bc4c431d693b0bc828cc86708882a26f777c
>
>Bas
>
>On 19 June 2017 at 17:00, Vincent Laporte 
>wrote:
>
>> Hi,
>>
>> Notice that if you replace the two occurrences of ‘g++’ by ‘clang++’
>in
>> the file ‘opencv/Setup.hs’, then ‘nix-build’ succeeds.
>>
>> This issue might be reported upstream: they apparently need a
>configure
>> step to select the correct name of the C++ compiler.
>>
>> The following patch also appears to make ‘nix-build’ work.
>>
>> Regards,
>> --
>> Vincent.
>>
>> ```
>> diff --git a/opencv/Setup.hs b/opencv/Setup.hs
>> index 031daa1..3c92176 100644
>> --- a/opencv/Setup.hs
>> +++ b/opencv/Setup.hs
>> @@ -3,6 +3,6 @@ import System.Environment ( getArgs )
>>
>>  main = do
>>  args <- getArgs
>> -let args' | "configure" `elem` args = args ++
>["--with-gcc","g++",
>> "--with-ld","g++"]
>> +let args' | "configure" `elem` args = args
>>| otherwise   = args
>>  defaultMainArgs args'
>> diff --git a/opencv/opencv.nix b/opencv/opencv.nix
>> index a28674c..80ed995 100644
>> --- a/opencv/opencv.nix
>> +++ b/opencv/opencv.nix
>> @@ -103,8 +103,8 @@ mkDerivation ({
>>libraryPkgconfigDepends = [ opencv3 ];
>>
>>configureFlags =
>> -[ "--with-gcc=g++"
>> -  "--with-ld=g++"
>> +[ "--with-gcc=${stdenv.cc}/bin/c++"
>> +  "--with-ld=${stdenv.cc}/bin/c++"
>>  ];
>>
>>hardeningDisable = [ "bindnow" ];
>> ```
>> ___
>> nix-dev mailing list
>> [email protected]
>> https://mailman.science.uu.nl/mailman/listinfo/nix-dev
>>

I believe stdenv also sets the CC and CXX environment variables to the 
preferred C compiler, which could be useful to avoid additional nix code.

Linus
___
nix-dev mailing list
[email protected]
https://mailman.science.uu.nl/mailman/listinfo/nix-dev


Re: [Nix-dev] How to build a Haskell binding to a C++ library (OpenCV) on OS X

2017-06-19 Thread Bas van Dijk
Thanks Vincent, you are spot on!

I went with the following change:

https://github.com/LumiGuide/haskell-opencv/commit/6b78bc4c431d693b0bc828cc86708882a26f777c

Bas

On 19 June 2017 at 17:00, Vincent Laporte  wrote:

> Hi,
>
> Notice that if you replace the two occurrences of ‘g++’ by ‘clang++’ in
> the file ‘opencv/Setup.hs’, then ‘nix-build’ succeeds.
>
> This issue might be reported upstream: they apparently need a configure
> step to select the correct name of the C++ compiler.
>
> The following patch also appears to make ‘nix-build’ work.
>
> Regards,
> --
> Vincent.
>
> ```
> diff --git a/opencv/Setup.hs b/opencv/Setup.hs
> index 031daa1..3c92176 100644
> --- a/opencv/Setup.hs
> +++ b/opencv/Setup.hs
> @@ -3,6 +3,6 @@ import System.Environment ( getArgs )
>
>  main = do
>  args <- getArgs
> -let args' | "configure" `elem` args = args ++ ["--with-gcc","g++",
> "--with-ld","g++"]
> +let args' | "configure" `elem` args = args
>| otherwise   = args
>  defaultMainArgs args'
> diff --git a/opencv/opencv.nix b/opencv/opencv.nix
> index a28674c..80ed995 100644
> --- a/opencv/opencv.nix
> +++ b/opencv/opencv.nix
> @@ -103,8 +103,8 @@ mkDerivation ({
>libraryPkgconfigDepends = [ opencv3 ];
>
>configureFlags =
> -[ "--with-gcc=g++"
> -  "--with-ld=g++"
> +[ "--with-gcc=${stdenv.cc}/bin/c++"
> +  "--with-ld=${stdenv.cc}/bin/c++"
>  ];
>
>hardeningDisable = [ "bindnow" ];
> ```
> ___
> nix-dev mailing list
> [email protected]
> https://mailman.science.uu.nl/mailman/listinfo/nix-dev
>
___
nix-dev mailing list
[email protected]
https://mailman.science.uu.nl/mailman/listinfo/nix-dev


Re: [Nix-dev] How to build a Haskell binding to a C++ library (OpenCV) on OS X

2017-06-19 Thread Vincent Laporte
Hi,

Notice that if you replace the two occurrences of ‘g++’ by ‘clang++’ in
the file ‘opencv/Setup.hs’, then ‘nix-build’ succeeds.

This issue might be reported upstream: they apparently need a configure
step to select the correct name of the C++ compiler.

The following patch also appears to make ‘nix-build’ work.

Regards,
--
Vincent.

```
diff --git a/opencv/Setup.hs b/opencv/Setup.hs
index 031daa1..3c92176 100644
--- a/opencv/Setup.hs
+++ b/opencv/Setup.hs
@@ -3,6 +3,6 @@ import System.Environment ( getArgs )

 main = do
 args <- getArgs
-let args' | "configure" `elem` args = args ++ ["--with-gcc","g++",
"--with-ld","g++"]
+let args' | "configure" `elem` args = args
   | otherwise   = args
 defaultMainArgs args'
diff --git a/opencv/opencv.nix b/opencv/opencv.nix
index a28674c..80ed995 100644
--- a/opencv/opencv.nix
+++ b/opencv/opencv.nix
@@ -103,8 +103,8 @@ mkDerivation ({
   libraryPkgconfigDepends = [ opencv3 ];

   configureFlags =
-[ "--with-gcc=g++"
-  "--with-ld=g++"
+[ "--with-gcc=${stdenv.cc}/bin/c++"
+  "--with-ld=${stdenv.cc}/bin/c++"
 ];

   hardeningDisable = [ "bindnow" ];
``` 
___
nix-dev mailing list
[email protected]
https://mailman.science.uu.nl/mailman/listinfo/nix-dev


Re: [Nix-dev] How to build a Haskell binding to a C++ library (OpenCV) on OS X

2017-06-19 Thread Laverne Schrock
On Sun, 2017-06-18 at 21:47 +0200, Bas van Dijk wrote:
> Good evening,
> 
> I'm trying to build our Haskell binding to the OpenCV C++ library on
> OS X. The following commands should do the job:
> 
>   git clone https://github.com/LumiGuide/haskell-opencv.git
>   cd opencv
>   nix-build
> 
> Unfortunately it fails during the configure phase with:
> 
>   Setup: Cannot find the program 'gcc'.   User-specified path 'g++'
> does not refer  to an executable and the program is not on the system
> path.
> 
> If I add gcc to the build dependencies of opencv/opencv.nix using: 
> 
>   buildDepends = [ gcc ];
> 
> and invoke nix-build again I get a different error:
> 
>   Setup: Missing dependencies on foreign libraries:  * Missing C
> libraries: stdc++, opencv_stitching, opencv_superres, 
> opencv_videostab, opencv_aruco, opencv_bgsegm, opencv_bioinspired, 
> opencv_ccalib, opencv_dpm, opencv_freetype, opencv_fuzzy, 
> opencv_line_descriptor, opencv_optflow, opencv_reg, opencv_saliency, 
> opencv_stereo, opencv_structured_light, opencv_phase_unwrapping,
> opencv_rgbd,  opencv_surface_matching, opencv_tracking,
> opencv_datasets, opencv_text,  opencv_face, opencv_plot, opencv_dnn,
> opencv_xfeatures2d, opencv_shape,  opencv_video, opencv_ximgproc,
> opencv_calib3d, opencv_features2d,  opencv_flann, opencv_xobjdetect,
> opencv_objdetect, opencv_ml, opencv_xphoto,  opencv_highgui,
> opencv_videoio, opencv_imgcodecs, opencv_photo,  opencv_imgproc,
> opencv_core  This problem can usually be solved by installing the
> system packages that  provide these libraries (you may need the "-
> dev" versions). If the libraries  are already installed but in a non-
> standard location then you can use the  flags --extra-include-dirs=
> and --extra-lib-dirs= to specify where they are.
> 
> Any ideas how to get this working?
> 
> Regards,
> 
> Bas
> 

Have you tried adding opencv as a buildInput? Maybe something like:

`buildInputs = [ stdenv opencv3 ] ;`?

But I have no idea what `libraryPkgconfigDepends = [ opencv3 ];` is
supposed to be doing.___
nix-dev mailing list
[email protected]
https://mailman.science.uu.nl/mailman/listinfo/nix-dev


Re: [Nix-dev] How to build a Haskell binding to a C++ library (OpenCV) on OS X

2017-06-18 Thread Bas van Dijk
I forgot to mention that the following does work:

  git clone https://github.com/LumiGuide/haskell-opencv.git
  cd opencv
  nix-shell
  cabal configure -v
  cabal build

In this case cabal is using the g++ from /usr/bin instead of the one from
the nix store since I'm using an impure nix-shell:

  Using gcc version 4.2.1 given by user at: /usr/bin/g++

Bas

On 18 June 2017 at 21:47, Bas van Dijk  wrote:

> Good evening,
>
> I'm trying to build our Haskell binding to the OpenCV C++ library on OS X.
> The following commands should do the job:
>
>   git clone https://github.com/LumiGuide/haskell-opencv.git
>   cd opencv
>   nix-build
>
> Unfortunately it fails during the configure phase with:
>
>   Setup: Cannot find the program 'gcc'.
>   User-specified path 'g++' does not refer
>   to an executable and the program is not on the system path.
>
> If I add gcc to the build dependencies of opencv/opencv.nix using:
>
>   buildDepends = [ gcc ];
>
> and invoke nix-build again I get a different error:
>
>   Setup: Missing dependencies on foreign libraries:
>   * Missing C libraries: stdc++, opencv_stitching, opencv_superres,
>   opencv_videostab, opencv_aruco, opencv_bgsegm, opencv_bioinspired,
>   opencv_ccalib, opencv_dpm, opencv_freetype, opencv_fuzzy,
>   opencv_line_descriptor, opencv_optflow, opencv_reg, opencv_saliency,
>   opencv_stereo, opencv_structured_light,
> opencv_phase_unwrapping, opencv_rgbd,
>   opencv_surface_matching, opencv_tracking, opencv_datasets, opencv_text,
>   opencv_face, opencv_plot, opencv_dnn, opencv_xfeatures2d, opencv_shape,
>   opencv_video, opencv_ximgproc, opencv_calib3d, opencv_features2d,
>   opencv_flann, opencv_xobjdetect, opencv_objdetect, opencv_ml,
> opencv_xphoto,
>   opencv_highgui, opencv_videoio, opencv_imgcodecs, opencv_photo,
>   opencv_imgproc, opencv_core
>   This problem can usually be solved by installing the system packages that
>   provide these libraries (you may need the "-dev" versions). If the
> libraries
>   are already installed but in a non-standard location then you can use the
>   flags --extra-include-dirs= and --extra-lib-dirs= to specify where they
> are.
>
> Any ideas how to get this working?
>
> Regards,
>
> Bas
>
___
nix-dev mailing list
[email protected]
https://mailman.science.uu.nl/mailman/listinfo/nix-dev