Bill Allombert on Sun, 26 Jan 2025 20:11:25 +0100


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

Re: collect2: error: ld returned 1 exit status


On Sun, Jan 26, 2025 at 07:01:49PM +0100, leitner@stp.dias.ie wrote:
> Hello,
> 
>  I installed pari-2.17.1 on Linux Ubuntu in the folder $HOME/pari. avx could
> not be found in C lib, but all tests seem to run fine.
> 
>  Now I am using gcc (Ubuntu 13.3.0-6ubuntu2~24.04) 13.3.0, and while my c
> code compiles all right, my simple test program (named "using_pari.c")

Hello,

Note that we provide compilation instruction in Appendix B of the libpari manual
and an example Makefile in the examples directory.
Using this Makefile, you can just do
make TARGET=using_pari

> #include "pari/pari-2.17.1/include/pari/pari.h"

Please do not do that, use -I pari/pari-2.17.1/include/ instead:
the correct way to include pari is:

#include <pari/pari.h>

> leitner@laptop:~$ gcc using_pari.c
> -L/home/leitner/pari/pari-2.17.1/lib/libpari.a -o using_pari

This is not a valid command line, -L expect a path, not a library, so this does nothing.

You should do

gcc -O3 -Wall using_pari.c -o using_pari -I /home/leitner/pari/pari-2.17.1/include -L/home/leitner/pari/pari-2.17.1/lib/ -lpari -Wl,-rpath=/home/leitner/pari/pari-2.17.1/lib/ 

Cheers,
Bill.