Compiling glpk in c for windows

931 views Asked by At

I wrote a C code that use glpk library and it works perfectly on linux but I failed to compile it in windows. I downloaded the winglpk-4.55.zip file from sourceforge. Once I decompress the .zip file, I include the glpk.h and glpk.lib in my project, . I'm using Qt so I add the following lines to my .pro file:

LIBS += -L"C:\Program Files (x86)\GLPK\glpk-4.55\w64" -lglpk_4_55
INCLUDEPATH += "C:\Program Files (x86)\GLPK\glpk-4.55\src"

When I run the following code:

#include <QtCore/QCoreApplication>
#include <QTextStream>
#include "glpk.h"

int main(int argc, char *argv[])
{
    QTextStream out(stdout);
    QTextStream in(stdin);

    out << "GLPK version: " << glp_version() << "\n";
    out << "Press Enter\n";
    out.flush();
    in.readLine();
    QCoreApplication::quit();
}

I have the error:

undefined reference to 'glp_version' 

Alternatively I use Visual Studio 2010 and after include the glpk.lib and glpk.h files in the project and add the location of glpk.dll to the environment variable PATH I obtain the same result, so I don't know what I'm doing wrong. I follow the steps explained in https://en.wikibooks.org/wiki/GLPK/Windows but I haven't found a solution. I'm using a 64 bits Win 7 system. Please help me

1

There are 1 answers

0
Vuong Long On

I use Visual Studio it works

I download glpk form this link (download/ setup program): enter link description here

and follow the steps explained in enter link description here

Step: under Linker > Input > Additional Dependencies : add "C:\Program Files\GLPK\glpk-4.47\w32\glpk_4_47.lib"

for me the link is: C:\Program Files (x86)\GnuWin32\lib\glpk.lib

remenber click: down sourse when you install then this step:

Step: under Configuration Properties > VC++ Directories > Include directories : add "C:\Program Files\GLPK\glpk-4.47\src"

you will file your link in sourse downloaded. for me the link is: "C:\Users\Admin\Downloads\src\glpk\4.34\glpk-4.34-src\include"

I also need to copy 3 file.dll in bin when use install into System32 or SysWOW64

I hope these will help you!