cannot compile

Michel Bardiaux mbardiaux@peaktime.be
Wed, 16 Apr 2003 13:57:14 +0200


Jens Hillenbach wrote:
>  Hi there. I'm quite a newbie to unix, successfully installed cygwin on 
> my win98 and proceeded by installing gmp. However, something went 
> utterly wrong and I don't know what. The little programm I wrote for 
> testing purpuses, called test1.cpp follows:
> #include <iostream.h>
> #include <gmpxx.h>
> using namespace std;
> 
> int main(void)
> {
>   mpz_class N = "12345678901234567891234567890";
>   cout << "N = " << N << endl;
>   return 0;
> }
> 
> When calling g++, look what I get:
> 
>    $ g++ -o t1 test1.cpp -lgmpxx > g++_output
> /cygdrive/c/WINDOWS/TEMP/ccmeb4uF.o(.__gmp_expr<__gmpz_value, 
> __gmpz_value>::tex
> t$(bool) +0x17):test1.cpp: undefined reference to `__gmpz_init_set_ui'
> /cygdrive/c/WINDOWS/TEMP/ccmeb4uF.o(.text$_$_t10__gmp_expr2Z12__gmpz_valueZ12__g 
> 
> mpz_value+0x13):test1.cpp: undefined reference to `__gmpz_clear'
> /usr/local/lib/libgmpxx.a(osmpz.o): In function `_ls(ostream &, 
> __mpz_struct con
> st *)':
> /Jens/gmp-4.0.1/cxx/osmpz.cc:38: undefined reference to `__gmpz_get_str'
> /usr/local/lib/libgmpxx.a(osdoprnti.o): In function 
> `$_20gmp_allocated_string':
> /Jens/gmp-4.0.1/cxx/../gmp-impl.h:2503: undefined reference to 
> `__gmp_allocate_func'
> /Jens/gmp-4.0.1/cxx/../gmp-impl.h:2503: undefined reference to 
> `__gmp_doprnt_integer'
> /Jens/gmp-4.0.1/cxx/../gmp-impl.h:2503: undefined reference to 
> `__gmp_asprintf_final'
> /Jens/gmp-4.0.1/cxx/../gmp-impl.h:2503: undefined reference to 
> `__gmp_free_func'
> /Jens/gmp-4.0.1/cxx/../gmp-impl.h:2503: undefined reference to 
> `__gmp_free_func'
> /Jens/gmp-4.0.1/cxx/../gmp-impl.h:2503: undefined reference to 
> `__gmp_free_func'
> /usr/local/lib/libgmpxx.a(osfuns.o)(.text+0x4):osfuns.cc: undefined 
> reference to `__gmp_asprintf_memory'
> /usr/local/lib/libgmpxx.a(osfuns.o)(.text+0x8):osfuns.cc: undefined 
> reference to  `__gmp_asprintf_reps'
> collect2: ld returned 1 exit status
> 
> Similar things are written when compiling with gcc some c-program. Even 
> telling explicitily where the libraries are to be found like
>    g++ -I/usr/local/include -o p-1 p-1.cpp -L/usr/local/lib -lgmpxx
> won't prevent the compiler, or linker, or whatever to write those nasty 
> remarks.
> 
> If u experienced similiar problems and got rid of them (or simply know 
> what's wrong) don't hesitate to tell me how. Please!

Going out on a limb here (pun intended!) since I use neither cygwin nor 
C++, but... don't you need -lgmp too?

> 
> Thanks in advance, Jens
> 
> 
> _______________________________________________
> gmp-discuss mailing list
> gmp-discuss@swox.com
> https://gmplib.org/mailman/listinfo/gmp-discuss


-- 
Michel Bardiaux
Peaktime Belgium S.A.  Bd. du Souverain, 191  B-1160 Bruxelles
Tel : +32 2 790.29.41