[CLN-list] fixing undefined references

Richard B. Kreckel kreckel at ginac.de
Wed Mar 26 21:50:53 CET 2014


Michael,

On 03/26/2014 06:35 PM, Michael Miller wrote:
> I've spent 5 hours trying to understand the reason for an undefined
> reference, so I'm asking for some help.
> 
> The code
> 
> --------------------
> #include <cstdlib>
> #include <gmp.h>
> #include <cln/cln.h>
> 
> using namespace std;
> using namespace cln;
> 
> const cl_univpoly_complex_ring CZ = find_univpoly_ring(cl_C_ring);
> 
> struct parameter { cl_N z0; cl_UP_N p(); };
> 
> int main(void) {
>    cl_UP_N q=CZ->create(1);
>    q.set_coeff(1, 1);
>    q.set_coeff(0, -1);
>    q.finalize();
> 
>    parameter param;
>    param.z0=1;
>    param.p()=q;
> 
> }
> --------------------
> 
> produces the error message
> 
> --------------------
> /tmp/ccZPl6fM.o: In function `main':
> test.cpp:(.text+0xc6): undefined reference to `parameter::p()'
> collect2: error: ld returned 1 exit status
> --------------------
> 
> What am I doing wrong?
> 
> 
> Note: replacing p() with p, which would make more sense to me, generates compiler errors.

The linker is telling you that you are call an undefined member function
p of struct parameter. You declared that member function in line 10 of
your program, call it in line 20, but never defined it.

My bet is that you wanted to declare p as a member variable, not as a
member function, in line 10.

hope this helps
  -richard.
-- 
Richard B. Kreckel
<http://www.ginac.de/~kreckel/>


More information about the CLN-list mailing list