help-glpk
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

SV: [Help-glpk] RE: JNI for Windows?


From: Fredrik Wernstedt
Subject: SV: [Help-glpk] RE: JNI for Windows?
Date: Fri, 20 Feb 2004 09:35:21 +0100

Hi,

 

First, GLPK is great tool and it is absolutely great that it is free!

 

I hope this could be helpful. Using cygwin JNI compiles nicely under windows (xp professional), use the JNI version in the attached zip file. Basically, just some minor changes to the makefile to include some stuff. Extract files to your glpk, put yourself in … glpk-4.3\contrib\jni\c and run “make –f Makefile.cygwin”

Then, move files according to instructions in http://mail.nongnu.org/archive/html/help-glpk/2004-02/msg00036.html which also are valid for windows (except that you have a dll instead of a so file)

(Another issue is that the main glpk43.dll in the bin directory must be named glpk4.dll, and that the path is set to this directory)

  

Also, there is a slip error in the glpk.c file that is corrected in the included glpk.c file, row 210-213 is:

 

JNIEXPORT void JNICALL

Java_org_gnu_glpk_GlpkSolver_setObjC0(JNIEnv *env, jobject obj, jdouble c0) {

  lpx_set_obj_dir(get_lpx(env, obj), (double)c0);

}

 

Should be:

 

JNIEXPORT void JNICALL

Java_org_gnu_glpk_GlpkSolver_setObjC0(JNIEnv *env, jobject obj, jdouble c0) {

  lpx_set_obj_c0(get_lpx(env, obj), (double)c0);

}

 

Also, running xp I sometimes get an error (crash) from glplib2.c rows 438-462. In the printout of the error it doesn’t really look like it is a memory address that is to be deallocated, but I haven’t really looked into it.

 

void ufree(void *ptr)

{     LIBENV *env = lib_env_ptr();

      LIBMEM *desc;

      int size_of_desc = align_datasize(sizeof(LIBMEM));

      if (ptr == NULL)

         fault("ufree: ptr = %p; null pointer", ptr);

      desc = (void *)((char *)ptr - size_of_desc);

      if (desc->flag != LIB_MEM_FLAG)

         fault("ufree: ptr = %p; invalid pointer", ptr);

      if (env->mem_total < desc->size || env->mem_count == 0)

            fault("ufree: ptr = %p; memory allocation error", ptr);

      if (desc->prev == NULL)

         env->mem_ptr = desc->next;

      else

         desc->prev->next = desc->next;

      if (desc->next == NULL)

         ;

      else

         desc->next->prev = desc->prev;

      env->mem_total -= desc->size;

      env->mem_count--;

      memset(desc, '?', size_of_desc);

      free(desc);

      return;

}

 

I handle the error in a very bad way, putting a return statement after the check “if (env->mem_total < desc->size || env->mem_count == 0)”:

 

void ufree(void *ptr)

{     LIBENV *env = lib_env_ptr();

      LIBMEM *desc;

      int size_of_desc = align_datasize(sizeof(LIBMEM));

      if (ptr == NULL)

         fault("ufree: ptr = %p; null pointer", ptr);

      desc = (void *)((char *)ptr - size_of_desc);

      if (desc->flag != LIB_MEM_FLAG)

         fault("ufree: ptr = %p; invalid pointer", ptr);

      if (env->mem_total < desc->size || env->mem_count == 0)

            return;

         /*fault("ufree: ptr = %p; memory allocation error", ptr);*/

      if (desc->prev == NULL)

         env->mem_ptr = desc->next;

      else

         desc->prev->next = desc->next;

      if (desc->next == NULL)

         ;

      else

         desc->next->prev = desc->prev;

      env->mem_total -= desc->size;

      env->mem_count--;

      memset(desc, '?', size_of_desc);

      free(desc);

      return;

}

 

 

Cheers

Fredrik

 


Från: address@hidden [mailto:address@hidden För Chris Rosebrugh
Skickat: den 20 februari 2004 03:45
Till: Welson Sun
Kopia: address@hidden
Ämne: [Help-glpk] RE: JNI for Windows?

 

Hi Welson,

 

The work I did on JNI only applied to Linux. Originally, I had it working for Windows as

well but that also required a recompile of glpk with different switches in order to work.

 

Over the past few months I' ve gotten quite a few requests to have this stuff working on

Windows again so I'll do so this weekend and post a link to this group when it's working.

Caveat emptor though - I only work with Cygwin on Windows with this stuff - not MS Studio

or Borland, so that's all I'll be able to speak to.

 

Cheers.

-----Original Message-----
From: Welson Sun [mailto:address@hidden
Sent: Wednesday, February 18, 2004 11:00 AM
To: address@hidden
Cc: address@hidden
Subject: JNI for Windows?

Hi Chris,

 

I am trying to use the JNI interface for GLPK. In the README of the JNI, it is said that:

 

"Currently, Windows is not supported in the Makefiles.", so how can I make the Windows version of JNI?

 

I am using Cygwin under WindowsXP, and I tried to compile the JNI ( I tried 4.3 and 4.4 ), but there are a lot of errors, and it is saying that there are syntax error in $JAVA_HOME/include/jni.h and $JAVA_HOME/include/win32/jni_md.h

 

Is this JNI only for Linux?

 

 

Best Regards,

Welson Sun

-------------------------------------
Electrical and Computer Engineering
Brigham Young Unversity
461 CB, Provo, Utah 84602

Office: (801) 422-7206
Email:  address@hidden
-------------------------------------

Attachment: jni.zip
Description: Zip compressed data


reply via email to

[Prev in Thread] Current Thread [Next in Thread]