attractivechaos / klib

A standalone and lightweight C library
http://attractivechaos.github.io/klib/
MIT License
4.18k stars 556 forks source link

Error in Make Test! #83

Open QuestionPython opened 7 years ago

QuestionPython commented 7 years ago

$ g++ -v

Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/5/lto-wrapper
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu 5.4.1-2ubuntu2' --with-bugurl=file:///usr/share/doc/gcc-5/README.Bugs --enable-languages=c,ada,c++,java,go,d,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-5 --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-vtable-verify --enable-libmpx --enable-plugin --enable-default-pie --with-system-zlib --disable-browser-plugin --enable-java-awt=gtk --enable-gtk-cairo --with-java-home=/usr/lib/jvm/java-1.5.0-gcj-5-amd64/jre --enable-java-home --with-jvm-root-dir=/usr/lib/jvm/java-1.5.0-gcj-5-amd64 --with-jvm-jar-dir=/usr/lib/jvm-exports/java-1.5.0-gcj-5-amd64 --with-arch-directory=amd64 --with-ecj-jar=/usr/share/java/eclipse-ecj.jar --enable-objc-gc --enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
gcc version 5.4.1 20160929 (Ubuntu 5.4.1-2ubuntu2) 

klib/test$ make

gcc -g -Wall -O2 -I.. -o kbtree_test kbtree_test.c
In file included from kbtree_test.c:10:0:
../kbtree.h:333:13: warning: ‘kb_itr_get_int’ defined but not used [-Wunused-function]
  static int kb_itr_get_##name(kbtree_##name##_t *b, const key_t * __restrict k,
             ^
../kbtree.h:372:2: note: in expansion of macro ‘__KB_ITR’
  __KB_ITR(name, key_t)
  ^
kbtree_test.c:11:1: note: in expansion of macro ‘KBTREE_INIT’
 KBTREE_INIT(int, uint32_t, kb_generic_cmp)
 ^
../kbtree.h:333:13: warning: ‘kb_itr_get_str’ defined but not used [-Wunused-function]
  static int kb_itr_get_##name(kbtree_##name##_t *b, const key_t * __restrict k,
             ^
../kbtree.h:372:2: note: in expansion of macro ‘__KB_ITR’
  __KB_ITR(name, key_t)
  ^
kbtree_test.c:12:1: note: in expansion of macro ‘KBTREE_INIT’
 KBTREE_INIT(str, str_t, kb_str_cmp)
 ^
gcc -g -Wall -O2 -I.. -o khash_keith khash_keith.c
gcc -g -Wall -O2 -I.. -o khash_keith2 khash_keith2.c
khash_keith2.c: In function ‘main’:
khash_keith2.c:32:9: warning: unused variable ‘l’ [-Wunused-variable]
  int i, l, n = 1000, ret;
         ^
gcc -g -Wall -O2 -I.. -o khash_test khash_test.c
gcc -g -Wall -O2 -I.. -o klist_test klist_test.c
gcc -g -Wall -O2 -I.. -o kseq_test kseq_test.c -lz
gcc -g -Wall -O2 -I.. -o kseq_bench kseq_bench.c -lz
gcc -g -Wall -O2 -I.. -o kseq_bench2 kseq_bench2.c -lz
In file included from kseq_bench2.c:6:0:
kseq_bench2.c: In function ‘ks_getc’:
kseq_bench2.c:7:19: warning: implicit declaration of function ‘read’ [-Wimplicit-function-declaration]
 KSTREAM_INIT(int, read, 4096)
                   ^
../kseq.h:74:14: note: in definition of macro ‘__KS_GETC’
    ks->end = __read(ks->f, ks->buf, __bufsize); \
              ^
kseq_bench2.c:7:1: note: in expansion of macro ‘KSTREAM_INIT’
 KSTREAM_INIT(int, read, 4096)
 ^
kseq_bench2.c: In function ‘main’:
kseq_bench2.c:39:3: warning: implicit declaration of function ‘close’ [-Wimplicit-function-declaration]
   close(fd);
   ^
gcc -g -Wall -O2 -I.. -o ksort_test ksort_test.c
g++ -g -Wall -O2 -I.. -o ksort_test-stl ksort_test.cc
In file included from ksort_test.cc:7:0:
ksort_test.cc: In function ‘void ks_sample_int(size_t, size_t, int*)’:
../ksort.h:276:10: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
    if (k != n - pop - 1) tmp = a[k], a[k] = a[n-pop-1], a[n-pop-1] = tmp; \
          ^
../ksort.h:295:36: note: in expansion of macro ‘KSORT_INIT’
 #define KSORT_INIT_GENERIC(type_t) KSORT_INIT(type_t, type_t, ks_lt_generic)
                                    ^
ksort_test.cc:8:1: note: in expansion of macro ‘KSORT_INIT_GENERIC’
 KSORT_INIT_GENERIC(int)
 ^
ksort_test.cc: In instantiation of ‘void _RadixSort_Unsigned_PowerOf2Radix_1(_Type*, long int, _Type, long unsigned int) [with _Type = unsigned int; long unsigned int PowerOfTwoRadix = 256ul; long unsigned int Log2ofPowerOfTwoRadix = 8ul; long int Threshold = 32l]’:
ksort_test.cc:776:102:   required from here
ksort_test.cc:748:55: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   while( _current >= startOfBin[ nextBin ] && nextBin < numberOfBins )
                                                       ^
ksort_test.cc:750:70: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  while( endOfBin[ nextBin - 1 ] == startOfBin[ nextBin ] && nextBin < numberOfB
                                                                     ^
g++ -g -Wall -O2 -I.. -o kvec_test kvec_test.cc
gcc -g -Wall -O2 -I.. -o kmin_test kmin_test.c ../kmath.c
/tmp/cc13nLlA.o: In function `kr_normal':
/home/guest/klib/test/../kmath.c:81: undefined reference to `log'
/home/guest/klib/test/../kmath.c:81: undefined reference to `sqrt'
/tmp/cc13nLlA.o: In function `kf_lgamma':
/home/guest/klib/test/../kmath.c:309: undefined reference to `log'
/home/guest/klib/test/../kmath.c:309: undefined reference to `log'
/tmp/cc13nLlA.o: In function `_kf_gammap':
/home/guest/klib/test/../kmath.c:369: undefined reference to `log'
/home/guest/klib/test/../kmath.c:369: undefined reference to `log'
/tmp/cc13nLlA.o: In function `_kf_gammaq':
/home/guest/klib/test/../kmath.c:390: undefined reference to `log'
/tmp/cc13nLlA.o:/home/guest/klib/test/../kmath.c:390: more undefined references to `log' follow
/tmp/cc13nLlA.o: In function `kf_betai_aux':
/home/guest/klib/test/../kmath.c:432: undefined reference to `exp'
/tmp/cc13nLlA.o: In function `kf_erfc':
/home/guest/klib/test/../kmath.c:336: undefined reference to `exp'
/tmp/cc13nLlA.o: In function `_kf_gammap':
/home/guest/klib/test/../kmath.c:369: undefined reference to `exp'
/tmp/cc13nLlA.o: In function `_kf_gammaq':
/home/guest/klib/test/../kmath.c:390: undefined reference to `exp'
collect2: error: ld returned 1 exit status
Makefile:48: recipe for target 'kmin_test' failed
make: *** [kmin_test] Error 1

how fix this?

metab0t commented 7 years ago

adding -lm in Makefile items using kmath.c will solve the problem