在Win7上使用Autoconf安装Haskell的CUDA [英] Install CUDA for Haskell using Autoconf on Win7

查看:243
本文介绍了在Win7上使用Autoconf安装Haskell的CUDA的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在Windows上使用Cygwin安装以下Haskell软件包:

p>

您可以使用cabal install cuda安装软件包。



以下是我得到的输出(您可能必须先cuda install c2hs):

  $ cabal install 
配置cuda-0.4.0.2 ...
检查gcc ... C:\ Haskell\2011.4.0.0\mingw\bin \ gcc.exe
检查C编译器的默认输出文件名...
configure:error:C编译器无法创建可执行文件
请参阅`config.log'以获取更多详细信息。
正在解析依赖关系...
cabal.exe:错误:某些程序包未能安装:
cuda-0.4.0.2在配置步骤中失败。例外情况是:
ExitFailure 77

日志文件中的相关部分是: p>

  configure:1758:检查gcc 
configure:1785:result:C:\ Haskell\2011.4.0.0\\ \\明确\ bin \ gcc.exe
配置:2022:检查C编译器版本
配置:2029:C:\ Haskell\2011.4.0.0\mingw\bin\gcc .exe --version>& 5
configure:line 2030:C:\Haskell\2011.4.0.0\mingw\bin\gcc.exe:找不到命令
configure: 2035:$? = 127
configure:2042:C:\Haskell\2011.4.0.0\mingw\bin\gcc.exe -v>& 5
configure:line 2043:C:\\ \\ Haskell \ 2011.4.0.0\mingw\bin\gcc.exe:找不到命令
configure:2045:$? = 127
configure:2052:C:\Haskell\2011.4.0.0\mingw\bin\gcc.exe -V>& 5
configure:line 2053:C:\\ \\ Haskell \ 2011.4.0.0\mingw\bin\gcc.exe:找不到命令
configure:2055:$? = 127
configure:2078:检查C编译器的默认输出文件名
configure:2105:C:\ Haskell\2011.4.0.0\mingw\bin\gcc.exe -fno- stack-protector conftest.c>& 5
configure:line 2106:C:\Haskell\2011.4.0.0\mingw\bin\gcc.exe:找不到命令
configure :2108:$? = 127
configure:2146:result:
configure:失败的程序是:[source elided]

如果我去Cygwin并输入

  gcc --version 

我得到合理的东西。这个问题似乎更多与我猜想的路径,但我不知道什么/如何解决它。我还应该注意,使用cabal install cuda-0.2.2这个软件包的旧版本,我会经过这一步(但稍后会得到一个不同的错误)。

<要复制,请确保将Haskell平台安装在没有空格的路径中,否则您可能会得到不同的错误。这是我迄今为止唯一想到的。



任何有关这方面的帮助都会得到很大的赞赏,我已经花了大约一个星期到目前为止还没有得到



编辑:

  $ PATH = C:\ Haskell\2011.4.0.0\mingw\bin; 
C:\Haskell\2011.4.0.0\lib\extralibs\bin;
C:\Haskell\2011.4.0.0\bin;
C:\CUDA\v4.0\bin\;
C:\cygwin\bin\;
...


解决方案

它的安装,但它并不漂亮,我不明白为什么它不会出现在autoconf框。



对于初学者来说,宁可与使用cabal install(使用本地副本)进行安装相比,我使用了顺序

 > runhaskell Setup.hs configure 
> runhaskell Setup.hs build
> runhaskell Setup.hs install

主要原因是因为使用Setup.hs中的参数更改configure脚本中的$ CC变量非常简单。我怀疑$ CC是给我带来问题的变量。我改变了:

  [(CC,ccProg)
$ b $ p

  [(CC,/ cygdrive / c /cygwin/bin/gcc.exe)

在Setup.hs中,这是gcc与Cygwin。我最初的怀疑是autoconf不喜欢gcc的Windows风格路径,它基于上面的日志文件使用它。我还发现,尽管我的计算机上有多个gcc副本(一个在Haskell / mingw中,一个在单独的mingw安装中,无论哪个版本是$ PATH指向的),只有cygwin gcc能够成功编译测试文件使用cygwin gcc,我可以运行

  gcc hello.c 

,而使用任何其他gcc副本,甚至可以像

  gcc -I / cygdrive / c /..../ include hello.c 

无法找到,不知道为什么。

只需将$ CC改为Cygwin gcc即可解决几乎所有问题检查包含cudaRuntimeGetVersion / cuGetDriverVersion的库时发生了下一个错误。



配置试图编译的文件是

  #define PACKAGE_NAMEHaskell CUDA绑定
#define PACKAGE_TARNAMEcu DA
#定义PACKAGE_VERSION 0.4.0.0
#定义PACKAGE_STRING 哈斯克尔CUDA绑定0.4.0.0
#定义PACKAGE_BUGREPORT tmcdonell@cse.unsw.edu.au
#定义STDC_HEADERS 1
#定义HAVE_SYS_TYPES_H 1个
#定义HAVE_SYS_STAT_H 1个
#定义HAVE_STDLIB_H 1个
#定义HAVE_STRING_H 1个
#定义HAVE_MEMORY_H 1个
#限定HAVE_STRINGS_H 1个
的#define HAVE_INTTYPES_H 1个
的#define HAVE_STDINT_H 1个
的#define HAVE_UNISTD_H 1个
的#define HAVE_CUDA_H 1个
的#define HAVE_CUDA_RUNTIME_API_H 1个
/ *端confdefs.h。 * /

/ *覆盖任何GCC内部原型以避免错误。
使用char是因为int可能与GCC
内置的返回类型相匹配,然后它的参数原型仍然适用。 * /
#ifdef __cplusplus
externC
#endif
char cudaRuntimeGetVersion();
int main()
{
return cudaRuntimeGetVersion();
;
返回0;
}

使用以下命令:

  /cygdrive/c/cygwin/bin/gcc.exe -o conftest.exe -fno堆叠保护器
-I / cygdrive / C / CUDA / V4。 0 / include -L / cygdrive / c / CUDA / v4.0 / lib conftest.c -lcudart

的误差(从日志文件)是

  / cygdrive / C /用户/ crockeea /应用程序数据/本地/温度/ ccKMQJiq .o:conftest.c :(。text + 0xc):
对`_cudaRuntimeGetVersion'
的未定义引用



我的C语言有些生疏,但是好像他们没有在这里包含适当的头文件。这可能是不对的,因为在运行configure时,同一文件在基于Unix的系统上工作,但这是我最好的猜测。此外,编辑配置以使该文件包含cuda.h只会导致关于cudaRuntimeGetVersion的多个定义的不同错误。所以我的破解是在配置文件中引用cudaRuntimeGetVersion / cuGetDriverVersion的注释。我将C注释放入配置文件要编译的C文件中(根据日志文件中的行号,可以很容易地在配置文件中找到这些文件的源代码)。我不知道以这种方式修改配置文件的后果。



这使我能够超越'构建'阶段。更多评论,如果我遇到任何其他问题。


I'm attempting to install the following Haskell package on Windows using Cygwin: HaskellCuda

You can install the package using "cabal install cuda".

Here is the output I get (you may have to "cuda install c2hs" first):

$ cabal install
Configuring cuda-0.4.0.2...
checking for gcc... C:\Haskell\2011.4.0.0\mingw\bin\gcc.exe
checking for C compiler default output file name...
configure: error: C compiler cannot create executables
See `config.log' for more details.
Resolving dependencies...
cabal.exe: Error: some packages failed to install:
cuda-0.4.0.2 failed during the configure step. The exception was:
ExitFailure 77

The relevant part from the log file is:

configure:1758: checking for gcc
configure:1785: result: C:\Haskell\2011.4.0.0\mingw\bin\gcc.exe
configure:2022: checking for C compiler version
configure:2029: C:\Haskell\2011.4.0.0\mingw\bin\gcc.exe --version >&5
configure: line 2030: C:\Haskell\2011.4.0.0\mingw\bin\gcc.exe: command not found
configure:2035: $? = 127
configure:2042: C:\Haskell\2011.4.0.0\mingw\bin\gcc.exe -v >&5
configure: line 2043: C:\Haskell\2011.4.0.0\mingw\bin\gcc.exe: command not found
configure:2045: $? = 127
configure:2052: C:\Haskell\2011.4.0.0\mingw\bin\gcc.exe -V >&5
configure: line 2053: C:\Haskell\2011.4.0.0\mingw\bin\gcc.exe: command not found
configure:2055: $? = 127
configure:2078: checking for C compiler default output file name
configure:2105: C:\Haskell\2011.4.0.0\mingw\bin\gcc.exe -fno-stack-protector   conftest.c  >&5
configure: line 2106: C:\Haskell\2011.4.0.0\mingw\bin\gcc.exe: command not found
configure:2108: $? = 127
configure:2146: result: 
configure: failed program was: [source elided]

If I go to Cygwin and type

gcc --version

I get something reasonable. The problem appears to be more with the path I guess, but I'm not sure what/how to fix it. I should also note that using "cabal install cuda-0.2.2", an older version of this package, I get past this step (but get a different error later).

To replicate, make sure you install the Haskell Platform in a path without spaces, otherwise you will probably get a different error. That's the only thing I've figured out so far.

Any help with this would be GREATLY appreciated, I've spent about a week so far and haven't gotten anywhere.

EDIT:

$PATH = C:\Haskell\2011.4.0.0\mingw\bin;
C:\Haskell\2011.4.0.0\lib\extralibs\bin;
C:\Haskell\2011.4.0.0\bin;
C:\CUDA\v4.0\bin\;
C:\cygwin\bin\;
...

解决方案

I managed to get it to install, but it isn't pretty and I don't really understand why it won't work out of the "autoconf" box.

For starters, rather than installing with "cabal install" (using a local copy), I used the sequence

>runhaskell Setup.hs configure
>runhaskell Setup.hs build
>runhaskell Setup.hs install

The main reason for this is because it is simple to change the $CC variable in the configure script using the argument in Setup.hs. I suspected the $CC was the variable giving me the problem. I changed:

[("CC",       ccProg)

to

[("CC",       "/cygdrive/c/cygwin/bin/gcc.exe")

in Setup.hs, which is the gcc that comes with Cygwin. My initial suspicion was that autoconf didn't like the Windows-style path to gcc, which it was using based on the log file above. I also discovered though that of the multiple copies of gcc on my computer (one in Haskell/mingw, one in a separate installation of mingw, and whichever version $PATH was pointing to, ONLY the cygwin gcc was able to successfully compile the test file that checked for . Using the cygwin gcc, I could run

gcc hello.c

on any file that included (WITHOUT an external include directive), whereas with any other copy of gcc, even something like

gcc -I/cygdrive/c/..../include hello.c

was not able to find . No idea why.

Just changing the $CC to the Cygwin gcc fixed almost all of the errors. The next errors occurred when "checking for library containing cudaRuntimeGetVersion/cuGetDriverVersion".

The file configure was trying to compile was

#define PACKAGE_NAME "Haskell CUDA bindings"
#define PACKAGE_TARNAME "cuda"
#define PACKAGE_VERSION "0.4.0.0"
#define PACKAGE_STRING "Haskell CUDA bindings 0.4.0.0"
#define PACKAGE_BUGREPORT "tmcdonell@cse.unsw.edu.au"
#define STDC_HEADERS 1
#define HAVE_SYS_TYPES_H 1
#define HAVE_SYS_STAT_H 1
#define HAVE_STDLIB_H 1
#define HAVE_STRING_H 1
#define HAVE_MEMORY_H 1
#define HAVE_STRINGS_H 1
#define HAVE_INTTYPES_H 1
#define HAVE_STDINT_H 1
#define HAVE_UNISTD_H 1
#define HAVE_CUDA_H 1
#define HAVE_CUDA_RUNTIME_API_H 1
/* end confdefs.h.  */

/* Override any GCC internal prototype to avoid an error.
   Use char because int might match the return type of a GCC
   builtin and then its argument prototype would still apply.  */
#ifdef __cplusplus
extern "C"
#endif
char cudaRuntimeGetVersion ();
int main ()
{
 return cudaRuntimeGetVersion ();
 ;
 return 0;
}

using the command:

/cygdrive/c/cygwin/bin/gcc.exe -o conftest.exe -fno-stack-protector  
-I/cygdrive/c/CUDA/v4.0/include   -L/cygdrive/c/CUDA/v4.0/lib  conftest.c -lcudart

The error (from the log file) is

/cygdrive/c/Users/crockeea/AppData/Local/Temp/ccKMQJiq.o:conftest.c:(.text+0xc):
undefined reference to `_cudaRuntimeGetVersion'

I'm a little rusty on my C, but it seems like they aren't include the appropriate header file here. That probably isn't right because the same file works on Unix based systems when running configure, but it's my best guess. Also, editing configure to make this file include cuda.h just results in a different error about multiple definitions of cudaRuntimeGetVersion. So my hack was to comment out the lines in the configure file with references to cudaRuntimeGetVersion/cuGetDriverVersion. I put C-comments into the C files that the configure file was going to compile (it is easy enough to find the source code for these in the configure file based on line numbers from the log file). I don't know the consequences of modifying the configure file in this way.

This allowed me to get past the 'build' phase. More comments if I run into any other issues.

这篇关于在Win7上使用Autoconf安装Haskell的CUDA的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆