# UndefVarError: solver not defined

**URL:** <https://discourse.julialang.org/t/undefvarerror-solver-not-defined/97497>\
**Category:** Optimization (Mathematical)\
**Tags:** package\
**Created:** [April 14, 2023, 10:20pm UTC](https://discourse.julialang.org/t/undefvarerror-solver-not-defined/97497 "2023-04-14T22:20:35Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Meilame\_Tayebjee](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/meilame_tayebjee/32/47507_2.png) [@Meilame\_Tayebjee](https://discourse.julialang.org/u/Meilame_Tayebjee)\
**Post date:** [April 14, 2023, 10:20pm UTC](https://discourse.julialang.org/t/undefvarerror-solver-not-defined/97497/1 "2023-04-14T22:20:35Z")

</div>

Hi,

I am trying to run that small code that comes from [Introduction to Julia](http://avinashu.com/tutorial/indexjulia.html)

```julia
using JuMP, Clp
m = Model()
@variable(m, x >=0)
@variable(m, y >=0)
@objective(m, Min, 10x + 26y)
@constraint(m, const1, 11x + 3y >= 21)
@constraint(m, const2, 6x + 20y >= 39)
status = solver(m)
println("Status = $status")
println("Optimal Objective Function value: ", getobjectivevalue(m))
println("Optimal Solutions:")
println("x = ", getvalue(x))
println("y = ", getvalue(y))

```

Hower I get that error :

`ERROR: UndefVarError: solver not defined`

I tried to put :

`m = Model(solver = ClpSolver())`

but then I got the error:

`UndefVarError: ClpSolver not defined`

The versions installed are as follow:

```julia
  [e2554f3b] Clp v1.0.2
  [2e9cd046] Gurobi v1.0.0
  [4076af6c] JuMP v1.10.0

```

Thanks a lot for your help !

---

<div class="post-metadata">

**Author:** ![hendri54](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/hendri54/32/9621_2.png) [@hendri54](https://discourse.julialang.org/u/hendri54)\
**Post date:** [April 14, 2023, 11:35pm UTC](https://discourse.julialang.org/t/undefvarerror-solver-not-defined/97497/2 "2023-04-14T23:35:57Z")

</div>

It’s `solve` instead of `solver`

---

<div class="post-metadata">

**Author:** ![odow](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/odow/32/28685_2.png) [@odow](https://discourse.julialang.org/u/odow)\
**Post date:** [April 15, 2023, 12:47am UTC](https://discourse.julialang.org/t/undefvarerror-solver-not-defined/97497/3 "2023-04-15T00:47:06Z")

</div>

That documentation is unofficial and refers to a very old version of JuMP. You shouldn’t refer to it.

Use the official documentation instead. Here’s a tutorial to get started:

> **[Getting started with JuMP · JuMP](https://jump.dev/JuMP.jl/stable/tutorials/getting_started/getting_started_with_JuMP/)**
>
> Documentation for JuMP.

The proper syntax for your example is

```julia
using JuMP, Clp
m = Model(Clp.Optimizer)
@variable(m, x >= 0)
@variable(m, y >= 0)
@objective(m, Min, 10x + 26y)
@constraint(m, const1, 11x + 3y >= 21)
@constraint(m, const2, 6x + 20y >= 39)
optimize!(m)
status = termination_status(m)
println("Status = $status")
println("Optimal Objective Function value: ", objective_value(m))
println("Optimal Solutions:")
println("x = ", value(x))
println("y = ", value(y))

```

---

<div class="post-metadata">

**Author:** ![Meilame\_Tayebjee](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/meilame_tayebjee/32/47507_2.png) [@Meilame\_Tayebjee](https://discourse.julialang.org/u/Meilame_Tayebjee)\
**Post date:** [April 15, 2023, 3:56am UTC](https://discourse.julialang.org/t/undefvarerror-solver-not-defined/97497/5 "2023-04-15T03:56:30Z")

</div>

Thanks for your answer. But when running, Julia crashes . Would you know why ?

EDIT : Very briefly before crashing, this error appears.

 ![Capture d’écran 2023-04-15 à 00.05.20](https://global.discourse-cdn.com/julialang/original/3X/0/7/0776149f14d72115e51031f8f3116e752d3bf3a5.png)

EDIT 2 : I tried with GLPK optimizer, and it works. There seems to be an issue with Clp, could you help me understand that ?
