Is it possible to write some C or C++ code and compile to binaries, then use those binaries with php? Is it also possible to write a php library using C and C++ ?
If
You can build shared object extensions that php can then load. There's a short tutorial on this at http://devzone.zend.com/node/view/id/1021
You can write your code in C/C++ and compile it into an EXE. You can then call exec(); from PHP and execute the code.