• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 264
  • Last Modified:

gnu g++ compiler question

Hi ,

I hv compiler my program with gnu g++ 2.95.2. Then, I hv transfer my binary to a site that only hv g++ 2.7. Is this possible for me to run my program at that site? or I need to install g++ 2.95.2 in that site too.

I hv tried run my program and it failed coz cannot found one of a g++ 2.95.2 library.

I'm not sure this is my environment setting problem or i need to install the g++ 2.95.2.

thanks,
huey ling
0
bhuey_ling
Asked:
bhuey_ling
1 Solution
 
bluprintCommented:
Did you recompile on the new box, or did you just copy the binary over? If you didn't recompile on the other box, recompile over there and then try to run it.
0
 
bhuey_lingAuthor Commented:
hi,

My program only can use g++ 2.95.2 and above compiler. But the site only have g++ 2.7 compiler.

I should work if i transfer the compiled binary to other site even the site din't hv g++ 2.95.2, is it?

thanks
0
 
AxterCommented:
Does the other site have the same OS?
What OS is the Target site, and what is the version of the OS?
You need to make sure that both the OS and the version match.  If they match, you should be able to run your binaray on the target machine.
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.

 
AxterCommented:
Please delete your duplicate question:
http://www.experts-exchange.com/cplusprog/Q.20283129.html
0
 
frechterCommented:
You can link your program with libstdc++ in static linkage
this way you will have no problem porting from version to version of g++.
You must however make sure it is running on the same OS
(like Axter mentioned above)
In order to link your program in static linkage add
 
        -lstdc++

to your makefile linking line for example

 g++ -o Test -lstdc++ X.o Y.o z.cpp

if you are using more libraries you should compile them static too.

I hope this works
 Yiftah
0
 
frechterCommented:
sorry ... I forgot -static

use -static  -lstdc++ in your make file line
 for example :
   g++ -o Test -static -lstdc++ X.o Y.o z.cpp
0
 
frechterCommented:
Again me ... :)

You can also try

     -static-libgcc  
for example :
   g++ -o Test -static-libgcc X.o Y.o z.cpp


for more information  you can look in gcc man pages

cheer Yiftah
0
 
griesshCommented:
Dear for bhuey_ling

I think you forgot this question. I will ask Community Support to close it unless you finalize it within 7 days. You can always request to keep this question open. But remember, experts can only help you if you provide feedback to their questions.
Unless there is objection or further activity,  I will suggest to accept

     "frechter"

comment(s) as an answer.

If you think your question was not answered at all, you can post a request in Community support (please include this link) to refund your points. The link to the Community Support area is: http://www.experts-exchange.com/commspt/

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!
======
Werner
0
 
MindphaserCommented:
Force accepted

** Mindphaser - Community Support Moderator **
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

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