glpkerl (glpk erlang library) compile error

208 views Asked by At

I am trying to compile the glpkerl library on Ubuntu 11.10, but without success so far.

Since I am getting errors all the way, maybe there is something crucial that I am missing:

What I tried

My installed Erlang version is R14B02 (installed via the official apt repository of my distro).

Since my glpk version is newer in the official repo, I downloaded glpk-4.38 from here: http://ftp.gnu.org/gnu/glpk/. I don't want to install this version of glpk systemwide, so I create a directory, ~/opt, and use it in the following steps as the root for all libraries to be installed.

export MY_PREFIX=$HOME/opt
mkdir $MY_PREFIX

cd /tmp
curl http://ftp.gnu.org/gnu/glpk/glpk-4.38.tar.gz | tar zx
cd glpk-3.48 && ./configure --prefix=$MY_PREFIX && make -s && make -s install

Next, I download the glpkerldrv and try to install it:

cd /tmp
curl http://glpkerl.googlecode.com/files/glpkerldrv-4.38.0.tar.gz | tar xz
cd glpkerldrv-4.38.0
./configure --prefix=$MY_PREFIX LDFLAGS="-L$MY_PREFIX/lib" CPPFLAGS="-I$MY_PREFIX/include"
make -s

Apparently something went wrong while using make. I disabled the transformation of compiler warnings to errors by using --disable-hardcore during configure, as stated on the glpkerl install wiki. But even then, the following undeclared identifier error still remains:

handlers.c: In function decode_from:
handlers.c:3310:29: error: INT_MAX undeclared (first use in this function)
handlers.c:3310:29: note: each undeclared identifier is reported only once for each function it appears in

Apparently the perl script that generates handlers.c file should also include the limits.h. I corrected it by adding the following (I have no experience with C so I am unsure if this is the right way to do it):

--- a/src/make-handlers
+++ b/src/make-handlers
@@ -52,6 +52,10 @@
   my ($name, $values) = @_;

   print <<EOD;
+#include <limits.h>
+EOD
+
+  print <<EOD;
 #define deserialize_$name(buf, buflen)                          \\
   ({                                                            \\
     uint8_t byte;                                               \\

Now the building works (with --disable-hardcore, although I don't think the warnings are to be ignored, see attached file), and I can execute a make, make check, and make install, which I did.

I am stuck in the second part though:

cd /tmp
curl http://glpkerl.googlecode.com/files/glpkerl-4.38.0.tar.gz | tar xz
cd glpkerl-4.38.0/
./configure --prefix=$MY_PREFIX LDFLAGS="-L$MY_PREFIX/lib" CPPFLAGS="-I$MY_PREFIX/include"
PKG_CONFIG_PATH=$MY_PREFIX/lib/pkgconfig make -s
PKG_CONFIG_PATH=$MY_PREFIX/lib/pkgconfig make -s check

while building seems the work fine, the check fails because of a dialyzer error:

dialyzer: Could not find the PLT: /home/my_user/.dialyzer_plt

Apparently, we can pass a DIALYZERFLAGS to the makefile, which I did:

DIALYZERFLAGS="--build_plt" PKG_CONFIG_PATH=$MY_PREFIX/lib/pkgconfig make -s check

and here is where I am unsure how to proceed

after executing the last command, I get the following error:

dialyzer: {dialyzer_error,"Byte code compiled with debug_info is needed to build the PLT"}

the strange thing is, that the +debug_info parameter is passed to the erlang compiler apparently, as found in the Makefile.opt file.

I stopped investigating any further, because I am not sure how I can solve this at all with my current environment; am I missing something obvious here? Thanks!

(tags: erlang glpk glpkerl)

1

There are 1 answers

0
Vincenzo Maggio On

the problem here could be that you're using Dialyzer for the wrong analysis: dialyzer is used to analyze standard libraries your application build on in addition to your modules (which you must refer with absolute name).

So in an ideal environment you should type something like dialyzer --build_plt --apps erts kernel stdlib to create the Persistent Lookup Table for the first time, and next you can add your applications to dyalizer PLT file by using dialyzer --add_to_plt.

By the way, if you use dyalizer directly with your modules, you must supply the .beam compiled file, not the .erl source file.