2

I am trying to compile GMP, because I need it for a Perl module. I have to install everything manually because the machine doesn’t have access to the Internet. I ran configure and used this command in Cygwin in the GMP Folder:

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

Now that also worked without problems and created the Makefile now when I run make this happens:

make

Output:

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

What should I do? I also tried it without any parameters, but it still gives the same error.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
alexj
  • 139
  • 1
  • 4
  • 15
  • I fixed some error by installing gcc-core, gcc-g++ to cygwin but still same error at end. – alexj Apr 12 '13 at 13:27
  • Stray error doublet \377 \376 (octal. Hexadecimal 0xFF 0xFE) in the beginning of the file is a signature for a UTF-16 [BOM](https://en.wikipedia.org/wiki/Byte_order_mark) ([UTF-16LE](https://en.wikipedia.org/wiki/UTF-16#Byte-order_encoding_schemes) (little-endian)). The null characters are consistent with [UTF-16](https://en.wikipedia.org/wiki/UTF-16) encoding. – Peter Mortensen May 25 '23 at 10:39
  • Related (though a different kind of stray errors): *[Compilation error: stray ‘\302’ in program, etc.](https://stackoverflow.com/questions/19198332/)* – Peter Mortensen May 25 '23 at 10:40
  • The canonical question may be *[How should I use g++'s -finput-charset compiler option correctly in order to compile a non-UTF-8 source file?](https://stackoverflow.com/questions/10345802/how-should-i-use-gs-finput-charset-compiler-option-correctly-in-order-to-com)*. Or some of its "Linked" questions (right-hand side). – Peter Mortensen May 25 '23 at 11:00

2 Answers2

2

Open up a Cygwin terminal, create a little text file called hello.txt and put some small amount of text in it, and then perform this command:

ln -s hello.txt link.txt

Now, cat link.txt will show your text. However, if you go into Windows, open up Notebook and open link.txt from there, you will see some very strange characters. You might see "hello.txt". Or nothing.

The reason for this is that Cygwin's ln command creates a kind of fake link that only Cygwin knows how to handle. Windows and Windows programs do not know that this is a Cygwin link, so they just open up the file and see the fake stuff Cygwin put there.

Now, if you look at the command that failed:

/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

You'll see that libtool is running GCC, and GCC must try at some point to open gmp-mparam.h, which is a link. Because it reads it as garbage instead of what gmp-mparam.h is linked to, this must mean that GCC is using some Windows library to read files. And so, GCC fails.

This link was created by config.status when you ran configure.

Now, do this:

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

Now both cat link.txt and Notebook should both show the contents of hello.txt. The reason is that setting CYGWIN=winsymlinks tells Cygwin to create Windows link files. Read more about Cygwin links in Chapter 3 of the Cygwin User's Guide.

Now that the CYGWIN environment variable is set, run configure again, and it will recreate the links using "proper" Windows link files.

Any errors other than the error: stray '\377' in program issue has other causes.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Robert B
  • 3,195
  • 2
  • 16
  • 13
  • It could be, but \377 \376 in the beginning of the file is a signature for [UTF-16LE](https://en.wikipedia.org/wiki/UTF-16#Byte-order_encoding_schemes) (little-endian). The null characters are consistent with [UTF-16](https://en.wikipedia.org/wiki/UTF-16) encoding (of a text file). – Peter Mortensen May 25 '23 at 10:27
  • What is *"Notebook"*? Do you mean [Notepad](https://en.wikipedia.org/wiki/Windows_Notepad)? (Or perhaps [OneNote](https://en.wikipedia.org/wiki/Microsoft_OneNote) or [Notepad++](https://en.wikipedia.org/wiki/Notepad%2B%2B)?) – Peter Mortensen May 25 '23 at 10:29
1

Switched to Strawberry Perl and used this Tutorial, that was the solution:

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

alexj
  • 139
  • 1
  • 4
  • 15