Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/155.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ 如何从命令行(Windows 7)编译和运行project?_C++_Windows_Linux_Command Line_Makefile - Fatal编程技术网

C++ 如何从命令行(Windows 7)编译和运行project?

C++ 如何从命令行(Windows 7)编译和运行project?,c++,windows,linux,command-line,makefile,C++,Windows,Linux,Command Line,Makefile,我有一个包含makefile的项目: # a simple makefile # Uncomment, if compression support is desired #DCOMP=-DWITH_COMPRESSION #ZLIB=-lz #Compiler CC=g++ # compiler switches #CPPFLAGS=-g -I. CPPFLAGS=-O -I. CFLAGS=-O -I. $(DCOMP) #LDFLAGS=-L/usr/local/lib #libr

我有一个包含makefile的项目:

# a simple makefile

# Uncomment, if compression support is desired
#DCOMP=-DWITH_COMPRESSION
#ZLIB=-lz

#Compiler
CC=g++
# compiler switches
#CPPFLAGS=-g -I.
CPPFLAGS=-O -I.
CFLAGS=-O -I. $(DCOMP) 

#LDFLAGS=-L/usr/local/lib
#libraries
LIBS= -lm $(ZLIB)

# Compilation rules
# target:source
%.o:%.c
    $(CC) $(CFLAGS) -o $@ -c $<
%.o:%.cpp
    $(CC) $(CPPFLAGS) -o $@ -c $<
# $@-target, $<-source

DNAME=f3dProjBasicNoComp12
PROGRAM=project

PROJ_OBJECTS= project.o f3d.o f3dGridLite.o

#the first (default)
all:$(PROGRAM)

project:$(PROJ_OBJECTS)
    $(CC) $(LDFLAGS) -o $@ $(PROJ_OBJECTS) $(LIBS)

clean:
    rm -f $(PROGRAM) *.o  core* *.ppm

pack:
    make clean
    (cd .. && tar cvzf $(DNAME).tgz $(DNAME))
要运行应用程序,我应该使用类似于
project-xsomethink.obj的somethink。
但是因为我无法编译makefile,所以无法运行该项目


您能帮助我吗?

最简单的解决方案是下载带有gcc的minigw for windows。看看:

1)您必须安装Visual Studio


2) 您必须运行Visual Studio命令提示符(安装后,您将在Microsoft Visual Studio的“开始”菜单项中找到它)并从那里调用
nmake

如果您的项目配置为使用gcc/g++(如示例中所示),则应安装。启动mingw shell之后,进入目录并键入
make
(前提是在安装mingw时安装了make)或
make-f

注意:c:\mydir1\mydir2
的windows路径在mingw
/c/mydir1/mydir2
中。因此,您应该通过键入
cd/c/mydir1/mydir2
来访问您的目录


如果将项目配置为使用Visual Studio(cl.exe编译器),则可以:

  • 启动VisualStudio控制台
  • 启动cmd.exe提示符,然后运行
    “c:\Program Files\Microsoft Visual Studio 9.0\VC\bin\vcvars32.bat”
    (或相应的
    vcvars32.bat
  • 完成此操作后,您可以使用
    cd c:\mydir1\mydir2
    进入目录,然后键入
    nmake
    (来自visual studio软件包的make等效项)或
    nmake/f

    如果您需要其他工具链来编译,那么您应该遵循特定的步骤。我记得要使用Borland编译器,您只需要设置
    bcc32
    可执行文件的路径

    以后编辑:


    如果项目使用unix特定的过程,您应该使用(如注释中所述)。

    您确实安装了编译器(尤其是Visual Studio)?请签出或。他们可以在Windows中“模拟”UNIX环境。除非绝对必要,否则我认为没有理由使用MinGW。makefile似乎是特定于gnu的,例如
    CC=g++
    。如果他不想编辑在整个课程中获得的makefile,那么安装cygwin、minigw或msys是最简单的解决方案。也许不是最优雅的,但需要最少的努力。@VioletGiraffe,因为你没有Visual Studio?@Pacerier:VS Express。很好,试试看。
    'nmake' is not recognized as an internal or external command,
    operable program or batch file.