visual-c++ - 带有 MSVC 和 CLION 的 Makefile
问题描述
我使用 ATL 库,所以我必须使用 MSVC 而不是 MinGW。但是使用 Makefile 编写的 MSVC 库是看不到的(使用 Makefile 他们是)。我想 MSVC 根本看不到 Makefile。对如何编译项目有任何假设吗?
# Remove NDEBUG define to trigger asserts
CPPFLAGS+=-O2 -std=gnu++11 -I. -DNDEBUG -Wall -Wno-sign-compare -Wno-unused -g -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -DOPENSSL
LDFLAGS+=-levent -lstdc++ -lssl -lcrypto
uname_S := $(shell sh -c 'uname -s 2>/dev/null || echo not')
ifeq ($(uname_S),FreeBSD)
CXX=clang++
LIBEVENT_HOME=D:/ProximaX/d/vcpkg/vcpkg/packages/libevent_x86-windows
CPPFLAGS+=-I${LIBEVENT_HOME}/include
LDFLAGS+=-L${LIBEVENT_HOME}/lib
else
CXX?=g++
LIBEVENT_HOME=D:/ProximaX/d/vcpkg/vcpkg/packages/libevent_x86-windows
CPPFLAGS+=-I${LIBEVENT_HOME}/include
LDFLAGS+=-L${LIBEVENT_HOME}/lib
OPENSSL_HOME=D:/ProximaX/d/vcpkg/vcpkg/packages/openssl_x86-windows
CPPFLAGS+=-I${OPENSSL_HOME}/include
LDFLAGS+=-L${OPENSSL_HOME}/lib
ATL_HOME=D:/VS17/VC/Tools/MSVC/14.16.27023/atlmfc
CPPFLAGS+=-I${ATL_HOME}/include
LDFLAGS+=-L${ATL_HOME}/lib
endif
all: swift-dynamic
swift: swift.o sha1.o compat.o sendrecv.o send_control.o hashtree.o bin.o binmap.o channel.o transfer.o httpgw.o statsgw.o cmdgw.o avgspeed.o avail.o storage.o zerostate.o zerohashtree.o livehashtree.o live.o api.o content.o swarmmanager.o address.o livesig.o exttrack.o
swift-static: swift
${CXX} ${CPPFLAGS} -o swift *.o ${LDFLAGS} -static -lrt
strip swift
touch swift-static
swift-dynamic: swift
${CXX} ${CPPFLAGS} -o swift *.o ${LDFLAGS}
touch swift-dynamic
clean:
rm -f *.o swift swift-static swift-dynamic 2>/dev/null
.PHONY: all clean swift swift-static swift-dynamic
解决方案
Visual Studio does not use makefiles. You need to create a project and configure it correctly. See also this question.
That is why libraries that target both Windows and Linux provide both a makefile and a Visual Studio project file. Or they use a "meta build tool", such as CMake, that can generate both from the same source.
Alternatively you can rewrite the makefile to call the Visual Studio compiler but the compilation and linking options will be different.
推荐阅读
- postgresql - postgreql 二维数组文字无法识别
- flutter - Flutter - 带有弓形图标的行
- python - Django 静态文件未加载 ImageField URL
- python - 如何在没有选择的情况下将评论表单绑定到一个锅(Django)
- node.js - 使用 nodejs 将 base64Image 上传到 Azure 存储时出错
- javascript - 在 Vue 3 中使用 Vuex 4 模块和 TypeScript,以及如何修复循环依赖 linting 错误?
- c++ - 是否可以在类定义中使用类对象作为变量?
- dart - 使用 dartz 中的 Either 时出现编译器错误
- reactjs - 如何使用 useRef 获取多个单击元素的文本?
- alibaba-cloud - 如何限制对 OSS 上文件的访问,同时仍然允许使用 wget 或 curl 下载