GMP build issues

Duke Hound dukethek9 at gmail.com
Sun Jun 22 02:45:01 CEST 2008


Sisyphus wrote:
>
> ----- Original Message ----- From: "Duke Hound" <dukethek9 at gmail.com>
> .
> .
>>> Hello,
>>> I decided to reinstall msys and start again.
>>> Details:
>>> -Windows XP SP2
>>> -I have MinGW (gcc version 3.4.5 (mingw-vista special)) at
>>> C:\Program Files\CodeBlocks\MinGW\
>>> -I have MSYS 1.0.10 at
>>> C:\msys\1.0\
>>> -In C:\msys\1.0\etc\fstab i have the following mount setting:
>>> "c:/progra~1/codeblocks/mingw /mingw"
>>> -I have unzipped GMP 4.2.2 to
>>> C:\msys\1.0\home\dan\gmp-4.2.2
>>>
>>> ======PART 1 BUILD ===========
>>> [note: the msys make is 3.79.1 built for i686-pc-msys , whereas the
>>> mingw32-make is GNU Make 3.81 built for i386-pc-mingw32]
>>>
>>> my commands (with the new setup as described above) (output of these
>>> commands are attached in the .zip)
>>> ./configure --enable-cxx
>>> make
>>> make check
>>>
>>> When I build this I do not get any DLL files, even though I do not
>>> provide the '--disable-shared --enable-static' switches.  Please 
>>> explain?
>
> My mistake. I thought dynamic libs were the default, but when I look 
> at the ./configure output you provided with your original post I see:
>
> checking whether to build shared libraries... no
> checking whether to build static libraries... yes
>
> That's why you get only static libraries.
> I expect that, for dynamic libs, you'll need to run:
>
> ./configure --disable-static --enable-shared --enable-cxx
>
> That should produce a correctly functioning dll - though, as I 
> mentioned earlier, 'make check' doesn't work for me when I build 
> dynamic libs. (I prefer static libs anyway.)
>
>>> During the make I receive the following warnings which i think are
>>> related to PART 2 of this email.
>>>
>>> libtool: link: warning: undefined symbols not allowed in
>>> athlon-pc-mingw32 shared libraries
>>> libtool: link: warning: undefined symbols not allowed in
>>> athlon-pc-mingw32 shared libraries
>
> They're just warnings, and can be ignored.
>
>>>
>>> make check seemed to pass.
>
> If you run 'make install' then gmp.h should be installed into 
> C:/msys/1.0/local/include, and the libs should be installed into 
> C:/msys/1.0/local/lib. You access them from the command line using the 
> '-I', '-L', and '-l' switches.
>
>>> Now, I am trying to use the library that i just built.
>>>
>>> Here is the simple code
>>> #include <gmpxx.h>
>>> using namespace std;
>>> int main() {
>>> mpz_class a;
>>> a = 1234;
>>> cout << a << endl;
>>> return 0;
>>> }
>>>
>
> Assuming that file is called 'test.cpp', and that you've run 'make 
> install', you would build that (in the msys shell) by running:
>
> g++ -o mytest.exe test.cpp -I/usr/local/include -L/usr/local/lib -lgmpxx
>
> If you're in the cmd.exe shell, then /usr/local/include and 
> /usr/local/lib won't be understood so it becomes:
>
> g++ -o mytest.exe test.cpp -IC:/msys/1.0/local/include 
> -LC:/msys/1.0/local/lib -lgmpxx
>
> (Just replace 'mytest.exe' and 'test.cpp' with whatever is appropriate.)]
>
> .
> .
>> -I saw the following from the GMP documentation
>> "MINGW uses the C runtime library `msvcrt.dll' for I/O, so applications
>> wanting to use the GMP I/O routines must be compiled with `cl /MD' to do
>> the same. If one of the other C runtime library choices provided by MS C
>> is desired then the suggestion is to use the GMP string functions and
>> confine I/O to the application. "
>> Could this be the reason for the undefined references?  If so how do I
>> "complie with the `cl /MD`"?  Do I have to use ./configure CFLAGS=cl 
>> /MD?
>
> 'cl' is the microsoft compiler. That advice is for those who want to 
> build their apps using Visual Studio as the compiler. It doesn't apply 
> to you as you are using the MinGW compiler.
>
> Cheers,
> Rob
Hello,
Thanks for sticking with me through this.  After issuing the make 
install command and executing the compile command from within msys, I 
received similar 'undefined reference to' errors as I did when trying to 
compile from within codeblocks.  The references it is trying to find are 
(i think) all in the libgmpxx.a file.  The linker can resolve 
definitions stated in libgmp.a, but not from libgmpxx.a.  This suggests 
to me that c runtime libraries were compiled during the make, but the 
c++ runtime libraries were not.

Below is the output from trying to compile the test code within msys.

$ g++ -o mytest.exe test.cpp -I/usr/local/include -L/usr/local/lib -lgmpxx
C:/DOCUME~1/dan/LOCALS~1/Temp/cc37G8yA.o:test.cpp:(.text$_ZN10__gmp_exprIA1_12__mpz_structS1_ED1Ev[__gmp_expr<__mpz_struct 
[1], __mpz_struct [1]>::~__gmp_expr()]+0xd): undefined reference to 
`___gmpz_clear'
C:/DOCUME~1/dan/LOCALS~1/Temp/cc37G8yA.o:test.cpp:(.text$_ZN10__gmp_exprIA1_12__pz_structS1_EaSEi[__gmp_expr<__mpz_struct 
[1], __mpz_struct [1]>::operator=(int)]+0x14): undefined reference to 
`___gmpz_set_si'
C:/DOCUME~1/dan/LOCALS~1/Temp/cc37G8yA.o:test.cpp:(.text$_ZN10__gmp_exprIA1_12__mpz_structS1_EC1Ev[__gmp_expr<__mpz_struct 
[1], __mpz_struct [1]>::__gmp_expr()]+0xd): undefined reference to 
`___gmpz_init'
C:/msys/1.0/local/lib/libgmpxx.a(osmpz.o):osmpz.cc:(.text+0x39): 
undefined reference to `___gmpz_get_str'
C:/msys/1.0/local/lib/libgmpxx.a(osdoprnti.o):osdoprnti.cc:(.text+0x65): 
undefined reference to `___gmp_allocate_func'
C:/msys/1.0/local/lib/libgmpxx.a(osdoprnti.o):osdoprnti.cc:(.text+0x9d): 
undefined reference to `___gmp_doprnt_integer'
C:/msys/1.0/local/lib/libgmpxx.a(osdoprnti.o):osdoprnti.cc:(.text+0xa9): 
undefined reference to `___gmp_asprintf_final'
C:/msys/1.0/local/lib/libgmpxx.a(osdoprnti.o):osdoprnti.cc:(.text+0xcd): 
undefined reference to `___gmp_free_func'
C:/msys/1.0/local/lib/libgmpxx.a(osdoprnti.o):osdoprnti.cc:(.text+0x125): 
undefined reference to `___gmp_free_func'
C:/msys/1.0/local/lib/libgmpxx.a(osdoprnti.o):osdoprnti.cc:(.text+0x164): 
undefined reference to `___gmp_free_func'
C:/msys/1.0/local/lib/libgmpxx.a(osfuns.o):osfuns.cc:(.rdata+0x4): 
undefined reference to `___gmp_asprintf_memory'
C:/msys/1.0/local/lib/libgmpxx.a(osfuns.o):osfuns.cc:(.rdata+0x8): 
undefined reference to `___gmp_asprintf_reps'
collect2: ld returned 1 exit status

Look forward to learning/figuring this out.

Thanks,
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://gmplib.org/list-archives/gmp-discuss/attachments/20080621/44e65776/attachment.html 


More information about the gmp-discuss mailing list