help-glpk
[Top][All Lists]
Advanced

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

[Help-glpk] Re: Build Error


From: Juan Carlos Borras
Subject: [Help-glpk] Re: Build Error
Date: Wed, 08 Nov 2006 14:45:26 +0200

Links your code with the mathematical library.
Otherwise you get errors like "I can't find sqrt, log, fmod, atan2 and things like that" which explains the complains by ld you describe in that long list of compiler messages... Rob writes:
I should add that either of the following lines of code work:
gcc -I. -I../include glpsol.c ../src/libglpk.a -lm
or
gcc glpsol.c -o glpsol -lglpk -lm

What does the -lm option do?
On 11/8/06, Rob <address@hidden> wrote:

Thanks for the help. I finally figured it out after watching the output of the Makefile. The proper command to compile is:
gcc  -I. -I../include -c  glpsol.c
gcc -g -O2 -o glpsol glpsol.o ../src/libglpk.a -lm
The original output from the makefile was:
gcc -DPACKAGE=\"GLPK\" -DVERSION=\"4.9\" -DHAVE_LIBM=1 -DSTDC_HEADERS=1
-I. -I.  -I../include   -g -O2 -c glpsol.c
gcc -g -O2 -o glpsol glpsol.o ../src/libglpk.a -lm
I'm not sure why you have to do it this way exactly. Using the line of
code you gave me produces the output that follows. Any idea why?
address@hidden gcc -I../include glpsol.c ../src/libglpk.a
../src/libglpk.a(glplpx4.o): In function
`gm_scal':/home/rcgreen/Development/GLPK/Source/src/glplpx4.c:307: undefined
reference to `sqrt'
:/home/rcgreen/Development/GLPK/Source/src/glplpx4.c:282: undefined
reference to `sqrt'
../src/libglpk.a(glpipm.o): In function
`basic_info':/home/rcgreen/Development/GLPK/Source/src/glpipm.c:648:
undefined reference to `sqrt'
../src/libglpk.a(glpipm.o): In function
`glp_ipm_main':/home/rcgreen/Development/GLPK/Source/src/glpipm.c:639:
undefined reference to `sqrt'
:/home/rcgreen/Development/GLPK/Source/src/glpipm.c:634: undefined
reference to `sqrt'
../src/libglpk.a(glpipm.o):/home/rcgreen/Development/GLPK/Source/src/glpi pm.c:653:
more undefined references to `sqrt' follow
../src/libglpk.a(glpmpl3.o): In function
`glp_mpl_fp_mod':/home/rcgreen/Development/GLPK/Source/src/glpmpl3.c:137:
undefined reference to `fmod'
../src/libglpk.a(glpmpl3.o): In function
`glp_mpl_fp_exp':/home/rcgreen/Development/GLPK/Source/src/glpmpl3.c:179:
undefined reference to `log'
../src/libglpk.a(glpmpl3.o): In function
`glp_mpl_fp_normal01':/home/rcgreen/Development/GLPK/Source/src/glpmpl3.c :381:
undefined reference to `log'
:/home/rcgreen/Development/GLPK/Source/src/glpmpl3.c:381: undefined
reference to `sqrt'
../src/libglpk.a(glpmpl3.o): In function
`glp_mpl_fp_power':/home/rcgreen/Development/GLPK/Source/src/glpmpl3.c:16 9:
undefined reference to `pow'
:/home/rcgreen/Development/GLPK/Source/src/glpmpl3.c:157: undefined
reference to `log'
:/home/rcgreen/Development/GLPK/Source/src/glpmpl3.c:157: undefined
reference to `log'
:/home/rcgreen/Development/GLPK/Source/src/glpmpl3.c:163: undefined
reference to `log'
:/home/rcgreen/Development/GLPK/Source/src/glpmpl3.c:163: undefined
reference to `log'
:/home/rcgreen/Development/GLPK/Source/src/glpmpl3.c:163: undefined
reference to `log'
../src/libglpk.a(glpmpl3.o):/home/rcgreen/Development/GLPK/Source/src/glp mpl3.c:163:
more undefined references to `log' follow
../src/libglpk.a(glpmpl3.o): In function
`glp_mpl_fp_round':/home/rcgreen/Development/GLPK/Source/src/glpmpl3.c:27 5:
undefined reference to `pow'
../src/libglpk.a(glpmpl3.o): In function
`glp_mpl_fp_trunc':/home/rcgreen/Development/GLPK/Source/src/glpmpl3.c:30 2:
undefined reference to `pow'
../src/libglpk.a(glpmpl3.o): In function
`glp_mpl_fp_exp':/home/rcgreen/Development/GLPK/Source/src/glpmpl3.c:181:
undefined reference to `exp'
../src/libglpk.a(glpmpl3.o): In function
`glp_mpl_fp_log':/home/rcgreen/Development/GLPK/Source/src/glpmpl3.c:192:
undefined reference to `log'
:/home/rcgreen/Development/GLPK/Source/src/glpmpl3.c:192: undefined
reference to `log'
../src/libglpk.a(glpmpl3.o): In function
`glp_mpl_fp_log10':/home/rcgreen/Development/GLPK/Source/src/glpmpl3.c:20 3:
undefined reference to `log10'
:/home/rcgreen/Development/GLPK/Source/src/glpmpl3.c:203: undefined
reference to `log10'
../src/libglpk.a(glpmpl3.o): In function
`glp_mpl_fp_sqrt':/home/rcgreen/Development/GLPK/Source/src/glpmpl3.c:214 :
undefined reference to `sqrt'
../src/libglpk.a(glpmpl3.o): In function
`glp_mpl_fp_sin':/home/rcgreen/Development/GLPK/Source/src/glpmpl3.c:225:
undefined reference to `sin'
../src/libglpk.a(glpmpl3.o): In function
`glp_mpl_fp_cos':/home/rcgreen/Development/GLPK/Source/src/glpmpl3.c:236:
undefined reference to `cos'
../src/libglpk.a(glpmpl3.o): In function
`glp_mpl_fp_atan':/home/rcgreen/Development/GLPK/Source/src/glpmpl3.c:246 :
undefined reference to `atan'
../src/libglpk.a(glpmpl3.o): In function
`glp_mpl_fp_atan2':/home/rcgreen/Development/GLPK/Source/src/glpmpl3.c:25 6:
undefined reference to `atan2'
collect2: ld returned 1 exit status
On 11/8/06, Andrew Makhorin <address@hidden> wrote:
>
> > I installed glpk using apt-get in Ubuntu. I then downloaded the
> source.
> > I'm currently trying to build glpsol.c to ensure that everything is
> set
> > up properly in my environment, but I am getting the following output
> > when I run gcc glpsol.c -lgpk
> >
> > address@hidden gcc glpsol.c -lglpk
> >
> > glpsol.c:337: error: syntax error before '}' token
> >
> > glpsol.c: In function 'parse_cmdline':
> >
> > glpsol.c:620: error: 'LPX_C_COVER' undeclared (first use in this
> function)
> >
> > glpsol.c:620: error: (Each undeclared identifier is reported only once
> >
> > glpsol.c:620: error: for each function it appears in.)
> >
> > glpsol.c:622: error: 'LPX_C_CLIQUE' undeclared (first use in this
> function)
> >
> > glpsol.c:624: error: 'LPX_C_GOMORY' undeclared (first use in this
> function)
> >
> > glpsol.c:626: error: 'LPX_C_ALL' undeclared (first use in this
> function)
> >
> > glpsol.c: In function 'main':
> >
> > glpsol.c:848: error: 'LPX_K_BINARIZE' undeclared (first use in this
> > function)
> >
> > glpsol.c:849: error: 'LPX_K_USECUTS' undeclared (first use in this
> function)
> >
> > Any Suggestions?
>
> Hmm... Try to configure and compile glpk from scratch; there must be
> no errors. Run `make check' to perform a simple check.
> Then not installing the package enter subdirectory `examples' and try
> to compile glpsol:
>
>    gcc -I../include glpsol.c ../src/libglpk.a
>
> The compilation must be successful. Then install the package in a usual
> way. I hope all will work properly.
>
>
>
>

--
Robert C. Green
Master's Candidate in Computer Science and Operations Research
address@hidden
(412) 860-4825
--
Robert C. Green
Master's Candidate in Computer Science and Operations Research
address@hidden
(412) 860-4825





reply via email to

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