1
我在makefile中包含庫時遇到了一些麻煩。在makefile中包含庫時出錯
庫nlopt
安裝在/usr/lib
,當我從命令行編譯我的程序運行正常:
gfortran -I/usr/include main.f90 -L/usr/lib -lnlopt -lm -o exec
但是我需要使用一個makefile。下面的人似乎要被罰款,但它不工作,我得到:
main.f90:19: Error: Can't open included file 'nlopt.f'
你能找到的bug幫忙,好嗎?
INCLUDES = -I/usr/include
LFLAGS = -L/usr/lib
LIBS = -lnlopt -lm
objects = main.o
f90comp = gfortran
exec: $(objects)
$(f90comp) $(INCLUDES) -o exec $(objects) $(LFLAGS) $(LIBS)
main.o: main.f90
$(f90comp) -c main.f90
clean:
rm *.o *.mod exec
rm $(objects)
# End of the makefile
($(f90comp)和RM之前,有標籤)
「nlopt.f」文件在哪裏?它在'usr/include'中嗎?你確定編譯器不關心參數順序嗎? (我會嘗試確切*相同的順序。) – Beta 2012-03-25 23:52:01
你可以顯示'make'的整個輸出嗎?我有一種感覺,在你的錯誤信息會很有教育意義的情況下。 – sarnold 2012-03-25 23:53:37
嘗試'make -n'有時也很有用,因爲它只會告訴你什麼命令試圖運行。 – mgilson 2012-03-26 00:20:49