2

i have generated .exe file from C file (ie filename.c ) after compiling in linux machine with -O option. I wish to know about how to run that .exe file when linux system starts up ?

4
  • Which Linux distro are you using?
    – Aman Jain
    Apr 6, 2010 at 6:12
  • 2
    What do you mean .exe file? Did you compile this for Windows? Can you compile it for Linux? Apr 6, 2010 at 6:13
  • Which Linux distro are you using? Please elaborate what all things you tried, what did not work, etc.? You will get better answers and in less time :)
    – Aman Jain
    Apr 6, 2010 at 6:18
  • exe file and linux in one sentence still is somehow a wtf-moment :D
    – knittl
    Apr 7, 2010 at 12:25

3 Answers 3

4

Compile filename.c under linux and just add the command to /etc/rc.d/rc.local. This would get executed when computer boots. Another way would be to create a script for it in /etc/rc.d/init.d/ and then make links to it in the relevant run levels /etc/rc.d/rc3.d/, /etc/rc.d/rc5.d/

1
  • I'd suggest rc.local for the initial try - its simpler especially in light of new dependency based init.d systems, such as upstart.
    – Yann Ramin
    Apr 6, 2010 at 6:19
1

To run exe files on Linux you need Wine.

So first you have to start wine, and then your exe. I guess you have to put these into /etc/rc.d/(Choose appropriate run level)

2
  • Yes, i tried this, but didnt work.
    – sagar
    Apr 6, 2010 at 6:14
  • 1
    If you have access to the source code (i.e. filename.c), you should rebuild the program on Linux rather then using Wine. Apr 6, 2010 at 6:36
1

Hi, i have generated .exe file from C file (ie filename.c ) after compiling in linux machine with -O option

I am assuming you are using GCC and you mean '-o' instead of '-O'. In this case you have named the file to be "file.exe", although on Linux you don't need to specify the file extension as "exe".

So you have done something like

gcc filename.c -o file.exe

You can then run the program using

./file.exe

If you would like to have the compiled application run at startup, you will need to put the compiled file in a common location and investigate which startup scripts run for your distribution (init.rc). You may find this helpful.

Once you have found how to add a startup script then you can add /var/myapp/test.exe to an existing startup script or write your own.

You must log in to answer this question.