[英]How to run makefile for C++ files in Windows (Vista) without the use of cygwin?
我使用的是Windows Vista ,並使用Makefile下載了C ++文件夾。 我想運行makefile來編譯Windows下的頭文件源文件。 最后我希望能夠在MATLAB的命令提示符之后調用這個C ++函數,所以我假設如果我使用cygwin這是不可能的,因為它只允許從cygwin中運行編譯。
我安裝了Windows SDK 7.1,並從它的commond提示符移動到makefile和source所在的目錄和nmake -f Makefile
並獲得響應Makefile(13) : fatal error U1001: syntax error : illegal character '^' in macro Stop.
我安裝了visual studio express 2010並從它的命令提示符嘗試了同樣的。 這些函數是眾所周知的,並且已經從這里使用 - 鏈接到托管c ++文件的頁面 。 所以我懷疑函數本身是否有錯誤。
如何運行makefile來編譯這些文件並隨后運行它們?
編輯:這是makefile :
#!/bin/bash
CC=g++
CFLAGS= -ansi -O5 -Wall
LDFLAGS= -ansi -lm -Wall
EXEC=community convert hierarchy
OBJ1= graph_binary.o community.o
OBJ2= graph.o
all: $(EXEC)
community : $(OBJ1) main_community.o
$(CC) -o $@ $^ $(LDFLAGS)
convert : $(OBJ2) main_convert.o
$(CC) -o $@ $^ $(LDFLAGS)
hierarchy : main_hierarchy.o
$(CC) -o $@ $^ $(LDFLAGS)
##########################################
# Generic rules
##########################################
%.o: %.cpp %.h
$(CC) -o $@ -c $< $(CFLAGS)
%.o: %.cpp
$(CC) -o $@ -c $< $(CFLAGS)
clean:
rm -f *.o *~ $(EXEC)
EDIT2:我從gnu安裝了make,這是輸出:這是dir
09/04/2013 17:13 <DIR> .
09/04/2013 17:13 <DIR> ..
24/09/2008 13:45 7,742 community.cpp
10/07/2008 13:41 4,386 community.h
10/07/2008 13:41 3,919 graph.cpp
10/07/2008 13:41 1,329 graph.h
10/07/2008 13:41 5,957 graph_binary.cpp
10/07/2008 13:41 3,434 graph_binary.h
23/07/2008 17:08 4,071 main_community.cpp
10/07/2008 13:41 2,110 main_convert.cpp
10/07/2008 13:41 3,449 main_hierarchy.cpp
10/07/2008 13:43 565 Makefile
23/07/2008 17:13 2,959 readme.txt
09/04/2013 17:13 <DIR> sample_networks
11 File(s) 39,921 bytes
3 Dir(s) 25,152,544,768 bytes free
並運行make -f Makefile gives
:
g+++ -o graph_binary.o -c graph_binary.cpp -ansi -05 -Wall
process_begin: CreateProcess(NULL, g++ -o graph_binary.o -c graph_binary.cpp -ansi -05 -Wall, ...) failed.
make (e=2): The system cannot find the file specified.
make: *** [graph_binary.o] Error 2
但這些文件列在目錄中,所以我不知道為什么會有錯誤。
我不知道MATLAB
C ++函數調用。 但是如果你想在Windows環境中用make
編譯使用VC
編譯器就是這里的步驟。
make
:轉到http://gnuwin32.sourceforge.net/packages/make.htm並下載Complete package, except sources
並按照同一頁面的說明進行安裝。 bin
(C:\\ Program Files(x86)\\ GnuWin32 \\ bin;)目錄路徑設置為windows環境變量PATH
make
並按Enter鍵。 如果一切正常則應顯示make: *** No targets specified and no makefile found. Stop.
make: *** No targets specified and no makefile found. Stop.
cd
命令生成文件位置並執行命令make -f yourFileName
注意:您應該已經安裝了VC編譯器。 這可能會讓你發現這一點
您可以使用MinGW (Windows端口的gcc)構建它
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.