?
Solved

gnu g++ compiler question

Posted on 2002-03-29
9
Medium Priority
?
262 Views
Last Modified: 2010-04-02
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
Comment
Question by:bhuey_ling
[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
9 Comments
 
LVL 1

Expert Comment

by:bluprint
ID: 6906414
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
 

Author Comment

by:bhuey_ling
ID: 6906466
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
 
LVL 30

Expert Comment

by:Axter
ID: 6906539
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
Technology Partners: 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!

 
LVL 30

Expert Comment

by:Axter
ID: 6906540
Please delete your duplicate question:
http://www.experts-exchange.com/cplusprog/Q.20283129.html
0
 
LVL 2

Accepted Solution

by:
frechter earned 400 total points
ID: 6908449
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
 
LVL 2

Expert Comment

by:frechter
ID: 6908453
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
 
LVL 2

Expert Comment

by:frechter
ID: 6908457
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
 
LVL 11

Expert Comment

by:griessh
ID: 6956313
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
 
LVL 6

Expert Comment

by:Mindphaser
ID: 6979176
Force accepted

** Mindphaser - Community Support Moderator **
0

Featured Post

Technology Partners: 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!

Question has a verified solution.

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

Article by: SunnyDark
This article's goal is to present you with an easy to use XML wrapper for C++ and also present some interesting techniques that you might use with MS C++. The reason I built this class is to ease the pain of using XML files with C++, since there is…
  Included as part of the C++ Standard Template Library (STL) is a collection of generic containers. Each of these containers serves a different purpose and has different pros and cons. It is often difficult to decide which container to use and …
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
Suggested Courses

743 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