help-glpk
[Top][All Lists]
Advanced

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

Re: [Help-glpk] glpk with g++


From: Andrew Makhorin
Subject: Re: [Help-glpk] glpk with g++
Date: Wed, 12 Mar 2008 06:40:37 +0300

> hi i am using glpk on linux (ubuntu), i want to use
> g++ compilator.
> here the version :

> ../src/configure -v
> --enable-languages=c,c++,fortran,objc,obj-c++,treelang
> --prefix=/usr --enable-shared --with-system-zlib
> --libexecdir=/usr/lib --without-included-gettext
> --enable-threads=posix --enable-nls
> --program-suffix=-4.1 --enable-__cxa_atexit
> --enable-clocale=gnu --enable-libstdcxx-debug
> --enable-mpfr --enable-checking=release i486-linux-gnu
> Modèle de thread: posix
> version gcc 4.1.2 (Ubuntu 4.1.2-0ubuntu4)

> i am trying to compile the sample.c example with g++
> but i have link problem :

> g++  -c sample.c   ok!
> g++ -o sample sample.o -lglpk

> sample.o: In function `main':
> sample.c:(.text+0x15): undefined reference to
> `glp_lpx_create_prob()'
> sample.c:(.text+0x2b): undefined reference to
> `glp_lpx_set_prob_name(LPX*, char*)'
<...>
> collect2: ld a retourné 1 code d'état d'exécution


> i have to use g++ so please if there is some specific
> lib i will ask you to send to me. this compilation
> works with gcc but i need to use g++. 
> thank you for your help.


You have an old version of glpk, where glpk.h does not suit to be
directly compiled with g++.

Either replace the line:

#include <glpk.h>

in file sample.c by the following line:

extern "C" {
#include <glpk.h>
}

or, that is better, download and install the most recent version
of glpk, which is 4.27.

GLPK distribution can be ftp'ed from <ftp://ftp.gnu.org/gnu/glpk/> or
from some mirror ftp sites; see <http://www.gnu.org/order/ftp.html>.





reply via email to

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