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

Makefile on Linux - how to do it in the right way?

atatart
Beginner
630 Views
Hello ,
I have installed Intel C++ compiler on Scientific Linux 5.3, it work fine, just compiling a few files together in one executable needs to be done in the way like this
[cpp]icpc pilotZp.cc zp.cc -o zpx[/cpp]



if I am uisng the standard Makefile like this

[cpp]CC= icc

CIBLE= zpx
SOURCE= pilotZP.cc zp.cc

$(CIBLE): $(SOURCE)
$(CC) $(SOURCE) -o $(CIBLE)

zp.o: zp.cc zp.h
pilotZP.o: pilotZP.cc zp.h

clean:

rm -f $(OBJ) $(CIBLE) *.o[/cpp]


I am getting the segmentation fault, I have installed also Eclipse Ganimede and I have integrated intel C++ compiler in it, everything works fine, but again the multiple files projecst with automaticaly generated Makefiles do not go, the same code compiles and executes great in Microsoft Visual Stusio 2008, provided I have developed it on linux, usin Intel C++ compiler, I would like to understand how to use efficiently the Makefiles on Gnu Linux systems with your compiler, it works OK when using gcc but you know that gcc do not deal with C++ as good as Intel's compiler.
Is there is something I should change in the configuration?

Regards, Andrei
0 Kudos
1 Solution
TimP
Honored Contributor III
630 Views
I would guess that by attempting to link a C++ application by using a C compiler without specifying -lstc++, you get errors associated with the missing library specification. It would be similar whther using gcc where you meant g++, or icc where you meant icpc. It's possible the .o file may be made OK, if the C compiler automatically shifts into C++ on account of the .cc suffix, but there is no information passed in the link stage to invoke a shift into C++ mode.
The usual practice is to use CXX to refer to the C++ compiler. You can't call what you have done a "standard" way of using C++. In your sample, if you would change CC to CXX and icc to icpc, it ought to work.

View solution in original post

0 Kudos
3 Replies
aazue
New Contributor I
630 Views
Quoting - atatart
Hello ,
I have installed Intel C++ compiler on Scientific Linux 5.3, it work fine, just compiling a few files together in one executable needs to be done in the way like this
[cpp]icpc pilotZp.cc zp.cc -o zpx[/cpp]



if I am uisng the standard Makefile like this

[cpp]CC= icc

CIBLE= zpx
SOURCE= pilotZP.cc zp.cc

$(CIBLE): $(SOURCE)
$(CC) $(SOURCE) -o $(CIBLE)

zp.o: zp.cc zp.h
pilotZP.o: pilotZP.cc zp.h

clean:

rm -f $(OBJ) $(CIBLE) *.o[/cpp]


I am getting the segmentation fault, I have installed also Eclipse Ganimede and I have integrated intel C++ compiler in it, everything works fine, but again the multiple files projecst with automaticaly generated Makefiles do not go, the same code compiles and executes great in Microsoft Visual Stusio 2008, provided I have developed it on linux, usin Intel C++ compiler, I would like to understand how to use efficiently the Makefiles on Gnu Linux systems with your compiler, it works OK when using gcc but you know that gcc do not deal with C++ as good as Intel's compiler.
Is there is something I should change in the configuration?

Regards, Andrei
Hi
add
libdir = (your way lib icc)
includedir = (your way include icc)
Curious not observed problem with Makefile and icc with standart program ??

Best regard


0 Kudos
TimP
Honored Contributor III
631 Views
I would guess that by attempting to link a C++ application by using a C compiler without specifying -lstc++, you get errors associated with the missing library specification. It would be similar whther using gcc where you meant g++, or icc where you meant icpc. It's possible the .o file may be made OK, if the C compiler automatically shifts into C++ on account of the .cc suffix, but there is no information passed in the link stage to invoke a shift into C++ mode.
The usual practice is to use CXX to refer to the C++ compiler. You can't call what you have done a "standard" way of using C++. In your sample, if you would change CC to CXX and icc to icpc, it ought to work.
0 Kudos
atatart
Beginner
630 Views
Quoting - tim18
I would guess that by attempting to link a C++ application by using a C compiler without specifying -lstc++, you get errors associated with the missing library specification. It would be similar whther using gcc where you meant g++, or icc where you meant icpc. It's possible the .o file may be made OK, if the C compiler automatically shifts into C++ on account of the .cc suffix, but there is no information passed in the link stage to invoke a shift into C++ mode.
The usual practice is to use CXX to refer to the C++ compiler. You can't call what you have done a "standard" way of using C++. In your sample, if you would change CC to CXX and icc to icpc, it ought to work.

Hi,
thank you for your replies; I will work on it, calling this Makefile a standard one I was thinking on C language and gcc, Ive just installed Intel C++ compiler and this is the first application I am developing using it.
Best Regards, atatart
0 Kudos
Reply