eclipsecdt编译动态库,供msvc调用3.手写Makefile.cross[操作系统入门]
1## 2## libusp_bpm22.c 3## 4## Created by JK 5## 67# General configuration variables:
8 CC = gcc
9 CXX = g++
10 AR = ar
11 RM = rm -rf
12 DEBUG =
13 CFLAGS = $(DEBUG) -O3 -Wall -c -fmessage-length=0 -MMD -MP
14 TIME = $(shell date +%Y%m%d)
15
16 OBJ = usbBasic.o cdebug.o libusp_BPM22.o
17
18 LIBS = -lusb-1.0 -lFreeImage
19
20 TOP_PATH = $(shell pwd)/..
21 LIB_PATH = -L$(TOP_PATH)/libs 22 -L$(TOP_PATH)/libs/libusb-1.0.2223 -L$(TOP_PATH)/libs/freeimage3180 24 -L$(TOP_PATH)/libs/plus
25 INC_PATH = -I$(TOP_PATH)/usbBasic 26 -I$(TOP_PATH)/cDebug-log 27 -I$(TOP_PATH)/libs
28
29# All Target
30all: libusp_BPM22.dll
31
32 usbBasic.o: $(TOP_PATH)/usbBasic/g_header.h $(TOP_PATH)/usbBasic/usbbasic.h
33 $(CXX) $(CFLAGS) $(INC_PATH) $(LIBS) $(TOP_PATH)/usbBasic/usbbasic.cpp
34
35 cdebug.o: $(TOP_PATH)/cDebug-log/cdebug.h
36 $(CXX) $(CFLAGS) $(INC_PATH) $(LIBS) $(TOP_PATH)/cDebug-log/cdebug.cpp
37
38 libusp_BPM22.o: $(TOP_PATH)/libusp_BPM22/src/libusp_bpm22.h
39 $(CC) $(CFLAGS) $(INC_PATH) $(LIBS) $(TOP_PATH)/libusp_BPM22/src/libusp_bpm22.c
40
41libusp_BPM22.dll: $(OBJ)
42 @echo ‘‘
43 @echo ‘‘
44 @echo ‘-- Invoking: Cross G++ Linker With MinGW-GCC‘
45 @echo ‘-- Building target: [email protected]‘
46 $(CXX) $(LIB_PATH) -shared -o "libusp_BPM22.dll" $(OBJ) $(LIBS)
47 @echo ‘-- Building target: libusp_BPM22.a‘
48 $(CXX) $(LIB_PATH) -shared -o "libusp_BPM22.a" $(OBJ) $(LIBS)
49 @echo ‘-- Finished building target with makefile.cross‘
50
51clean:
52 -$(RM) $(OBJ) *.d libusp_BPM22.dll libusp_BPM22.def libusp_BPM22.lib libusp_BPM22.a
53 [email protected] ‘-- Finished make clean‘
54
55package:
56 mkdir -p build$(TIME)
57 $(RM) build$(TIME)/*.*
58 mkdir -p build$(TIME)/gcc-win32 build$(TIME)/msvc
59 @pexports libusp_BPM22.dll > libusp_BPM22.def
60 @lib /machine:i386 /def:libusp_BPM22.def /out:libusp_BPM22.lib
61 @echo ‘-- Finished make objects with makefile.cross‘
62 cp $(TOP_PATH)/usbBasic/g_header.h $(TOP_PATH)/libusp_BPM22/src/libusp_BPM22.h ./build$(TIME)/
63 cp -f libusp_BPM22.dll libusp_BPM22.a ./build$(TIME)/gcc-win32
64 cp -f libusp_BPM22.dll libusp_BPM22.lib ./build$(TIME)/msvc
65 @echo ‘-- ‘build$(TIME) >>./readme.txt
66
67clear:
68 -$(RM) $(OBJ) *.d libusp_BPM22.dll libusp_BPM22.def libusp_BPM22.lib libusp_BPM22.a libusp_BPM22.exp
69 [email protected] ‘-- Finished make clear‘
70
71.PHONY: all clean dependents
参考博文:
跟我一起写Makefile:MakeFile介绍
Makefile教程(绝对经典,所有问题看这一篇足够了)
Makefile简易教程
eclipse cdt 编译动态库,供msvc调用 -- 3.手写Makefile.cross
原文:https://www.cnblogs.com/jk-deamon/p/12802653.html
以上是 eclipsecdt编译动态库,供msvc调用3.手写Makefile.cross[操作系统入门] 的全部内容, 来源链接: utcz.com/z/516023.html