Solved

gnu g++ compiler question

Posted on 2002-03-29
9
253 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
 
LVL 30

Expert Comment

by:Axter
Comment Utility
Please delete your duplicate question:
http://www.experts-exchange.com/cplusprog/Q.20283129.html
0
Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

 
LVL 2

Accepted Solution

by:
frechter earned 100 total points
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
Force accepted

** Mindphaser - Community Support Moderator **
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Written by John Humphreys C++ Threading and the POSIX Library This article will cover the basic information that you need to know in order to make use of the POSIX threading library available for C and C++ on UNIX and most Linux systems.   [s…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
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 user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.

762 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now