[CLN-list] compililing with cln doesn't work

Marcel Schulz schulz_m at molgen.mpg.de
Tue Sep 1 16:25:17 CEST 2009


Hi,
I have installed the CLN library version 1.3.0 and wanted to use it. 
however I am not able to compile even the simple fibonacci.cpp example.
I have installed the library with ./configure --prefix=/home/schulz_m 
and i tried to use your documentation to set all the compiler flags 
appropriately.
the original files after unpacking are under /home/schulz_m/cln-1.3.0 
and the fibon.cpp is in my home directory. after typing make test I get 
the following error (makefile and cpp, g++ version below):


 make test
g++ -02 -I/home/schulz_m/include/ -Icln-1.3.0/include/ fibon.cpp -o test
g++: unrecognized option '-02'
/tmp/ccJKw2VF.o: In function 
`__static_initialization_and_destruction_0(int, int)':
fibon.cpp:(.text+0x159): undefined reference to 
`cln::cl_random_def_init_helper::cl_random_def_init_helper()'
fibon.cpp:(.text+0x18d): undefined reference to 
`cln::cl_FF_globals_init_helper::cl_FF_globals_init_helper()'
fibon.cpp:(.text+0x1b5): undefined reference to 
`cln::cl_DF_globals_init_helper::cl_DF_globals_init_helper()'
fibon.cpp:(.text+0x1dd): undefined reference to 
`cln::cl_LF_globals_init_helper::cl_LF_globals_init_helper()'
/tmp/ccJKw2VF.o: In function `__tcf_4':
fibon.cpp:(.text+0x22a): undefined reference to 
`cln::cl_LF_globals_init_helper::~cl_LF_globals_init_helper()'
/tmp/ccJKw2VF.o: In function `__tcf_3':
fibon.cpp:(.text+0x23e): undefined reference to 
`cln::cl_DF_globals_init_helper::~cl_DF_globals_init_helper()'
/tmp/ccJKw2VF.o: In function `__tcf_2':
fibon.cpp:(.text+0x252): undefined reference to 
`cln::cl_FF_globals_init_helper::~cl_FF_globals_init_helper()'
/tmp/ccJKw2VF.o: In function `__tcf_1':
fibon.cpp:(.text+0x266): undefined reference to 
`cln::cl_random_def_init_helper::~cl_random_def_init_helper()'
/tmp/ccJKw2VF.o: In function `fibonacci(int)':
fibon.cpp:(.text+0x2c0): undefined reference to 
`cln::float_format(unsigned long long)'
fibon.cpp:(.text+0x2fc): undefined reference to `cln::sqrt(cln::cl_F 
const&)'
fibon.cpp:(.text+0x3c7): undefined reference to `cln::expt(cln::cl_R 
const&, long)'
fibon.cpp:(.text+0x3e3): undefined reference to 
`cln::operator/(cln::cl_R const&, cln::cl_R const&)'
fibon.cpp:(.text+0x3f8): undefined reference to `cln::round1(cln::cl_R 
const&)'
/tmp/ccJKw2VF.o: In function 
`cln::cl_I_classes_dummy::cl_I_classes_dummy()':
fibon.cpp:(.gnu.linkonce.t._ZN3cln18cl_I_classes_dummyC1Ev+0x9): 
undefined reference to `cln::cl_class_fixnum'
/tmp/ccJKw2VF.o: In function 
`cln::cl_gc_dec_pointer_refcount(cln::cl_heap*)':
fibon.cpp:(.gnu.linkonce.t._ZN3cln26cl_gc_dec_pointer_refcountEPNS_7cl_heapE+0x28): 
undefined reference to `cln::cl_free_heap_object(cln::cl_heap*)'
/tmp/ccJKw2VF.o: In function `cln::operator/(cln::cl_R const&, int)':
fibon.cpp:(.gnu.linkonce.t._ZN3clndvERKNS_4cl_REi+0x2e): undefined 
reference to `cln::operator/(cln::cl_R const&, cln::cl_R const&)'
/tmp/ccJKw2VF.o: In function `cln::cl_float(int, cln::float_format_t)':
fibon.cpp:(.gnu.linkonce.t._ZN3cln8cl_floatEiNS_14float_format_tE+0x41): 
undefined reference to `cln::cl_float(cln::cl_I const&, 
cln::float_format_t)'
/tmp/ccJKw2VF.o: In function `cln::operator+(int, cln::cl_R const&)':
fibon.cpp:(.gnu.linkonce.t._ZN3clnplEiRKNS_4cl_RE+0x2e): undefined 
reference to `cln::operator+(cln::cl_R const&, cln::cl_R const&)'
collect2: ld returned 1 exit status
make: *** [test] Error 1


----makefile
CLN_DIR=/home/schulz_m/
CLN_TARGETDIR=cln-1.3.0/
CC=g++
CFLAGS= -I$(CLN_DIR)include/ -I$(CLN_TARGETDIR)include/
CXXFLAGS= -02
test:
    $(CC) $(CXXFLAGS) $(CFLAGS) fibon.cpp -o test

all: test



----fibon.cpp:

#include <iostream>
//#include <cln/cln.h>
#include "cln/integer.h"
#include "cln/real.h"
using namespace cln;

// Returns F_n, computed as the nearest integer to
// ((1+sqrt(5))/2)^n/sqrt(5). Assume n>=0.
cl_I fibonacci (int n)
{
        // Need a precision of ((1+sqrt(5))/2)^-n.
        float_format_t prec = float_format((int)(0.208987641*n+5));
        cl_R sqrt5 = sqrt(cl_float(5,prec));
        cl_R phi = (1+sqrt5)/2;
        return round1( expt(phi,n)/sqrt5 );
}


int main(){
    cl_I tt=fibonacci(4);
    std::cout<< "fibon:";
    return 1;
}

----this is my g++ version
Using built-in specs.
Target: i686-pc-linux-gnu
Configured with: ../gcc-4.2.0/configure --prefix=/usr 
--libexecdir=/usr/lib --enable-shared --enable-threads=posix 
--enable-__cxa_atexit --enable-clocale=gnu --disable-multilib 
--disable-nls --enable-languages=c,c++,fortran
Thread model: posix
gcc version 4.2.0


Thanks for any advice!
Best wishes,
Marcel



More information about the CLN-list mailing list