Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

how do I create an executable to run on a machine - same platform - but no devel-stuff

Posted on 2011-03-10
6
Medium Priority
?
377 Views
Last Modified: 2012-05-11
I have a small c-program and would like it to run on a similar platform as mine (OS X, 10.6)  but on the customer server there's no xcode installed so I can't compile the program on his computer. Can I compile it on mine where I have all the headers in a way where the headers will be included in the executable out-file? So say references to time.h, string.h etc will work?

thanx
0
Comment
Question by:ventumsolve
[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
6 Comments
 
LVL 46

Expert Comment

by:Kent Olsen
ID: 35094864
Hi ventum,

If you compile and link the program into a self-contained executable, it should run just fine on any computer running the same operating system.

If the program uses shared libraries, dll files, etc., then you might have to do some more work.  But unless you specifically code to these shared libraries you won't be using them.

Just compile the program, run the executable (test it), and copy it to the other computer.


Good Luck,
Kent
0
 
LVL 10

Accepted Solution

by:
Martin_J_Parker earned 750 total points
ID: 35094904
If you can, link the program statically so that it won't use any dynamic libraries.  That way you won't have anything missing at the client end.  A lot of compilers have a -static or -Bstatic option to allow you to do that.

Cheers,
M.
0
 

Author Comment

by:ventumsolve
ID: 35095031
Apparently the static option will not work on mac 10.6. So there's no way around installing xcode I guess?



The man gcc says:
       -static
           On systems that support dynamic linking, this prevents linking
           with the shared libraries.  On other systems, this option has no
           effect.

           This option will not work on Mac OS X unless all libraries
           (including libgcc.a) have also been compiled with -static.
           Since neither a static version of libSystem.dylib nor crt0.o are
           provided, this option is not useful to most people.



0
Independent Software Vendors: 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 46

Assisted Solution

by:Kent Olsen
Kent Olsen earned 375 total points
ID: 35095065
Hi ventum,

That basically means that you're going to have to just test it.

My expectation is that the shared libraries will be on each system to that the program should run fine.  You won't even know that the shared libraries are involved.


Kent
0
 
LVL 8

Assisted Solution

by:ssnkumar
ssnkumar earned 375 total points
ID: 35104959
ventumsolve> So say references to time.h, string.h etc will work?
Yes. You will be including these files using #include directive.
This is just like a preprocessor directive and hence all the contents of time.h, string.h, etc will be added to your .c file itself before compilation.
So, you don't need to have time.h, string.h, etc on the computer where you will be executing this code.

But, if you are specifying any libraries during compilation (compiler will make use of some standard libraries and they should be there in the target computer also by default), you will have to make sure that they are present in the target computer also.

If you are not specifying any libraries during compilation, then no need to worry.
Your code should run without any problem on the destination computer also.
0
 

Author Closing Comment

by:ventumsolve
ID: 35133202
Meanwhile .. customer installed xcode so the problem sort of disapeared. However .. I never got a working executable. Perhabs because target server was 10.5 whereas source was 10.6. Was playing with CFLAGS= -mmacosx-version-min=10.5 when customers notification about xcode saved my day.
0

Featured Post

Independent Software Vendors: 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

Have you thought about creating an iPhone application (app), but didn't even know where to get started? Here's how: ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ Important pre-programming comments: I’ve never tri…
This is a short and sweet, but (hopefully) to the point article. There seems to be some fundamental misunderstanding about the function prototype for the "main" function in C and C++, more specifically what type this function should return. I see so…
The goal of this video is to provide viewers with basic examples to understand and use pointers in the C programming language.
The goal of this video is to provide viewers with basic examples to understand how to use strings and some functions related to them in the C programming language.

721 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