[Nix-dev] How to build a Haskell binding to a C++ library (OpenCV) on OS X
Linus
acc at sphalerite.org
Tue Jun 20 00:17:50 CEST 2017
On 19 June 2017 18:05:36 BST, Bas van Dijk <v.dijk.bas at gmail.com> 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 <vincent.laporte at gmail.com>
>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
>> nix-dev at lists.science.uu.nl
>> 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
More information about the nix-dev
mailing list