Compare Proposal

Nothing to compare.

Integrate a C third party library to be used as a shared PHP extension

  • Posted at : 5 months ago
  • Post Similar Project

Skills Required

Posted By -


Projects Posted : 1
Projects Paid : 1
Services Purchased : 0
Total Spent :
Feedbacks : 0 %

Project Details show (+) hide (-)

I need to use a third party library written in C from PHP, preferably as a shared extension.

C library I'm referring to is Tulip Indicators:

  • Documentation:
  • GitHub:
Note: every method in the library has the same exact signature.

Target PHP version: >= 7.2.0

What I have achieved so far
I tried doing it by using SWIG 3.0 (

While compiling and linking the library I had to include -fPIC flag to each step, I will indicate the involved steps here for reference:
  • Add -fPIC as the first CCFLAGS in the library's Makefile
  • [...]
  • gcc -fPIC `php-config --includes` -c tulip_indicators_wrap.c indicators.h
  • gcc -fPIC -shared tulip_indicators_wrap.o libindicators.a -o
I tried implementing some array helpers in SWIG interface file that works for simpler cases, but without succeding in this case.
Note: SWIG usage is not mandatory.

What I need
A step by step guide on how to achieve my need, together with a simple PHP script that will work as an example.
Said script has to succesfully compute only one indicator: the Stochastic Oscillator (, being it the most complete one.
Inputs, options and expected outputs can be found in the same page of the indicator's description.

Note: performance is a priority: adopt the most efficient solution and avoid every possible memory leak.

Your Job Feed