Sorry this is a total newb question but there is this really great C-library available and I would like to call functions from it using php. However I have a linux server. Here are the specs:
- Apache version 2.2.17
- PHP version 5.2.17
- MySQL version 5.1.56-community-log
- Architecture x86_64
- Operating system linux
- Kernel version 2.6.32-29.1.BHsmp
Would I be able to call the functions from the C-library in php (ex. using php exec()) if the C-library is on the linux server? If so does the library need to be re-compiled using gcc?
Thanks much!
With those specs. you basically have two options.
Create a wrapper library which acts as a PHP extension which enables you to call your C-functions directly from PHP, for example
mylib_awesome_func('hello');Create a command line utility which acts as an interface to your C library and then call this tool with exec() in PHP.
Option one could be considered more “clean” but is definitely harder, whereas option two may be very easy but may in some cases not be possible depending on what kind of data needs to be transmitted/manipulated back and forth to and from the library.