bug-gmp
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Problems linking with gmp...


From: Will Galway
Subject: Problems linking with gmp...
Date: Tue, 10 Sep 2002 23:25:14 -0500 (CDT)

I apologize ahead of time for asking for help with what is undoubtedly
a stupidity on my part, and probably relates more to proper use of
"ld" than of gmp, but I'm hoping that someone can quickly spot what
I'm doing wrong here...  Before describing the problem, here are some
details about the system:

 > uname -a 
 SunOS u00.math.uiuc.edu 5.8 Generic_108528-15 sun4u sparc
 > config.guess
 sparcv9-sun-solaris2.8
 > gcc --version
 2.95.2
 > cc -V
 cc: Sun WorkShop 6 update 2 C 5.3 2001/05/15
 > echo $LD_LIBRARY_PATH
 /home/users/galway/lib:/usr/lib:/usr/local/lib

I've just built gmp 4.0, to reside under a personal "lib" directory.
With the untarred gmp distribution residing in
~/encap/gmp-4.0/distribution/, the configure-and-build process went
something like this (following an early attempt to build...):

 cd ~/encap/gmp-4.0/distribution/
 make distclean
 ./configure --prefix=~/encap/gmp-4.0
 make
 make install
 make check

and all this seemed to go smoothly.  (Note that the prefix directory
is the parent directory of the untarred gmp distribution.)

Later, I created symbolic links from ~/lib into ~/encap/gmp-4.0, so
that 

  cd ~/lib; ls -lt

reports

  lrwxrwxrwx   1 galway   help           29 Sep 10 21:08 libgmp.a -> 
../encap/gmp-4.0/lib/libgmp.a
  lrwxrwxrwx   1 galway   help           30 Sep 10 21:08 libgmp.la -> 
../encap/gmp-4.0/lib/libgmp.la*
  lrwxrwxrwx   1 galway   help           30 Sep 10 21:08 libgmp.so -> 
../encap/gmp-4.0/lib/libgmp.so*
  lrwxrwxrwx   1 galway   help           32 Sep 10 21:08 libgmp.so.3 -> 
../encap/gmp-4.0/lib/libgmp.so.3*
  lrwxrwxrwx   1 galway   help           36 Sep 10 21:08 libgmp.so.3.2.0 -> 
../encap/gmp-4.0/lib/libgmp.so.3.2.0*

However, when I try to compile, using either cc or gcc, I can't seem
to pick up the the gmp library, even though I think I'm passing the
correct information via the "-L" option, and via the LD_LIBRARY_PATH
environment variable.  Here's the test program that I've been trying.
(Essentially one of the standard tests, but the ``#include <gmp.h>''
changed to ``#include <gmp.h>''.)
/************************************************************************/
    #include <stdio.h>
    #include "gmp.h"         /* All GMP programs need to include gmp.h */

    main (int argc, char **argv)
    {
      mpz_t a, b, p;

      if (argc != 3)
        {
          printf ("Usage: %s <number> <number>\n", argv[0]);
          exit (1);
        }

      /* Initialize variables */
      mpz_init (a);
      mpz_init (b);
      mpz_init (p);

      /* Assign a and b from base 10 strings in argv */
      mpz_set_str (a, argv[1], 10);
      mpz_set_str (b, argv[2], 10);

      /* Multiply a and b and put the result in p */
      mpz_mul (p, a, b);

      /* Print p in decimal */
      gmp_printf ("%Zd\n", p);

      /* Clear out variables */
      mpz_clear (a);
      mpz_clear (b);
      mpz_clear (p);
      exit (0);
    }
/************************************************************************/

But, when I attempt to compile, no luck:

  > cc gmp-test.c -I/home/users/galway/include -L/home/users/galway/lib -lgmp 
-o gmp-test
  Undefined                       first referenced
   symbol                             in file
  __gmp_printf                        gmp-test.o
  ld: fatal: Symbol referencing errors. No output written to gmp-test

similarly with gcc:
  > gcc gmp-test.c -I/home/users/galway/include -L/home/users/galway/lib -lgmp 
-o gmp-test
  Undefined                       first referenced
   symbol                             in file
  __gmp_printf                        /var/tmp/ccSwAPYs.o
  ld: fatal: Symbol referencing errors. No output written to gmp-test
  collect2: ld returned 1 exit status

I might also mention that my earlier experience with gcc (pre-4.0) has
gone more-or-less smoothly....

Thanks for any help you might be able to provide!

--Will
( mailto:address@hidden  http://www.math.uiuc.edu/~galway )




reply via email to

[Prev in Thread] Current Thread [Next in Thread]