Solved

same version on both linux and solaris

Posted on 2004-10-20
7
673 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
Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

 

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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Using libpcap/Jpcap to capture and send packets on Solaris version (10/11) Library used: 1.      Libpcap (http://www.tcpdump.org) Version 1.2 2.      Jpcap(http://netresearch.ics.uci.edu/kfujii/Jpcap/doc/index.html) Version 0.6 Prerequisite: 1.      GCC …
Java performance on Solaris - Managing CPUs There are various resource controls in operating system which directly/indirectly influence the performance of application. one of the most important resource controls is "CPU".   In a multithreaded…
The goal of this video is to provide viewers with basic examples to understand and use pointers in the C programming language.
The goal of this video is to provide viewers with basic examples to understand and use structures in the C programming language.

840 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