Code Newbie
News     Forums     Search     Members     Sign Up    

My Code Newbie
Username

Password

Articles/Snippets
ASP Classic
ASP.NET
C
C#
C++
HTML / CSS
Java
Javascript
Linux / BSD
Perl
PHP
Python
Ruby
SQL
VB 6
VB.NET

C.N. Friends
  Planet Rome

Link to Us!
Code Newbie
  Code Newbie
    forums
Go Back   Code Forums > Systems > Linux / BSD / OS X
User Name
Password

Reply
 
LinkBack Thread Tools Display Modes
Old 02-22-2005, 08:06 PM   #1 (permalink)
rajabb
Registered User
 
Join Date: Feb 2005
Posts: 1
rajabb is on a distinguished road
Binary generated by gcc on BSDI are portable or not ?

Hi,

I want to know that if i compile a c++ code using g++ on one BSDi box and put it on any other BSDi box which is not having gcc , will it work ?

Also when i tried with a binary generated on FreeBSD (as o/p of g++ only) and when i execute, it give me following error -
$./a.out
bash: ./a.out: No such file or directory

and when i run ldd for it -
$ ldd ./a.out
ldd: can't execute ./a.out (No such file or directory)

but when i run nm -
$ nm ./a.out
00000000 f Test.cpp
0804969c A _DYNAMIC
08049754 A _GLOBAL_OFFSET_TABLE_
.
.
blah blah

can any one help me out that what can be reason for it

thanks,
Raja
__________________
rajabb is offline   Reply With Quote
Old 02-22-2005, 11:12 PM   #2 (permalink)
redhead
Newbie
 
redhead's Avatar
 
Join Date: Jun 2002
Location: Denmark
Posts: 1,680
redhead is on a distinguished road
The reason the a.out isn't working is because it's linked to some sort of library, which is present at compile time but not at run time, you'r nm command will tell you what a.out is trying to get in contact with during it's run.
The way you'd make anything usable on any BSDi box, is to ensure the libraries it needs will be present on the target box, thus using dependensies.
__________________
Don't worry Ma'am, We're university students, We know what We're doing.
-----
If you pull the pin, Mr.Grenade would no longer be your friend.
-----
01000111 01101111 00100000 01000011 00100000 00100001
redhead is offline   Reply With Quote
Old 02-23-2005, 07:15 AM   #3 (permalink)
teknomage1
Jack of all trades
 
teknomage1's Avatar
 
Join Date: Feb 2005
Location: Los Angeles
Posts: 595
teknomage1 is on a distinguished road
Send a message via AIM to teknomage1
Or compile the program statically, I think the gcc flag for that is --static. That way the binary will be self cintained and have no external dependencies.
__________________
teknomage1 is offline   Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -8. The time now is 07:33 PM.


Powered by vBulletin Version 3.6.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.0.0 RC8





Copyright © 2000-2006, Milano Interactive
Web Hosting provided by Portal 360 Web Hosting
Open Circle