LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 11-13-2012, 02:06 PM   #1
rpegram
LQ Newbie
 
Registered: Nov 2012
Posts: 4

Rep: Reputation: Disabled
Unhappy Compiling C++ code on Red Hat Linux


I am new to doing command line C++ compiling and linking in Linux. I have been a Developer Studio programmer for years in the Windows environment, so I am spoiled. We are porting a group of C++ programs from Solaris 10 to Red Hat version 5 and I am having trouble getting the include and library paths correct in the make file. Getting a "make Error 127" - Command not found when I run the make file. The makefile is shown below.

***************************************************************************
***************************************************************************

####################################################################
APP_HOME=/home/payroll/c
EXE_HOME=${APP_HOME}/exe
GOBJ=$(EXE_HOME)
GEXE=$(EXE_HOME)

#CC=gcc
CC=g++


# Options to be passed to your C++ compiler:
CCOPTIONS= -O

# Where the library is located:
LIBDIR=-I/usr/lib/


# STL header include path

STLINCL=-I/usr/include/

# USER's header include path

USERINCL=-I/home/payroll/c/include/

# Full path to the library:
LIBFULL= $(LIBDIR)

# Link directives for the library:
LIBLINK=


# Compile flags:

CPPFLAGS= $(STLINCL) $(USERINCL) $(CCOPTIONS) -library=iostream




######################## Executables #######################

# STL based examples:
STL= mmapptr dequeval

# Template example programs:
TEMPLATE= tvdlist tpdlist

# Internationalization example programs:
I18N= i18n

########################## Targets ########################
CONVERTCIPS_OBJ=cipsfile.o convertengine.o convertcipsapp.o convertcipsmain.o

all: convertcips
convertcips: $(EXE_HOME)/convertcips

# clean: $(RM) *.o
########################## Conversions ########################

.SUFFIXES: .cpp .C .cc .cxx .o


##################################################
# general case for compilation
%.o: %.cpp
$(CCC) $(CPPFLAGS) -c -o $@ $<

$(EXE_HOME)/convertcips: $(CONVERTCIPS_OBJ)
$(CC) $(CPPFLAGS) -o $(EXE_HOME)/convertcips $(CONVERTCIPS_OBJ) $(LIBFULL)
rm *.o

Any help is greatly appreciated.
 
Old 11-13-2012, 02:23 PM   #2
smallpond
Senior Member
 
Registered: Feb 2011
Location: Massachusetts, USA
Distribution: Fedora
Posts: 4,153

Rep: Reputation: 1265Reputation: 1265Reputation: 1265Reputation: 1265Reputation: 1265Reputation: 1265Reputation: 1265Reputation: 1265Reputation: 1265
ALways paste the whole error, even if you don't know what it all means. It should be telling you what line in your Makefile has a problem.
Here's what I see:

There is an extra space after '=' on several lines. Remove them. Makefiles are not free-form.

There are no instructions in the rule to make convertcips.

I don't see where CCC is defined.
 
Old 11-13-2012, 02:41 PM   #3
rpegram
LQ Newbie
 
Registered: Nov 2012
Posts: 4

Original Poster
Rep: Reputation: Disabled
Here is the error. I found the error with CCC, I left off a c in the makefile definition.
**********************************************************************************************

[rpegram@finn c]$ make -f makelinux.mk
I/usr/include/ SERINCL -O -library=iostream -c -o cipsfile.o cipsfile.cpp
make: I/usr/include/: Command not found
make: [cipsfile.o] Error 127 (ignored)
I/usr/include/ SERINCL -O -library=iostream -c -o convertengine.o convertengine.cpp
make: I/usr/include/: Command not found
make: [convertengine.o] Error 127 (ignored)
I/usr/include/ SERINCL -O -library=iostream -c -o convertcipsapp.o convertcipsapp.cpp
make: I/usr/include/: Command not found
make: [convertcipsapp.o] Error 127 (ignored)
I/usr/include/ SERINCL -O -library=iostream -c -o convertcipsmain.o convertcipsmain.cpp
make: I/usr/include/: Command not found
make: [convertcipsmain.o] Error 127 (ignored)
g++ -I/usr/include/ SERINCL -O -library=iostream -o /home/payroll/c/exe/convertcips cipsfile.o convertengine.o convertcipsapp.o convertcipsmain.o -I/usr/lib/
g++: SERINCL: No such file or directory
g++: cipsfile.o: No such file or directory
g++: convertengine.o: No such file or directory
g++: convertcipsapp.o: No such file or directory
g++: convertcipsmain.o: No such file or directory
make: *** [/home/payroll/c/exe/convertcips] Error 1
 
Old 11-13-2012, 02:50 PM   #4
rpegram
LQ Newbie
 
Registered: Nov 2012
Posts: 4

Original Poster
Rep: Reputation: Disabled
Made some progress, objects are being created now. Now need to work on linking objects. Here is the make file again.
**********************************************
APP_HOME=/home/payroll/c
EXE_HOME=${APP_HOME}/exe
GOBJ=$(EXE_HOME)
GEXE=$(EXE_HOME)

#CCC=gcc
CCC=g++


# Options to be passed to your C++ compiler:
CCOPTIONS= -O

# Where the library is located:
LIBDIR=-I/usr/lib/


# STL header include path

STLINCL=-I/usr/include/

# USER's header include path

USERINCL=-I/home/payroll/c/include/

# Full path to the library:
LIBFULL= $(LIBDIR)

# Link directives for the library:
LIBLINK=


# Compile flags:

CPPFLAGS= $(STLINCL) $(USERINCL) $(CCOPTIONS) -library=iostream




######################## Executables #######################

# STL based examples:
STL= mmapptr dequeval

# Template example programs:
TEMPLATE= tvdlist tpdlist

# Internationalization example programs:
I18N= i18n

########################## Targets ########################
CONVERTCIPS_OBJ=cipsfile.o convertengine.o convertcipsapp.o convertcipsmain.o

all: convertcips
convertcips: $(EXE_HOME)/convertcips

# clean: $(RM) *.o
########################## Conversions ########################

.SUFFIXES: .cpp .C .cc .cxx .o


##################################################
# general case for compilation
%.o: %.cpp
$(CCC) $(CPPFLAGS) -c -o $@ $<

$(EXE_HOME)/convertcips: $(CONVERTCIPS_OBJ)
$(CCC) $(CPPFLAGS) -o $(EXE_HOME)/convertcips $(CONVERTCIPS_OBJ) $(LIBFULL)
rm *.o
**********************************************

Output results from current makefile
**********************************************************
make -f makelinux.mk
g++ -I/usr/include/ -I/home/payroll/c/include/ -O -library=iostream -c -o cipsfile.o cipsfile.cpp
cipsfile.cpp: In member function âint CipsFile::GetNextLine(unsigned char*, int)â:
cipsfile.cpp:327: warning: NULL used in arithmetic
g++: -library=iostream: linker input file unused because linking not done
g++ -I/usr/include/ -I/home/payroll/c/include/ -O -library=iostream -c -o convertengine.o convertengine.cpp
g++: -library=iostream: linker input file unused because linking not done
g++ -I/usr/include/ -I/home/payroll/c/include/ -O -library=iostream -c -o convertcipsapp.o convertcipsapp.cpp
g++: -library=iostream: linker input file unused because linking not done
g++ -I/usr/include/ -I/home/payroll/c/include/ -O -library=iostream -c -o convertcipsmain.o convertcipsmain.cpp
g++: -library=iostream: linker input file unused because linking not done
g++ -I/usr/include/ -I/home/payroll/c/include/ -O -library=iostream -o /home/payroll/c/exe/convertcips cipsfile.o convertengine.o convertcipsapp.o convertcipsmain.o -I/usr/lib/
/usr/bin/ld: cannot find -library=iostream
collect2: ld returned 1 exit status
make: *** [/home/payroll/c/exe/convertcips] Error 1
 
Old 11-13-2012, 03:15 PM   #5
John VV
LQ Muse
 
Registered: Aug 2005
Location: A2 area Mi.
Posts: 17,627

Rep: Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651
did you install the development tools ? ( looks like it ? BUT ???? you might be missing things ?
and did you install from source / or the *-devel.rpm's for ALL prerequisites

most are not installed by default in RHEL
having them on a server is a security risk
( a "bad guy" could then build the spy software on the server)

please USE code tags
Code:
make -f makelinux.mk
I/usr/include/ SERINCL -O -library=iostream -c -o cipsfile.o cipsfile.cpp
make: I/usr/include/: Command not found
make: [cipsfile.o] Error 127 (ignored)
I/usr/include/ SERINCL -O -library=iostream -c -o convertengine.o convertengine.cpp
make: I/usr/include/: Command not found
make: [convertengine.o] Error 127 (ignored)
I/usr/include/ SERINCL -O -library=iostream -c -o convertcipsapp.o convertcipsapp.cpp
make: I/usr/include/: Command not found
make: [convertcipsapp.o] Error 127 (ignored)
I/usr/include/ SERINCL -O -library=iostream -c -o convertcipsmain.o convertcipsmain.cpp
make: I/usr/include/: Command not found
make: [convertcipsmain.o] Error 127 (ignored)
g++ -I/usr/include/ SERINCL -O -library=iostream -o /home/payroll/c/exe/convertcips cipsfile.o convertengine.o convertcipsapp.o convertcipsmain.o -I/usr/lib/
g++: SERINCL: No such file or directory
g++: cipsfile.o: No such file or directory
g++: convertengine.o: No such file or directory
g++: convertcipsapp.o: No such file or directory
g++: convertcipsmain.o: No such file or directory
manually making make files are a pain sometimes
Autotools are a bit better , but for a small program ?? maybe not

Quote:
-library=iostream
?
where is that coming from ?
it is causing one of the errors
 
Old 11-13-2012, 03:21 PM   #6
rpegram
LQ Newbie
 
Registered: Nov 2012
Posts: 4

Original Poster
Rep: Reputation: Disabled
No I did not install from development tools. I have no reference documentation for compiles as this is a new process here and the other developers have not experience with the platform. I am basically shooting in the dark trying to create a basic makefile that works and can be put into a Source Code Control system so the next person after me does not have to feel the pain like I do if changes have and will be made in the future.
 
Old 11-13-2012, 03:33 PM   #7
johnsfine
LQ Guru
 
Registered: Dec 2007
Distribution: Centos
Posts: 5,286

Rep: Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197
Are you trying to build a 32-bit executable or a 64-bit? If you have a 32-bit RHEL, you must be building 32-bit and you can ignore this concern. But if you have 64-bit RHEL, I'm not sure whether the g++ default is 32-bit or 64-bit.

/usr/lib/ is 32-bit even on 64-bit RHEL, so if the g++ default is 64-bit, your choice of usr/lib instead of /usr/lib64 might be an issue (EDIT: after you fix other syntax problems that I didn't initially notice that make your choice of lib vs. lib64 not yet relevant).

I always prefer to have one of -m32 or -m64 in my CPPFLAGS, so there is no ambiguity about what I am trying to build.

Last edited by johnsfine; 11-13-2012 at 03:38 PM.
 
Old 11-13-2012, 04:15 PM   #8
John VV
LQ Muse
 
Registered: Aug 2005
Location: A2 area Mi.
Posts: 17,627

Rep: Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651
so you are moving over to RHEL
is there a reason to use the now, starting to age ,older RHEL5.9
( it is rhel5.9 ? and not 5.1 ?)
and not the current RHEL6.3

The 5 series is supported but it is also starting to show sings of it's old age

With RHEL requiring a support contract your company is paying for the license and the support that comes with it

you can start with the Red hat knowledge base
( loging in to red hat will be required)
https://access.redhat.com/search/quick?
and there is the open to EVERYONE documentation
https://access.redhat.com/knowledge/...erprise_Linux/
the docs for the older 5 are near the bottom

Other references
http://www.tldp.org/
and look on Amazon for the older "red hat enterprise linux 5 "bible" "

Last edited by John VV; 11-13-2012 at 04:16 PM.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
accessing source code of Red hat linux rmmurugan Linux - General 2 05-22-2006 08:42 AM
the code name of red hat tukang_minta Linux - Newbie 2 08-15-2003 05:24 PM
compiling c++ on red hat linux 9 eschneid Linux - Software 5 05-11-2003 11:45 AM
March 31 with the release of Red Hat Linux 9, code-named Shrike. futurist Linux - Distributions 1 03-26-2003 02:11 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 03:14 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration