我有以下生成文件:
CC = gcc
ROOTPATH = /home/swagatam
LIB_PATH = $(ROOTPATH)/mylib/libf2c.a \
$(ROOTPATH)/mylib/blas_LINUX.a \
$(ROOTPATH)/mylib/lapack_LINUX.a -lm
INC_PATH = -I$(ROOTPATH)/myinclude
swadgesv : swadgesv.o
$(CC) $(LIB_PATH) swadgesv.o -o swadgesv
swadgesv.o : swadgesv.c
$(CC) $(INC_PATH) -c swadgesv.c
clean:
rm -f *.o
swadgesv.c 是 AX = B 形式的程序求解方程。我需要 3 个头文件和 3 个库来链接以解决问题。但是当我在终端中运行 Makefile 时,它显示:
gcc -I/home/swagatam/myinclude -c swadgesv.c
gcc /home/swagatam/mylib/libf2c.a /home/swagatam/mylib/blas_LINUX.a /home/swagatam/mylib/lapack_LINUX.a -lm swadgesv.o -o swadgesv
swadgesv.o: In function `main':
swadgesv.c:(.text+0x0): multiple definition of `main'
/home/swagatam/mylib/libf2c.a(main.o):(.text.startup+0x0): first defined here
/home/swagatam/mylib/libf2c.a(main.o): In function `main':
(.text.startup+0xad): undefined reference to `MAIN__'
swadgesv.o: In function `main':
swadgesv.c:(.text+0xc1): undefined reference to `dgesv_'
collect2: ld returned 1 exit status
make: *** [swadgesv] Error 1
即使我更改 LIB_PATH 中库的顺序,它也会显示不同的错误。我正在从我安装的 clapack 库中调用一个函数 dgsev。