Solved

gnu g++ compiler question

Posted on 2002-03-29
9
256 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
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
Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

 
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 100 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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
C++ get user from AD  (VS6) 7 75
ASP.net build a IF/Then Walkthrough Guide 1 213
Compile GLUT with Visual Studio 2015 1 148
Problem with SqlConnection 4 170
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…
IntroductionThis article is the second in a three part article series on the Visual Studio 2008 Debugger.  It provides tips in setting and using breakpoints. If not familiar with this debugger, you can find a basic introduction in the EE article loc…
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.
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

809 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