首页 > 解决方案 > 带有 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-c++makefileclionatl

解决方案


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.


推荐阅读