如何从命令行(Windows 7)编译和运行项目? [英] How can I compile and run project from command line(Windows 7)?

查看:193
本文介绍了如何从命令行(Windows 7)编译和运行项目?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个有makefile的项目:

I have a project which has a 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))

我想在Windows上运行它。教授说我应该编译并运行,但他没有告诉我如何在Windows上这样做。我已经阅读,我应该使用nmake MakeFile,但比:

And I want to run it on Windows. The professor has said that I should compile it and run, but he did not tell me how can I do this on Windows. I have read that I should use nmake MakeFile, but than:

'nmake' is not recognized as an internal or external command,
operable program or batch file.

要运行应用程序,我应该使用像 project -x somethink这样的东西。 obj
但是因为我无法编译makefile,所以无法运行该项目。

To run the application, I should use somethink like project -x somethink.obj. But because I cannot compile the makefile I cannot run the project.

你能帮我吗?

推荐答案

如果您的项目配置为使用gcc / g ++(如在您的示例中),那么您应该安装 mingw 。之后你启动mingw shell,你去你的目录并输入 make (假设你在安装mingw时安装了make)或 make -f < ; makefile name>

If your project is configured to use gcc/g++ (as in your example) then you should install mingw. After that you start the mingw shell, you go to your directory and type make (provided that you installed make when installing mingw) or make -f <makefile name>.

注意 c:\ mydir1 \mydir2 在mingw / c / mydir1 / mydir2 中。因此,您应该通过键入 cd / c / mydir1 / mydir2 到达您的目录。

NOTE: The windows path for c:\mydir1\mydir2 is in mingw /c/mydir1/mydir2. So you should reach your directory by typing cd /c/mydir1/mydir2.

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

If your project is configured to use Visual Studio (cl.exe compiler) you can:


  1. 启动Visual studio控制台

  2. 一个cmd.exe提示符,然后运行c:\Program Files\Microsoft Visual Studio 9.0 \VC\bin\vcvars32.bat(或您的对应 vcvars32.bat

  1. Start Visual studio console
  2. Start a cmd.exe prompt and after that run "c:\Program Files\Microsoft Visual Studio 9.0\VC\bin\vcvars32.bat" (or your corresponding vcvars32.bat)

cd c:\ mydir1 \mydir2 并键入 nmake code> nmake / f< your makefile name> 。

After you done this you go to your directory with cd c:\mydir1\mydir2 and type nmake (the make equivalent from visual studio package) or nmake /f <your makefile name>.

如果需要其他工具链编译,具体步骤。我记得使用Borland编译器只需要设置 bcc32 可执行文件的路径。

If you're required other toolchain to compile then you should follow specific steps. I remember that for using Borland compiler you only need to set the path to the bcc32 executable.

后修改:

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

In case the project uses unix specific procedure you should use cygwin (as mentioned in comments).

这篇关于如何从命令行(Windows 7)编译和运行项目?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆