Prof. J. E. Cremona on Thu, 31 May 2007 13:41:25 +0200


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

Re: libpari and static linking


Jeroen Demeyer wrote:
> Jeroen Demeyer wrote:
>> Hello list,
>>
>> I wrote a C++ program which uses libPARI for factoring integers (the
>> function Z_factor()).  However, it only compiles with dynamic linking.
>> When I link -static, I get the following errors:
>>
>> factor.o: In function `factornumber(number_t const&)':
>> factor.cpp:(.text+0x10c): undefined reference to `avma'
>> factor.cpp:(.text+0x16c): undefined reference to `bot'
>> [more errors like this...]
> 
> I found out how to fix the problem:
> apparently the -lpari linker option must be given AFTER all object
> files, so I need to do
> 
> g++ -static myobj1.o myobj2.o myobj3.o -omyprogram -lpari -lgmp
> 
> With -lpari -lgmp at the end.  I found this out using trial and error, I
> cannot explain why.

>From my limited knowledge of these things it parses the line in order
and when it reaches a library flag like -lpari it only looks in that
library for symbols it already knows that it needs, i.e. from .o files
it has seen already.  So if you use a pari function in foo.o then you
need to put -lpari after foo.o on the command line.

John

-- 
 Prof. J. E. Cremona             |
 University of Nottingham        | Tel.:  +44-115-9514920
 School of Mathematical Sciences | Fax:   +44-115-9514951
 University Park                 | Email: John.Cremona@nottingham.ac.uk
 Nottingham NG7 2RD, UK          |


This message has been checked for viruses but the contents of an attachment
may still contain software viruses, which could damage your computer system:
you are advised to perform your own checks. Email communications with the
University of Nottingham may be monitored as permitted by UK legislation.