Intel® C++ Compiler
Community support and assistance for creating C++ code that runs on platforms based on Intel® processors.
7956 Discussions

How to port a GNU C++ Makefile to Windows

jerryleo
Beginner
1,236 Views

Hi,

There is aMakefile works fineunder fedora core 3 with gcc 3.4. Ineed to port it to WindowswithIntel C++ compiler for Windows.ButI know little about Makefile and have no idea how to do it. I googled it hard, but find little information about it.

Could anyone give me some instruction how to do it?

Thanks a lot!

Jerry

[cpp]#************Makefile for libsnd3.a*************



CC = gcc

CPP = g++



LOADLIBES =-lm

INCLUDES = -I.

CFLAGS = -Wall -O3

CPPFLAGS = $(CFLAGS)



PROGRAM =

LIBSND = libsnd3.a

SNDLIBS = ptu.o pwv_data.o tm_data.o wind.o timesub.o sonde_data.o



all: $(PROGRAM) $(LIBSND)



$(LIBSND): $(SNDLIBS)

ar r $@ $?





ptu.o: ptu.h

pwv_data.o: pwv_data.h

sonde.o: sonde.h

sonde_data.o: sonde_data.h

tm_data.o: tm_data.h

wind.o: wind.h

timesub.o: timesub.h



#sonde.h: sonde_data.h pwv_data.h tm_data.h

sonde_data.h: ptu.h wind.h timesub.h





clean:

rm -f *.o

rm -f $(LIBSND)

rm -f *.stackdump



bak:

rm -f *.bak



distclean: clean

rm -f $(PROGRAM)

rm -f *.exe

rm -f *~











.c.o:

$(CC) $(CFLAGS) $(INCLUDES) -c $<



.cc.o:

$(CPP) $(CPPFLAGS) $(INCLUDES) -c $< [/cpp]
[cpp][/cpp]
[cpp][/cpp]
[cpp][/cpp]
[cpp][/cpp]
[cpp]
#*************Makefile for EXE program****************



SNDLIBDIR = ./lib



LIBSND = libsnd3.a





CC=gcc

CPP=g++



LIBS = $(LIBSND)

LOADLIBES = -L$(SNDLIBDIR) -lm -lsnd3

INCLUDES = -I$(SNDLIBDIR) -I.



CFLAGS = -Wall -O3 -g

CPPFLAGS = $(CFLAGS)



PROGRAM = snd_wyoming snd_vaisala_aed snd_vaisala_mw31





all: $(LIBS) $(PROGRAM)





$(LIBSND):

(cd $(SNDLIBDIR); make)



snd_wyoming: snd2pwv.o sonde.o io_wyoming.o

$(CPP) $(CPPFLAGS) -o $@ snd2pwv.o sonde.o io_wyoming.o $(LOADLIBES)



snd_vaisala_aed: snd2pwv.o sonde.o io_vaisala_aed.o

$(CPP) $(CPPFLAGS) -o $@ snd2pwv.o sonde.o io_vaisala_aed.o $(LOADLIBES)



snd_vaisala_mw31: snd2pwv.o sonde.o io_vaisala_mw31.o

$(CPP) $(CPPFLAGS) -o $@ snd2pwv.o sonde.o io_vaisala_mw31.o $(LOADLIBES)



sonde.o: sonde.h

io_wyoming.o: sonde.h

io_visala_aed.o: sonde.h







clean:

rm -f *.o

rm -f *~

rm -f *.stackdump



bak:

rm -f *.bak



libclean:

(cd $(SNDLIBDIR); make distclean)



distclean: clean libclean

rm -f $(PROGRAM)

rm -f *.exe

rm -f *~



#include rules.mk





.c.o:

$(CC) $(CFLAGS) $(INCLUDES) -c $<



.cc.o:

$(CPP) $(CPPFLAGS) $(INCLUDES) -c $< [/cpp]
0 Kudos
4 Replies
Alexey-Kukanov
Employee
1,236 Views
Makefiles are "executed" by a make tool, not a compiler. Makefile content is mostly about files, dependencies between files, and rules (commands) to convert files, e.g. to compile an executable binary from a set of source files. Besides compilation, they often describe other actions, and may reference some system-specific utilities (in your case, 'ar' and 'rm'). Also, different make tools have some incompatibilities in syntax (in your case, #include rules.mk might be specific to GNU make).
As this all is eventually about building binaries from sources, if I were you I wouldn't bother with makefiles on Windows (unless there is a serious reason to do that) but instead created VS project files that do the same job.
If you really need to "port" the makefile, GNU make manual (http://www.gnu.org/software/make/manual/make.html) is probably the point to start learning about makefiles. The conversion might start with replacing gcc and g++ with icl (the command to launchIntel Compiler), and replacing all gcc/g++ options with equivalent options for Intel Compiler.
0 Kudos
Ganesh_R_Intel
Employee
1,236 Views

Hi,

That is right.

You can consider using the "nmake" tool to build your makefile on Windows. See http://support.microsoft.com/kb/60340/en-us and http://support.microsoft.com/kb/132084/en-us

You need to make sure that your library dependencies are resolved.

Take care,

Ganesh

0 Kudos
jerryleo
Beginner
1,236 Views
Quoting - Ganesh Rao

Hi,

That is right.

You can consider using the "nmake" tool to build your makefile on Windows. See http://support.microsoft.com/kb/60340/en-us and http://support.microsoft.com/kb/132084/en-us

You need to make sure that your library dependencies are resolved.

Take care,

Ganesh

Thanks for all comments.

I already set the environment variable, while I issued command "icl -I. /c ptu.cc",icl still complained error: identifier "isinf" is undefined.

Is there anything missing?

Thanks.

0 Kudos
JenniferJ
Moderator
1,236 Views
try"icl /TP /c t.cc". "/TP" tells the compiler to treat "t.cc" as a C++ file.

0 Kudos
Reply