在命令行中使用此命令
gcc -static dwttest.c -L. -lwavelib -o test
我正在尝试将测试功能链接到我使用以下makefile构建的小波静态库:
edit: object.o libwave.a
object.o:
gcc -c *.c
libwave.a:
ar rcs libwavelib.a *.o
C文件似乎都包含math.h,所以我无法真正分辨出问题所在。
错误输出:
./libwavelib.a(wavelib.o): In function `wpt_init':
wavelib.c:(.text+0x9ac): undefined reference to `ceil'
./libwavelib.a(wavelib.o): In function `cwt_init':
wavelib.c:(.text+0xf09): undefined reference to `log'
wavelib.c:(.text+0xf62): undefined reference to `pow'
./libwavelib.a(wavelib.o): In function `dwt':
wavelib.c:(.text+0x34d0): undefined reference to `ceil'
wavelib.c:(.text+0x3721): undefined reference to `ceil'
./libwavelib.a(wavelib.o): In function `wtree':
wavelib.c:(.text+0x45ba): undefined reference to `ceil'
wavelib.c:(.text+0x47e4): undefined reference to `ceil'
./libwavelib.a(wavelib.o): In function `dwpt':
wavelib.c:(.text+0x4e4e): undefined reference to `ceil'
./libwavelib.a(wavelib.o):wavelib.c:(.text+0x51ff): more undefined references to `ceil' follow
./libwavelib.a(wavelib.o): In function `getCWTScaleLength':
wavelib.c:(.text+0x620b): undefined reference to `log'
./libwavelib.a(wavelib.o): In function `setCWTScales':
wavelib.c:(.text+0x62e0): undefined reference to `pow'
./libwavelib.a(wavelib.o): In function `cwt':
wavelib.c:(.text+0x6544): undefined reference to `pow'
./libwavelib.a(wavelib.o): In function `getSWTRecCoeff':
wavelib.c:(.text+0x9d29): undefined reference to `pow'
./libwavelib.a(wavelib.o): In function `iswt':
wavelib.c:(.text+0xa835): undefined reference to `pow'
./libwavelib.a(wavelib.o): In function `getMODWTRecCoeff':
wavelib.c:(.text+0xbe92): undefined reference to `pow'
./libwavelib.a(wavelib.o):wavelib.c:(.text+0xca48): more undefined references to `pow' follow
./libwavelib.a(wavelib.o): In function `dwt2':
wavelib.c:(.text+0xdf5a): undefined reference to `ceil'
wavelib.c:(.text+0xdf7b): undefined reference to `ceil'
wavelib.c:(.text+0xe43c): undefined reference to `ceil'
wavelib.c:(.text+0xe45d): undefined reference to `ceil'
./libwavelib.a(wavelib.o): In function `iswt2':
wavelib.c:(.text+0xfd8b): undefined reference to `pow'
./libwavelib.a(wavelib.o): In function `imodwt2':
wavelib.c:(.text+0x108a3): undefined reference to `pow'
./libwavelib.a(wtmath.o): In function `wmaxiter':
wtmath.c:(.text+0x2bf2): undefined reference to `log'
./libwavelib.a(wtmath.o): In function `entropy_s':
wtmath.c:(.text+0x2cb7): undefined reference to `log'
./libwavelib.a(wtmath.o): In function `entropy_n':
wtmath.c:(.text+0x2e1f): undefined reference to `pow'
./libwavelib.a(wtmath.o): In function `entropy_l':
wtmath.c:(.text+0x2edf): undefined reference to `log'
./libwavelib.a(cwt.o): In function `wave_function':
cwt.c:(.text+0xaa): undefined reference to `sqrt'
cwt.c:(.text+0xd6): undefined reference to `pow'
cwt.c:(.text+0x161): undefined reference to `exp'
cwt.c:(.text+0x23a): undefined reference to `sqrt'
cwt.c:(.text+0x2ca): undefined reference to `sqrt'
cwt.c:(.text+0x2fd): undefined reference to `pow'
cwt.c:(.text+0x332): undefined reference to `sqrt'
cwt.c:(.text+0x3d0): undefined reference to `pow'
cwt.c:(.text+0x3f5): undefined reference to `exp'
cwt.c:(.text+0x591): undefined reference to `sqrt'
cwt.c:(.text+0x5c8): undefined reference to `sqrt'
cwt.c:(.text+0x661): undefined reference to `pow'
cwt.c:(.text+0x692): undefined reference to `pow'
cwt.c:(.text+0x6a7): undefined reference to `exp'
cwt.c:(.text+0x77c): undefined reference to `pow'
cwt.c:(.text+0x7ad): undefined reference to `pow'
cwt.c:(.text+0x7c2): undefined reference to `exp'
cwt.c:(.text+0x822): undefined reference to `sqrt'
./libwavelib.a(cwt.o): In function `psi0':
cwt.c:(.text+0x110a): undefined reference to `sqrt'
cwt.c:(.text+0x110f): undefined reference to `sqrt'
cwt.c:(.text+0x11c0): undefined reference to `pow'
cwt.c:(.text+0x11f4): undefined reference to `sqrt'
cwt.c:(.text+0x1289): undefined reference to `pow'
cwt.c:(.text+0x130c): undefined reference to `sqrt'
./libwavelib.a(cwt.o): In function `cdelta':
cwt.c:(.text+0x1617): undefined reference to `pow'
cwt.c:(.text+0x1720): undefined reference to `sqrt'
cwt.c:(.text+0x17ed): undefined reference to `sqrt'
./libwavelib.a(cwt.o): In function `icwavelet':
cwt.c:(.text+0x18ae): undefined reference to `sqrt'
cwt.c:(.text+0x1934): undefined reference to `sqrt'
./libwavelib.a(cwtmath.o): In function `nsfft_fd':
cwtmath.c:(.text+0x39a): undefined reference to `cos'
cwtmath.c:(.text+0x3bf): undefined reference to `sin'
cwtmath.c:(.text+0x404): undefined reference to `cos'
cwtmath.c:(.text+0x429): undefined reference to `sin'
./libwavelib.a(cwtmath.o): In function `nsfft_bk':
cwtmath.c:(.text+0x65e): undefined reference to `cos'
cwtmath.c:(.text+0x6a6): undefined reference to `sin'
cwtmath.c:(.text+0x713): undefined reference to `cos'
cwtmath.c:(.text+0x75a): undefined reference to `sin'
./libwavelib.a(cwtmath.o): In function `fix':
cwtmath.c:(.text+0xa6e): undefined reference to `floor'
cwtmath.c:(.text+0xa87): undefined reference to `ceil'
./libwavelib.a(cwtmath.o): In function `cwt_gamma':
cwtmath.c:(.text+0xdb2): undefined reference to `sin'
cwtmath.c:(.text+0x1132): undefined reference to `log'
cwtmath.c:(.text+0x1169): undefined reference to `exp'
./libwavelib.a(hsfft.o): In function `fft_init':
hsfft.c:(.text+0xb0): undefined reference to `log10'
hsfft.c:(.text+0xc9): undefined reference to `ceil'
hsfft.c:(.text+0xe5): undefined reference to `pow'
./libwavelib.a(hsfft.o): In function `mixed_radix_dit_rec':
hsfft.c:(.text+0x8678): undefined reference to `cos'
hsfft.c:(.text+0x86c5): undefined reference to `sin'
./libwavelib.a(hsfft.o): In function `bluestein_exp':
hsfft.c:(.text+0x9169): undefined reference to `cos'
hsfft.c:(.text+0x9197): undefined reference to `sin'
./libwavelib.a(hsfft.o): In function `bluestein_fft':
hsfft.c:(.text+0x933c): undefined reference to `log10'
hsfft.c:(.text+0x9355): undefined reference to `ceil'
hsfft.c:(.text+0x9377): undefined reference to `pow'
./libwavelib.a(hsfft.o): In function `twiddle':
hsfft.c:(.text+0xab0a): undefined reference to `cos'
hsfft.c:(.text+0xab38): undefined reference to `sin'
./libwavelib.a(hsfft.o): In function `longvectorN':
hsfft.c:(.text+0xac40): undefined reference to `cos'
hsfft.c:(.text+0xac78): undefined reference to `sin'
./libwavelib.a(real.o): In function `fft_real_init':
real.c:(.text+0x9d): undefined reference to `cos'
real.c:(.text+0xcc): undefined reference to `sin'
collect2: error: ld returned 1 exit status
抱歉,这是一个愚蠢的错误,我对makefile还是很陌生,谢谢!
编译时也需要链接数学库。将-lm
添加到gcc命令。