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

Posted on 2011-03-10
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?

Question by:ventumsolve
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
LVL 45

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,
LVL 10

Accepted Solution

Martin_J_Parker earned 250 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.


Author Comment

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:
           On systems that support dynamic linking, this prevents linking
           with the shared libraries.  On other systems, this option has no

           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.

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

LVL 45

Assisted Solution

by:Kent Olsen
Kent Olsen earned 125 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.


Assisted Solution

ssnkumar earned 125 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.

Author Closing Comment

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.

Featured Post


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

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…
Examines three attack vectors, specifically, the different types of malware used in malicious attacks, web application attacks, and finally, network based attacks.  Concludes by examining the means of securing and protecting critical systems and inf…
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.
The goal of this video is to provide viewers with basic examples to understand opening and reading files in the C programming language.

630 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