1

久しぶりに、共同開発したプログラムをダウンロードして、Ubuntu Linux 12.04 で再コンパイルしようとしましたが、math.h が見つからないようです。これは、 で最近何かが変更されたことが原因である可能性がありgccますsrc/Makefile.am

http://www.ub.edu/softevol/variscan/からダウンロード:

tar xzf variscan-2.0.2.tar.gz 
cd variscan-2.0.2/
make distclean
sh ./autogen.sh
make

私は得る:[...]

gcc -DNDEBUG -O3 -W -Wall -ansi -pedantic  -lm  -o variscan variscan.o statistics.o common.o linefile.o memalloc.o dlist.o errabort.o dystring.o intExp.o kxTok.o pop.o window.o free.o output.o readphylip.o readaxt.o readmga.o readmaf.o readhapmap.o readxmfa.o readmav.o ran1.o swcolumn.o swnet.o swpoly.o swref.o  
statistics.o: In function `calculate_Fu_and_Li_D':
statistics.c:(.text+0x497): undefined reference to `sqrt'
statistics.o: In function `calculate_Fu_and_Li_F':
statistics.c:(.text+0x569): undefined reference to `sqrt'
statistics.o: In function `calculate_Fu_and_Li_D_star':
statistics.c:(.text+0x63b): undefined reference to `sqrt'
statistics.o: In function `calculate_Fu_and_Li_F_star':
statistics.c:(.text+0x75c): undefined reference to `sqrt'
statistics.o: In function `calculate_Tajima_D':
statistics.c:(.text+0x85d): undefined reference to `sqrt'
statistics.o:statistics.c:(.text+0xcb1): more undefined references to `sqrt' follow
statistics.o: In function `calcRunMode21Stats':
statistics.c:(.text+0xe02): undefined reference to `log'
statistics.o: In function `correctedDivergence':
statistics.c:(.text+0xe5a): undefined reference to `log'
statistics.o: In function `calcRunMode22Stats':
statistics.c:(.text+0x104a): undefined reference to `sqrt'
statistics.o: In function `calculate_Fu_fs':
statistics.c:(.text+0x11a8): undefined reference to `fabsl'
statistics.c:(.text+0x11ca): undefined reference to `powl'
statistics.c:(.text+0x11f2): undefined reference to `logl'
statistics.o: In function `calculateStatistics':
statistics.c:(.text+0x13f2): undefined reference to `log'
collect2: ld returned 1 exit status
make[1]: *** [variscan] Error 1
make[1]: Leaving directory `/home/avilella/variscan/latest/variscan-2.0.2/src'
make: *** [all-recursive] Error 1

ライブラリが存在するのは、この単純な例が完全にうまく機能するためです。

$ gcc test.c -o test -lm
$ cat test.c 
#include <stdio.h>
#include <math.h>
int main(void)
{
        double x = 0.5;
        double result = sqrt(x);
        printf("The hyperbolic cosine of %lf is %lf\n", x, result);
        return 0;
}

何か案は?

4

2 に答える 2

3

簡単な例のように、ライブラリはコンパイラ コマンドの最後に配置する必要があります。

gcc -DNDEBUG -O3 -W -Wall -ansi -pedantic -o variscan variscan.o statistics.o common.o linefile.o memalloc.o dlist.o errabort.o dystring.o intExp.o kxTok.o pop.o window .o free.o output.o readphylip.o readaxt.o readmga.o readmaf.o readhapmap.o readxmfa.o readmav.o ran1.o swcolumn.o swnet.o swpoly.o swref.o statistics.o -lm

GCC リンク オプションから:

-図書館
-l ライブラリ
    リンク時に library という名前のライブラリを検索します。
    (別の引数としてライブラリを使用する 2 番目の選択肢
    これは POSIX 準拠のみを目的としており、推奨されません。)

    コマンドのどこにこのオプションを記述するかによって違いが生じます。
    リンカーは、ライブラリとオブジェクト ファイルを検索して処理します。
    それらが指定されている順序。
    したがって、`foo.o -lz bar.o' はファイル foo.o の後にライブラリ `z' を検索しますが、
    bar.o.の前に bar.o が `z' の関数を参照する場合、それらの関数
    ロードされない場合があります。
于 2012-07-09T15:18:02.897 に答える
1

この単純な変更で十分なようですMakefile.am

+variscan_LDADD = -lm
-variscan_LDFLAGS = -lm
于 2012-07-09T16:25:13.320 に答える