Solved

same version on both linux and solaris

Posted on 2004-10-20
7
676 Views
Last Modified: 2013-12-05
hey Van_dy
i bet u r a smart like God. This is working smothly on my solaris as never before. But my main goal is to be able to run the same version of code both linux box and solaris. When i try that on linuxbox it is giving the following error:

==================ERROR MESSAGE ==============================
[komlaaa@linuxbox a4_1]$ make
g++ -g -Wall -ansi -c wc.cpp
g++ -g -Wall -ansi -c main.cpp
g++ main.o wc.o getopt.o -o cs450words
/usr/bin/ld: getopt.o: Relocations in generic ELF (EM: 2)
getopt.o: could not read symbols: File in wrong format
collect2: ld returned 1 exit status
make: *** [cs450words] Error 1
[komlaaa@linuxbox a4_1]$


Any idea?

thanks though
0
Comment
Question by:komlaaa
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
  • 2
7 Comments
 
LVL 5

Expert Comment

by:van_dy
ID: 12363657
haha,

>>i bet u r a smart like God
     no nothing like that. But i dont see the compilation 'cc -c getopt.c' in above wat you posted.
are you using the same Makefile that i posted? please use that. here is a session
on my linux machine:

[van_dy@victoria a4_1]$ ls
BUG_LOG  file  file1  getop.c  main.cpp  Makefile  MANPAGE  README  test.cc  TIME_LOG  wc.cpp  wc.h
[van_dy@victoria a4_1]$ uname -rs
Linux 2.4.21
[van_dy@victoria a4_1]$ make
g++ -g -Wall -ansi -c wc.cpp
g++ -g -Wall -ansi -c main.cpp
cc -c getop.c            <------------------------------- this is  what is missing in what you posted
g++ main.o wc.o getop.o -o cs450words
[van_dy@victoria a4_1]$ ./cs450words -t file
Reading from file...

TOTAL: 6
[van_dy@victoria a4_1]$ ./cs450words -tl file
Reading from file...

TOTAL: 6
World 1
hello 2
helloo 1
worlds 1
worlds1 1
[van_dy@victoria a4_1]$

-----------------
Apparently the getopt.o being used for building your final cs405words is the one compiled on your solaris
machine probably :).


Hope this helps,
van_dy
0
 

Author Comment

by:komlaaa
ID: 12364973
I am surprised it is running on your linux box, i bet u i am using the Make file u gave me but still. Check the following out.

======================= SAMPLE RUN =====================================
[komlaaa@bgpdata a4]$ ls
bible.txt  file      getopt.o   main.cpp   main.o    MANPAGE  TIME_LOG  wc.h
BUG_LOG    getopt.c  main1.cpp  main.cppn  Makefile  README   wc.cpp    wc.o
[komlaaa@bgpdata a4]$ uname -rs
Linux 2.6.5-1.358
[komlaaa@bgpdata a4]$ cat Makefile

all: cs450words

cs450words:  wc.o main.o getopt.o
        g++ main.o wc.o getopt.o -o cs450words

wc.o: wc.cpp wc.h
        g++ -g -Wall -ansi -c wc.cpp

main.o: main.cpp
        g++ -g -Wall -ansi -c main.cpp

getop.o: getopt.c
        cc -c getopt.c

clean:
        /bin/rm -f cs450words main.o wc.o *~

[komlaaa@bgpdata a4]$ make
g++ main.o wc.o getopt.o -o cs450words
/usr/bin/ld: getopt.o: Relocations in generic ELF (EM: 2)
getopt.o: could not read symbols: File in wrong format
collect2: ld returned 1 exit status
make: *** [cs450words] Error 1
[komlaaa@bgpdata a4]$
0
 
LVL 11

Expert Comment

by:avizit
ID: 12366083
prolly you need to do a

make clean
make


you probably copied the getopt.o from your solaris
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:komlaaa
ID: 12366206
I don't think thats the problem.

======== SAMPLE RUN ============

[komlaaa@bgpdata a4]$ make clean
/bin/rm -f cs450words main.o wc.o *~
[komlaaa@bgpdata a4]$ ls
bible.txt  file      getopt.o   main.cpp   Makefile  README    wc.cpp
BUG_LOG    getopt.c  main1.cpp  main.cppn  MANPAGE   TIME_LOG  wc.h
[komlaaa@bgpdata a4]$ make
g++ -g -Wall -ansi -c wc.cpp
g++ -g -Wall -ansi -c main.cpp
g++ main.o wc.o ./getopt.o -o cs450words
/usr/bin/ld: ./getopt.o: Relocations in generic ELF (EM: 2)
./getopt.o: could not read symbols: File in wrong format
collect2: ld returned 1 exit status
make: *** [cs450words] Error 1
[komlaaa@bgpdata a4]$
0
 

Author Comment

by:komlaaa
ID: 12366221
i know i need to force my Makefile to use my getopt.o and not the one in my system, but i don't know how?

Thanks,

komlaaa.
0
 
LVL 11

Assisted Solution

by:avizit
avizit earned 100 total points
ID: 12366228
hmm your make clean dosnt delete the getopt.o file


so change the Makefile so that make clean now has

clean:
        /bin/rm -f cs450words main.o wc.o *~  getopt.o

or better still have it as

clean:
        /bin/rm -f *.o  cs450words *~


or you can manually delete getopt.o

what I think yuo have done is you have copied the whole directory from solaris to linux and  hence the getopt.o from solaris has stayed and hence make dint feel any need to make ( compile ) it again

so either change the makefile and then type make clean   or you can delete the getopt.o file manually

0
 
LVL 5

Accepted Solution

by:
van_dy earned 400 total points
ID: 12366259
remove the getopt.o in the source dir. and make again
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
How to build c program using make in mingw environment? 9 90
How to Insert a File Using Text Editor 9 111
remove one line from a file in solaris 8 66
Shell Script- gzip 5 85
Summary: This tutorial covers some basics of pointer, pointer arithmetic and function pointer. What is a pointer: A pointer is a variable which holds an address. This address might be address of another variable/address of devices/address of fu…
Why Shell Scripting? Shell scripting is a powerful method of accessing UNIX systems and it is very flexible. Shell scripts are required when we want to execute a sequence of commands in Unix flavored operating systems. “Shell” is the command line i…
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
The goal of this video is to provide viewers with basic examples to understand and use pointers in the C programming language.

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question