[Top][All Lists]

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

[Bug-glpk] Re: C#; Error detected in file ..\src\glplib07.c at line 147

From: Andrew Makhorin
Subject: [Bug-glpk] Re: C#; Error detected in file ..\src\glplib07.c at line 147
Date: Sun, 30 Nov 2008 23:38:16 +0300


I tried to run your example, t1.cs, with MS Visual Studio 2008, and
encountered an error. Stripping the code off I detected that the error
happens in the destructor.

The final code is the following:

using System;
using System.Runtime.InteropServices;

unsafe class GLPK
{   void* lp;
    const string glpkLibrary = "glpk_4_34.dll";
    [DllImport(glpkLibrary, SetLastError = true)]
    static extern void* glp_create_prob();
    public GLPK()
        Console.WriteLine("Enter constructor");
        lp = glp_create_prob();
        Console.WriteLine("Exit constructor");

    [DllImport(glpkLibrary, SetLastError = true)]
    static extern void glp_delete_prob(void* lp);
        Console.WriteLine("Enter destructor");
        Console.WriteLine("Exit destructor");


class test
    public static void Main()
        Console.WriteLine("Enter Main");
        GLPK lp = new GLPK();
        Console.WriteLine("Exit Main");

The output is the following:

Enter Main
Enter constructor
Exit constructor
Exit Main
Enter destructor
xfree: memory allocation error
Error detected in file ..\src\glplib07.c at line 147

Obviously there is something elementary wrong in the call to
glp_delete_prob, because removing the call causes the error to

I am not a C# programmer. May be you could tell me what is wrong?


Andrew Makhorin

reply via email to

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