vscode_gcc.png

使用 C/C++ Makefile Project 插件建立 Makefile

  • ctrl+shift+p, 插件选择 Only C++ Makefile

修改过的 Makefile 添加了 windres.exe 编译 resource.rc

Makefile.png

Makefile

# Compiler settings - Can be customized.
CC = g++
WINDRES = windres.exe
CXXFLAGS = -Wall -O2 -std=c++11 -fexec-charset=gbk -finput-charset=UTF-8
LDFLAGS =  -s -shared-libstdc++  -lgdi32 -luser32 -lkernel32 -lcomctl32 -mwindows

# Makefile settings - Can be customized.
APPNAME = WinKcp_Launcher
EXT = .cpp

SRCDIR = .
OBJDIR = .

############## Do not change anything from here downwards! #############
SRC = $(wildcard $(SRCDIR)/*$(EXT))
OBJ = $(SRC:$(SRCDIR)/%$(EXT)=$(OBJDIR)/%.o)
DEP = $(OBJ:$(OBJDIR)/%.o=%.d)

####################### Targets beginning here #########################
all: $(APPNAME)

# Builds the app
$(APPNAME): $(OBJ)
    $(WINDRES)  -J rc -O coff -i resource.rc -o resource.res
    $(CC) $(CXXFLAGS) -o $@ $^ $(LDFLAGS)  resource.res

# Includes all .h files
-include $(DEP)

# Building rule for .o files and its .c/.cpp in combination with all .h
$(OBJDIR)/%.o: $(SRCDIR)/%$(EXT)
    $(CC)  $(CXXFLAGS) -o $@ -c $<
分类: 学习编程

0 条评论

发表回复

Avatar placeholder

您的电子邮箱地址不会被公开。 必填项已用 * 标注

© 2024 兰雅VBA代码分享
浙ICP备2021017795号-2 浙公网安备33078102100266号