Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 380
  • Last Modified:

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

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
ventumsolve
Asked:
ventumsolve
3 Solutions
 
Kent OlsenData Warehouse Architect / DBACommented:
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
 
Martin_J_ParkerCommented:
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
 
ventumsolveAuthor Commented:
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
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.

 
Kent OlsenData Warehouse Architect / DBACommented:
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
 
ssnkumarCommented:
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
 
ventumsolveAuthor Commented:
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

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.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now