Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

I am using Windows Vista, and have downloaded a folder of files in C++ with a Makefile. I would like to run the makefile to compile the source files with header files under Windows. In the end I would like to be able to call this C++ function from MATLAB's command prompt afterwards, so I assume that if I use cygwin this will not be possible because it only allows the compilation to be run from within cygwin.

I installed the Windows SDK 7.1 and from its commond prompt moved into the directory where the makefile and source lies and nmake -f Makefile and got the response Makefile(13) : fatal error U1001: syntax error : illegal character '^' in macro Stop. I installed visual studio express 2010 and from its command prompt tried the same. Thes functions are widely known and have been used from here - link to page hosting the c++ files. So I doubt that there is an error with the functions themselves.

How can I run the makefile to compile these files and subsequently run them?

EDIT: this is the 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: I installed make from gnu and this is the output: Here is the 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

And running the 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

but these files are listed in the dir so I do not know why there is an error.

share|improve this question
show 2 more comments

2 Answers

up vote 1 down vote accepted

I don't have idea about C++ function call from MATLAB. But if you want to build using make in windows environment with VC compiler here is the steps.

  1. Install make: go to http://gnuwin32.sourceforge.net/packages/make.htm and download Complete package, except sources and install it according to instruction of the same page.
  2. Set the bin(C:\Program Files (x86)\GnuWin32\bin;) directory path to windows environment variable PATH
  3. restart computer them open command prompt and type make and hit enter. if everything ok then it should shows make: *** No targets specified and no makefile found. Stop.
  4. If everything ok go to make file location using cd command and execute command make -f yourFileName

NOTE: you should have VC compiler already installed. this may hep you to find that

share|improve this answer
add comment

You can build it with MinGW (Windows port of gcc)

Mingw builds link

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.
{"cc_re__cc_re__cc_by_sa_3_0": ["        <li><a href=\"http://area51.stackexchange.com\" title=\"proposing new sites in the Stack Exchange network\">Area 51</a></li>\r\n                        <li><a href=\"http://careers.stackoverflow.com\">Stack Overflow Careers</a></li>\r\n                    \r\n                </ol>\r\n            </td>\r\n    </tr>\r\n</table>\r\n                </div>\r\n            </div>\r\n\r\n            <div id=\"copyright\">\r\n                site design / logo &#169; 2014 stack exchange inc; user contributions licensed under <a href=\"http://creativecommons.org/licenses/by-sa/3.0/\" rel=\"license\">cc by-sa 3.0</a> \r\n                with <a href=\"http://blog.stackoverflow.com/2009/06/attribution-required/\" rel=\"license\">attribution required</a>\r\n            </div>\r\n            <div id=\"svnrev\">\r\n                rev 2014.3.7.1431\r\n            </div>\r\n            \r\n        </div>\r\n    </div>\r\n    <noscript>\r\n        <div id=\"noscript-warning\">Stack Overflow works best with JavaScript enabled<img src=\"http://pixel.quantserve.com/pixel/p-c1rF4kxgLUzNc.gif\" alt=\"\" class=\"dno\"></div>\r\n    </nosc"], "copyright__copyright__copyright": ["e file location using cd command and execute command make -f yourFileName\n\nNOTE: you should have VC compiler already installed. this may hep you to find that\n\nshare|improve this answer\nadd comment\n\nYou can build it with MinGW (Windows port of gcc)\n\nMingw builds link\n\nshare|improve this answer\nadd comment\n\nYour Answer\n\n\u00a0\ndiscard\n\nBy posting your answer, you agree to the privacy policy and terms of service.\n\nNot the answer you're looking for? Browse other questions tagged or ask your own question."]}