2

您好,我正在尝试编译 gmp,因为我需要它用于 Perl 模块。我必须手动安装everyrthing,因为机器无法访问互联网。我在 GMP 文件夹的 cygwin 中运行了 configure 并使用了这个命令:

./configure --prefix=C:\gmp --disable-static --enable-shared

现在这也没有问题,并且在我运行时创建了 MAKEFILE,这会发生:

$ make
gcc -std=gnu99 `test -f 'gen-fac.c' || echo './'`gen-fac.c -o gen-fac.exe
./gen-fac 32 0 >fac_table.h || (rm -f fac_table.h; exit 1)
gcc -std=gnu99 `test -f 'gen-fib.c' || echo './'`gen-fib.c -o gen-fib.exe
./gen-fib header 32 0 >fib_table.h || (rm -f fib_table.h; exit 1)
./gen-fib table 32 0 >mpn/fib_table.c || (rm -f mpn/fib_table.c; exit 1)
gcc -std=gnu99 `test -f 'gen-bases.c' || echo './'`gen-bases.c -o gen-bases.exe -lm
./gen-bases header 32 0 >mp_bases.h || (rm -f mp_bases.h; exit 1)
./gen-bases table 32 0 >mpn/mp_bases.c || (rm -f mpn/mp_bases.c; exit 1)
gcc -std=gnu99 `test -f 'gen-trialdivtab.c' || echo './'`gen-trialdivtab.c -o gen-trialdivtab.exe -lm
./gen-trialdivtab 32 8000 >trialdivtab.h || (rm -f trialdivtab.h; exit 1)
gcc -std=gnu99 `test -f 'gen-jacobitab.c' || echo './'`gen-jacobitab.c -o gen-jacobitab.exe
./gen-jacobitab >mpn/jacobitab.h || (rm -f mpn/jacobitab.h; exit 1)
gcc -std=gnu99 `test -f 'gen-psqr.c' || echo './'`gen-psqr.c -o gen-psqr.exe -lm
./gen-psqr 32 0 >mpn/perfsqr.h || (rm -f mpn/perfsqr.h; exit 1)
make  all-recursive
make[1]: Entering directory `/cygdrive/e/FAGProgramme/Perl Modules/gmp'
Making all in tests
make[2]: Entering directory `/cygdrive/e/FAGProgramme/Perl Modules/gmp/tests'
Making all in .
make[3]: Entering directory `/cygdrive/e/FAGProgramme/Perl Modules/gmp/tests'
make[3]: Für das Ziel »all-am« ist nichts zu tun.
make[3]: Leaving directory `/cygdrive/e/FAGProgramme/Perl Modules/gmp/tests'
Making all in devel
make[3]: Entering directory `/cygdrive/e/FAGProgramme/Perl Modules/gmp/tests/devel'
make[3]: Für das Ziel »all« ist nichts zu tun.
make[3]: Leaving directory `/cygdrive/e/FAGProgramme/Perl Modules/gmp/tests/devel'
Making all in mpn
make[3]: Entering directory `/cygdrive/e/FAGProgramme/Perl Modules/gmp/tests/mpn'
make[3]: Für das Ziel »all« ist nichts zu tun.
make[3]: Leaving directory `/cygdrive/e/FAGProgramme/Perl Modules/gmp/tests/mpn'
Making all in mpz
make[3]: Entering directory `/cygdrive/e/FAGProgramme/Perl Modules/gmp/tests/mpz'
make[3]: Für das Ziel »all« ist nichts zu tun.
make[3]: Leaving directory `/cygdrive/e/FAGProgramme/Perl Modules/gmp/tests/mpz'
Making all in mpq
make[3]: Entering directory `/cygdrive/e/FAGProgramme/Perl Modules/gmp/tests/mpq'
make[3]: Für das Ziel »all« ist nichts zu tun.
make[3]: Leaving directory `/cygdrive/e/FAGProgramme/Perl Modules/gmp/tests/mpq'
Making all in mpf
make[3]: Entering directory `/cygdrive/e/FAGProgramme/Perl Modules/gmp/tests/mpf'
make[3]: Für das Ziel »all« ist nichts zu tun.
make[3]: Leaving directory `/cygdrive/e/FAGProgramme/Perl Modules/gmp/tests/mpf'
Making all in rand
make[3]: Entering directory `/cygdrive/e/FAGProgramme/Perl Modules/gmp/tests/rand'
make[3]: Für das Ziel »all« ist nichts zu tun.
make[3]: Leaving directory `/cygdrive/e/FAGProgramme/Perl Modules/gmp/tests/rand'
Making all in misc
make[3]: Entering directory `/cygdrive/e/FAGProgramme/Perl Modules/gmp/tests/misc'
make[3]: Für das Ziel »all« ist nichts zu tun.
make[3]: Leaving directory `/cygdrive/e/FAGProgramme/Perl Modules/gmp/tests/misc'
Making all in cxx
make[3]: Entering directory `/cygdrive/e/FAGProgramme/Perl Modules/gmp/tests/cxx'
make[3]: Für das Ziel »all« ist nichts zu tun.
make[3]: Leaving directory `/cygdrive/e/FAGProgramme/Perl Modules/gmp/tests/cxx'
make[2]: Leaving directory `/cygdrive/e/FAGProgramme/Perl Modules/gmp/tests'
Making all in mpn
make[2]: Entering directory `/cygdrive/e/FAGProgramme/Perl Modules/gmp/mpn'
/bin/sh ../libtool --tag=CC    --mode=compile gcc -std=gnu99 -DHAVE_CONFIG_H -I. -I.. -D__GMP_WITHIN_GMP -I..  -DOPERATION_`echo fib_table | sed 's/_$//'`     -m32 -O2 -pedantic -fomit-frame-pointer -mtune=corei7 -march=corei7 -c -o fib_table.lo fib_table.c
libtool: compile:  gcc -std=gnu99 -DHAVE_CONFIG_H -I. -I.. -D__GMP_WITHIN_GMP -I.. -DOPERATION_fib_table -m32 -O2 -pedantic -fomit-frame-pointer -mtune=corei7 -march=corei7 -c fib_table.c  -DDLL_EXPORT -DPIC -o .libs/fib_table.o
In file included from ../gmp-impl.h:134:0,
                 from fib_table.c:4:
../gmp-mparam.h:1:1: error: expected identifier or '(' before '!' token
../gmp-mparam.h:1:1: error: stray '\377' in program
../gmp-mparam.h:1:1: error: stray '\376' in program
../gmp-mparam.h:1:14: warning: null character(s) ignored [enabled by default]
../gmp-mparam.h:1:16: warning: null character(s) ignored [enabled by default]
../gmp-mparam.h:1:18: warning: null character(s) ignored [enabled by default]
../gmp-mparam.h:1:20: warning: null character(s) ignored [enabled by default]
../gmp-mparam.h:1:22: warning: null character(s) ignored [enabled by default]
../gmp-mparam.h:1:24: warning: null character(s) ignored [enabled by default]
../gmp-mparam.h:1:26: warning: null character(s) ignored [enabled by default]
../gmp-mparam.h:1:28: warning: null character(s) ignored [enabled by default]
../gmp-mparam.h:1:30: warning: null character(s) ignored [enabled by default]
../gmp-mparam.h:1:32: warning: null character(s) ignored [enabled by default]
../gmp-mparam.h:1:34: warning: null character(s) ignored [enabled by default]
../gmp-mparam.h:1:36: warning: null character(s) ignored [enabled by default]
../gmp-mparam.h:1:38: warning: null character(s) ignored [enabled by default]
../gmp-mparam.h:1:40: warning: null character(s) ignored [enabled by default]
../gmp-mparam.h:1:42: warning: null character(s) ignored [enabled by default]
../gmp-mparam.h:1:44: warning: null character(s) ignored [enabled by default]
../gmp-mparam.h:1:46: warning: null character(s) ignored [enabled by default]
../gmp-mparam.h:1:48: warning: null character(s) ignored [enabled by default]
../gmp-mparam.h:1:50: warning: null character(s) ignored [enabled by default]
../gmp-mparam.h:1:52: warning: null character(s) ignored [enabled by default]
../gmp-mparam.h:1:54: warning: null character(s) ignored [enabled by default]
../gmp-mparam.h:1:56: warning: null character(s) ignored [enabled by default]
../gmp-mparam.h:1:58: warning: null character(s) ignored [enabled by default]
../gmp-mparam.h:1:60: warning: null character(s) ignored [enabled by default]
../gmp-mparam.h:1:62: warning: null character(s) ignored [enabled by default]
../gmp-mparam.h:1:64: warning: null character(s) ignored [enabled by default]
../gmp-mparam.h:1:66: warning: null character(s) ignored [enabled by default]
../gmp-mparam.h:1:68: warning: null character(s) ignored [enabled by default]
../gmp-mparam.h:1:70: warning: null character(s) ignored [enabled by default]
In file included from ../gmp-impl.h:144:0,
                 from fib_table.c:4:
e:\fagprogramme\mingw\bin\../lib/gcc/mingw32/4.7.1/../../../../include/inttypes.h:272:1: error: unknown type name 'wchar_t'
e:\fagprogramme\mingw\bin\../lib/gcc/mingw32/4.7.1/../../../../include/inttypes.h:273:29: error: unknown type name 'wchar_t'
e:\fagprogramme\mingw\bin\../lib/gcc/mingw32/4.7.1/../../../../include/inttypes.h:274:1: error: unknown type name 'wchar_t'
e:\fagprogramme\mingw\bin\../lib/gcc/mingw32/4.7.1/../../../../include/inttypes.h:275:9: error: unknown type name 'wchar_t'
Makefile:389: recipe for target `fib_table.lo' failed
make[2]: *** [fib_table.lo] Error 1
make[2]: Leaving directory `/cygdrive/e/FAGProgramme/Perl Modules/gmp/mpn'
Makefile:833: recipe for target `all-recursive' failed
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/cygdrive/e/FAGProgramme/Perl Modules/gmp'
Makefile:656: recipe for target `all' failed
make: *** [all] Error 2

现在我不知道该怎么办。我也尝试过没有任何参数它仍然给出相同的错误。

4

2 回答 2

2

2 1/2 年后,但我也许可以为遇到类似问题的任何人回答这个问题(比如我!)。

打开一个 cygwin 终端,创建一个名为的小文本文件hello.txt并在其中放入少量文本,然后执行以下命令:

ln -s hello.txt link.txt

现在,cat link.txt将显示您的文本。但是,如果你进入 Windows,打开 Notebook 并link.txt from在那里打开,你会看到一些非常奇怪的字符。您可能会看到“ hello.txt”。或无。

原因是 cygwin 的 ln 命令创建了一种只有 cygwin 知道如何处理的假链接。Windows 和 Windows 程序不知道这是一个 cygwin 链接,所以他们只是打开文件并看到 cygwin 放在那里的假东西。

现在,如果您查看失败的命令:

/bin/sh ../libtool --tag=CC    --mode=compile gcc -std=gnu99 -DHAVE_CONFIG_H -I. -I.. -D__GMP_WITHIN_GMP -I..  -DOPERATION_`echo fib_table | sed 's/_$//'`     -m32 -O2 -pedantic -fomit-frame-pointer -mtune=corei7 -march=corei7 -c -o fib_table.lo fib_table.c
libtool: compile:  gcc -std=gnu99 -DHAVE_CONFIG_H -I. -I.. -D__GMP_WITHIN_GMP -I.. -DOPERATION_fib_table -m32 -O2 -pedantic -fomit-frame-pointer -mtune=corei7 -march=corei7 -c fib_table.c  -DDLL_EXPORT -DPIC -o .libs/fib_table.o

你会看到 libtool 正在运行 gcc,而 gcc 必须在某个时候尝试打开gmp-mparam.h这是一个链接。因为它将它作为垃圾而不是gmp-mparam.h链接到的内容来读取,这一定意味着 gcc 正在使用某些 Windows 库来读取文件。所以,gcc 失败了。

此链接由config.status您运行时创建configure

现在,这样做:

rm link.txt
export CYGWIN=winsymlinks
ln -s hello.txt link.txt

现在cat link.txtAND Notebook 都应该显示hello.txt. 原因是设置CYGWIN=winsymlinks告诉 cygwin 创建 Windows 链接文件。在 Cygwin 用户指南的第 3 章中阅读有关 cygwin 链接的更多信息。

现在CYGWIN已经设置了环境变量,再次运行 configure,它将使用“正确的”Windows 链接文件重新创建链接。

除问题外的任何错误error: stray '\377' in program都有其他原因。

于 2015-12-18T03:55:05.527 回答
1

切换到 Strawberry Perl 并使用本教程,这就是解决方案:

http://www.cs.nyu.edu/exact/core/gmp/

于 2013-04-15T07:30:19.600 回答