Search code examples
phpcdaemon

Running a C program executable in a server with LAMP - what modifications to the C code?


I am planning on putting the executable of a C program in a server and running it using a PHP script - as a Web API: e.g. echo exec("myscript.exe")

Currently the myscript runs on command prompt - it takes two input files and return an integer or float number. Currently the code takes the input files on the command prompt.

What modifications are needed to the existing program - I heard about HTTP bridge and daemon but not sure what I need, if any?

Update: Currently the only other dependency is libsndfile - that is available on Linux. The C program was developed on Linux.


Solution

  • The answer actually depends on the APIs the C application is using. If the C application is using just the Standard C library, then you just need to recompile the application on the target system and invoke the name of the executable. However if you depend on any Windows based APIs such as COM, WinINET, etc you will need to run the executable on another system and have some sort of IPC mechanism between them.