[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 683
  • Last Modified:

same version on both linux and solaris

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
komlaaa
Asked:
komlaaa
  • 3
  • 2
  • 2
2 Solutions
 
van_dyCommented:
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
 
komlaaaAuthor Commented:
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
 
avizitCommented:
prolly you need to do a

make clean
make


you probably copied the getopt.o from your solaris
0
Independent Software Vendors: 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!

 
komlaaaAuthor Commented:
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
 
komlaaaAuthor Commented:
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
 
avizitCommented:
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
 
van_dyCommented:
remove the getopt.o in the source dir. and make again
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

  • 3
  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now