Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed FreeBSD and some Linux compilations #1

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

jrhigueras
Copy link

@jrhigueras jrhigueras commented Jun 18, 2019

The config.m4 file has been modified in order to match current FreeBSD and Linux configurations.
Also, on hash.c malloc.h include has been changed to stdlib.h as it throws errors on FreeBSD.

The ./configure script will try to automatically discover the correct lpsolve library and its lp_lib.h. If the library is not correctly discovered it will throw an error and --with-phplpsolve55=DIR parameter should be set on ./configure in order to work.

A very basic test has been included and it can be executed via make test.

Current compilation instructions:

phpize
./configure
make
make test

@adamk33n3r
Copy link

Hey @DontCryAndPlay! Thanks for making a PR. I've got to be honest, I don't know anything about this repo and anyone who does has left our company. I attempted to build this but I'm a little lost on what do do. Running ./configure shows an error that it cannot find lp_lib.h. So I went to https://sourceforge.net/projects/lpsolve/files/lpsolve/5.5.2.5/ and downloaded the source, then added that param to point to that directory but then it says it can't find the lib which makes me think that I need to compile lpsolve. I tried to do that but I couldn't figure out and couldn't find any instructions. We still use lpsolve as far as I know but we haven't had to recompile it since our update to php7.2 (and like I said the employee that did that has left and didn't leave instructions).

If you could provide assistance so that I can test this out, that would be greatly appreciated.

@jrhigueras
Copy link
Author

Hey @adamk33n3r. Thanks for your feedback.
Let me introduce you the changes I've made and why.
Like you said, the current library has many errors on how it should be compiled, and that's because it's old. If you try to compile this, with no changes, on a 3-4 years old OS, it may work properly, but changes came to OSes and this library doesn't reflects those changes, and that's why you're getting errors.

First, it doesn't detects the lp_lib.h automagically, you need to specify its path by using --with-phplpsolve55=DIR on ./configure.
Then, there's an "error" with PHP_CHECK_LIBRARY con config.m4 file. It basically, doesn't includes dl and math libraries, required for compiling the test program for the PHP_CHECK_LIBRARY function, and because of that, that check fails showing Invalid phplpsolve55 library, make_lp() not found.
Finally, the library liblpsolve55.so is expected to be on /usr/local/lib directory or linked through shared library by using ldconfig. In case you have ldconfig properly configured and recognises liblpsolve55.so as shared, it will work, but if you got that library compiled from source and not registered on ldconfig it won't.

For those reasons, I've rewrote the config.m4 file on my repo to match the current OS and it works so easy as:

phpize
./configure
make

And optionally: make test for unit testing. It's a very basic unit testing at this moment, but ensures that the library loads on PHP and works.
The compile process has been tested and fully working with no additional interaction on Ubuntu 18.04 and FreeBSD 12.0, but it should work on most GNU/Linux distros if you got the correct libraries installed.

For Debian and derivatives:
apt-get install liblpsolve55-dev
For CentOS and maybe RedHat derivatives:
yum install lpsolve-devel
For FreeBSD:
pkg install lp_solve
or

cd /usr/ports/math/lp_solve
make && make install clean

You can have a look to it at: https://github.com/DontCryAndPlay/php_lp_solve and try to compile that one to see if it works or not.
Please, don't hesitate to open an issue on my repo if it doesn't works and I will have a look.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants