Solved

same version on both linux and solaris

Posted on 2004-10-20
7
669 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
  • 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
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 

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

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

This tutorial is posted by Aaron Wojnowski, administrator at SDKExpert.net.  To view more iPhone tutorials, visit www.sdkexpert.net. This is a very simple tutorial on finding the user's current location easily. In this tutorial, you will learn ho…
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…
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
In a previous video, we went over how to export a DynamoDB table into Amazon S3.  In this video, we show how to load the export from S3 into a DynamoDB table.

762 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now