[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

same version on both linux and solaris

Posted on 2004-10-20
7
Medium Priority
?
681 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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 

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 400 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 1600 total points
ID: 12366259
remove the getopt.o in the source dir. and make again
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

Attention: This article will no longer be maintained. If you have any questions, please feel free to mail me. jgh@FreeBSD.org Please see http://www.freebsd.org/doc/en_US.ISO8859-1/articles/freebsd-update-server/ for the updated article. It is avail…
My previous tech tip, Installing the Solaris OS From the Flash Archive On a Tape (http://www.experts-exchange.com/articles/OS/Unix/Solaris/Installing-the-Solaris-OS-From-the-Flash-Archive-on-a-Tape.html), discussed installing the Solaris Operating S…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use while-loops in the C programming language.
Suggested Courses

649 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