Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

gnu g++ compiler question

Posted on 2002-03-29
9
Medium Priority
?
263 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
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

Industry Leaders: 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

When writing generic code, using template meta-programming techniques, it is sometimes useful to know if a type is convertible to another type. A good example of when this might be is if you are writing diagnostic instrumentation for code to generat…
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…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.
Suggested Courses

636 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