List Info

Thread: Using C++ output functions




Using C++ output functions
user name
2007-02-14 05:51:59
I guess this problem is less related to GMP than to general C++ compilation, but it would be very helpful if someone could nevertheless explain me what to do.

When compiling the following simple program

#include < gmp.h>
#include <gmpxx.h>
#include <iostream>

using namespace std;

int main() {
  mpf_class f;
  f = 3.5 * 2.2;
 ; cout << f;
  return 0;
}

with the following command

g++ max-npv.cc -static -lgmp -lgmpxx

I get the following error message:

/usr/local/lib/libgmpxx.a(osmpf.o): In function `operator&lt;<(std::basic_ostream<char, std::char_traits<char> >&, __mpf_struct const*)9;:
osmpf.cc:(.text+0x131): undefined reference to `__gmp_doprnt_mpf29;
osmpf.cc:(.text+0x139): undefined reference to `__gmp_asprintf_final'
/usr/local/lib/libgmpxx.a(osfuns.o):(.rodata+0x4): undefined reference to `__gmp_asprintf_memory'
/usr/local/lib/libgmpxx.a(osfuns.o):(.rodata+0x8): undefined reference to `__gmp_asprintf_reps&#39;
collect2: ld returned 1 exit status

If I remove the line "cout << f" from the code, everything works fine. I have used the "--enable-cxx&quot; parameter during the make process, so that should be okay.

Can anybody give me a hint what I need to do?

Best,

Wolfram
Re: Using C++ output functions
country flaguser name
Italy
2007-02-15 00:30:29
Wolfram Wiesemann wrote:
> I guess this problem is less related to GMP than to
general C++ 
> compilation,
> but it would be very helpful if someone could
nevertheless explain me what
> to do.
> 
> When compiling the following simple program
> 
> #include <gmp.h>
> #include <gmpxx.h>
> #include <iostream>
> 
> using namespace std;
> 
> int main() {
>  mpf_class f;
>  f = 3.5 * 2.2;
>  cout << f;
>  return 0;
> }
> 
> with the following command
> 
> g++ max-npv.cc -static -lgmp -lgmpxx

Use one of these commands instead:

   g++ max-npv.cc -static -lgmpxx -lgmp

if you really want to prevent linking with
the shared libraries; or

   g++ max-npv.cc -lgmpxx

otherwise.  Notice also that it is enough to include
<gmpxx.h>.
All the best,

     Roberto

-- 
Prof. Roberto Bagnara
Computer Science Group
Department of Mathematics, University of Parma, Italy
http://www.cs.unipr.
it/~bagnara/
mailto:bagnaracs.unipr.it
_______________________________________________
gmp-discuss mailing list
gmp-discussswox.com
http://s
wox.com/mailman/listinfo/gmp-discuss

[1-2]

about | contact  Other archives ( Real Estate discussion Medical topics )