我在makefile中遇到两个问题,我无法弄明白。因此,一些帮助将不胜感激。
另外,我是linux和makefile的新手。所以,如果有人能指导我了解相关资源,我将不胜感激。
成功运行:如果我可以执行以下操作,我可以成功运行此makefile:
A)$gcc -c tsnnls_test_DKU.c
B)然后,$make
3)我可以成功调用我的函数。
1)运行不成功但是,如果我在make文件中对以下内容发表评论
# Here is a simple Make Macro.
LINK_TARGET = tsnnls_test_DKU
OBJS_LOC = tsnnls_test_DKU.o
tsnnls_test_DKU.o: tsnnls_test_DKU.c
gcc tsnnls_test_DKU.c
然后,然后执行$make
,我收到错误
dkumar@dkumar-Precision-WorkStation-T7500 ~/libtsnnls-2.3.3/tsnnls $ make
gcc tsnnls_test_DKU.c
/tmp/ccvbnByX.o: In function `lsqrwrapper':
tsnnls_test_DKU.c:(.text+0x598): undefined reference to `alloc_lsqr_mem'
tsnnls_test_DKU.c:(.text+0x6a8): undefined reference to `sparse_lsqr_mult'
tsnnls_test_DKU.c:(.text+0x6c7): undefined reference to `lsqr'
tsnnls_test_DKU.c:(.text+0x742): undefined reference to `free_lsqr_mem'
/tmp/ccvbnByX.o: In function `main':
tsnnls_test_DKU.c:(.text+0x9cb): undefined reference to `taucs_construct_sorted_ccs_matrix'
tsnnls_test_DKU.c:(.text+0xb15): undefined reference to `t_snnls_fallback'
tsnnls_test_DKU.c:(.text+0xb66): undefined reference to `t_snnls'
tsnnls_test_DKU.c:(.text+0xc92): undefined reference to `colvector_write_mat'
tsnnls_test_DKU.c:(.text+0xcce): undefined reference to `taucs_ccs_free'
collect2: error: ld returned 1 exit status
make: *** [tsnnls_test_DKU.o] Error 1
2)运行不成功另外,如果我在makefile中注释掉“clean: ..
”部分,它只会清理并且在我尝试时不会生成:
A)$gcc -c tsnnls_test_DKU.c
B)然后,$make
然后,我得到以下输出:
dkumar@dkumar-Precision-WorkStation-T7500 ~/libtsnnls-2.3.3/tsnnls $ make
rm -f tsnnls_test_DKU
echo Clean done
Clean done
这是我的makefile
# A sample Makefile
# Here is a simple Make Macro.
LINK_TARGET = tsnnls_test_DKU
OBJS_LOC = tsnnls_test_DKU.o
#tsnnls_test_DKU.o: tsnnls_test_DKU.c
# gcc tsnnls_test_DKU.c
# Here is a Make Macro that uses the backslash to extend to multiple lines.
OBJS = libtsnnls_la-taucs_malloc.o libtsnnls_la-taucs_ccs_order.o \
libtsnnls_la-taucs_ccs_ops.o libtsnnls_la-taucs_vec_base.o \
libtsnnls_la-taucs_complex.o libtsnnls_la-colamd.o \
libtsnnls_la-amdbar.o libtsnnls_la-amdexa.o \
libtsnnls_la-amdtru.o libtsnnls_la-genmmd.o \
libtsnnls_la-taucs_timer.o libtsnnls_la-taucs_sn_llt.o \
libtsnnls_la-taucs_ccs_base.o libtsnnls_la-tlsqr.o \
libtsnnls_la-tsnnls.o libtsnnls_la-lsqr.o \
$(OBJS_LOC)
REBUILDABLES = $(LINK_TARGET)
##DK COMMENTED OUT THE CLEANING PART
#clean :
# rm -f $(REBUILDABLES)
# echo Clean done
all : $(LINK_TARGET)
echo All done
#Inclusion of all libraries
RANLIB = ranlib
STATICLIB= /usr/local/lib/taucs_full/lib/linux/libtaucs.a
tsnnls_test_LDADD = $(LDADD)
LIBS = -largtable2 -llapack -lblas -lquadmath -lm
$(LINK_TARGET) : $(OBJS) $(tsnnls_test_LDADD) $(LIBS) $(STATICLIB)
gcc -g -o $@ $^