Java文件能编译成lib吗_Makefile用于将一些.cpp和.h编译成lib
在構(gòu)建dll時(shí)可以設(shè)置很多選項(xiàng),但是如果您從命令行執(zhí)行此操作,則可以使用這個(gè)基本命令:
gcc -shared -o mydll.dll file1.o file2.o file3.o
這是一個(gè)makefile(通常稱為 Makefile ),它將處理整個(gè)構(gòu)建過程:
# You will have to modify this line to list the actual files you use.
# You could set it to use all the "fileN" files that you have,
# but that's dangerous for a beginner.
FILES = file1 file2 file3
OBJECTS = $(addsuffix .o,$(FILES)) # This is "file1.o file2.o..."
# This is the rule it uses to assemble file1.o, file2.o... into mydll.dll
mydll.dll: $(OBJECTS)
gcc -shared $^ -o $@ # The whitespace at the beginning of this line is a TAB.
# This is the rule it uses to compile fileN.cpp and fileN.h into fileN.o
$(OBJECTS): %.o : %.cpp %.h
g++ -c $< -o $@ # Again, a TAB at the beginning.
現(xiàn)在要構(gòu)建 mydll.dll ,只需輸入"make"即可 .
幾個(gè)筆記 . 如果只鍵入"make"而不指定makefile或目標(biāo)(要構(gòu)建的東西),Make將嘗試使用默認(rèn)的makefile("GNUMakefile","makefile"或"Makefile")和默認(rèn)目標(biāo)(makefile中的第一個(gè),在這種情況下) mydll.dll ) .
總結(jié)
以上是生活随笔為你收集整理的Java文件能编译成lib吗_Makefile用于将一些.cpp和.h编译成lib的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: java中删除node节点_[Java]
- 下一篇: java美元兑换,(Java实现) 美元