# Error using BigDecimal: 'undefined reference to \`\_\_gmp\_set\_memory\_functions' (Crystal::Loader::LoadError)'

**URL:** <https://forum.crystal-lang.org/t/error-using-bigdecimal-undefined-reference-to-gmp-set-memory-functions-crystal-loaderror/5254>\
**Category:** Help & Support\
**Created:** [January 11, 2023, 10:41pm UTC](https://forum.crystal-lang.org/t/error-using-bigdecimal-undefined-reference-to-gmp-set-memory-functions-crystal-loaderror/5254 "2023-01-11T22:41:24Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![yawaramin](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.crystal-lang.org/yawaramin/32/1872_2.png) [@yawaramin](https://forum.crystal-lang.org/u/yawaramin)\
**Post date:** [January 11, 2023, 10:41pm UTC](https://forum.crystal-lang.org/t/error-using-bigdecimal-undefined-reference-to-gmp-set-memory-functions-crystal-loaderror/5254/1 "2023-01-11T22:41:24Z")

</div>

Hi, I have just installed Crystal and am trying to use BigDecimal, and getting an error. Some details follow.

- macOS Monterey 12.6, Apple M1
- Crystal 1.7.0 installed with Homebrew
- gmp 6.2.1\_1 installed with Homebrew

Running the following:

```auto
$ crystal i
icr> require "big/big_decimal"

```

Getting error:

```auto
undefined reference to `__gmp_set_memory_functions' (Crystal::Loader::LoadError)
  from /opt/homebrew/Cellar/crystal/1.7.0/libexec/crystal in 'raise<Crystal::Loader::LoadError>:NoReturn'
  from /opt/homebrew/Cellar/crystal/1.7.0/libexec/crystal in 'Crystal::Repl::Context#c_function<String>:Pointer(Void)'
  from /opt/homebrew/Cellar/crystal/1.7.0/libexec/crystal in 'Crystal::Repl::Compiler#visit<Crystal::Call>:Bool'
  from /opt/homebrew/Cellar/crystal/1.7.0/libexec/crystal in 'Crystal::ASTNode+@Crystal::ASTNode#accept<Crystal::Repl::Compiler>:Nil'
  from /opt/homebrew/Cellar/crystal/1.7.0/libexec/crystal in 'Crystal::ASTNode+@Crystal::ASTNode#accept<Crystal::Repl::Compiler>:Nil'
  from /opt/homebrew/Cellar/crystal/1.7.0/libexec/crystal in 'Crystal::Repl::Compiler#compile_def:closure_owner<Crystal::Repl::CompiledDef, Crystal::FileModule>:Nil'
  from /opt/homebrew/Cellar/crystal/1.7.0/libexec/crystal in 'Crystal::ASTNode+@Crystal::ASTNode#accept<Crystal::Repl::Compiler>:Nil'
  from /opt/homebrew/Cellar/crystal/1.7.0/libexec/crystal in 'Crystal::ASTNode+@Crystal::ASTNode#accept<Crystal::Repl::Compiler>:Nil'
  from /opt/homebrew/Cellar/crystal/1.7.0/libexec/crystal in 'Crystal::Repl::Compiler#compile_def:closure_owner<Crystal::Repl::CompiledDef, Crystal::FileModule>:Nil'
  from /opt/homebrew/Cellar/crystal/1.7.0/libexec/crystal in 'Crystal::ASTNode+@Crystal::ASTNode#accept<Crystal::Repl::Compiler>:Nil'
  from /opt/homebrew/Cellar/crystal/1.7.0/libexec/crystal in 'Crystal::ASTNode+@Crystal::ASTNode#accept<Crystal::Repl::Compiler>:Nil'
  from /opt/homebrew/Cellar/crystal/1.7.0/libexec/crystal in 'Crystal::Repl::Compiler#compile_def:closure_owner<Crystal::Repl::CompiledDef, Crystal::FileModule>:Nil'
  from /opt/homebrew/Cellar/crystal/1.7.0/libexec/crystal in 'Crystal::ASTNode+@Crystal::ASTNode#accept<Crystal::Repl::Compiler>:Nil'
  from /opt/homebrew/Cellar/crystal/1.7.0/libexec/crystal in 'Crystal::Repl::Compiler#compile<Crystal::ASTNode+>:Nil'
  from /opt/homebrew/Cellar/crystal/1.7.0/libexec/crystal in 'Crystal::Repl::Interpreter#interpret<Crystal::ASTNode+, Hash(String, Crystal::MetaVar)>:Crystal::Repl::Value'
  from /opt/homebrew/Cellar/crystal/1.7.0/libexec/crystal in 'Crystal::Command#repl:(Crystal::Repl::Value | Nil)'
  from /opt/homebrew/Cellar/crystal/1.7.0/libexec/crystal in '__crystal_main'
  from /opt/homebrew/Cellar/crystal/1.7.0/libexec/crystal in 'main'

```

Any ideas how to solve?

---

<div class="post-metadata">

**Author:** ![straight-shoota](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.crystal-lang.org/straight-shoota/32/36_2.png) [@straight-shoota](https://forum.crystal-lang.org/u/straight-shoota)\
**Post date:** [January 11, 2023, 10:50pm UTC](https://forum.crystal-lang.org/t/error-using-bigdecimal-undefined-reference-to-gmp-set-memory-functions-crystal-loaderror/5254/2 "2023-01-11T22:50:40Z")

</div>

I don’t think big numbers work in the interpreter yet.

The bindings for libgmp probably need some adjustment.

---

<div class="post-metadata">

**Author:** ![cyangle](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.crystal-lang.org/cyangle/32/1437_2.png) [@cyangle](https://forum.crystal-lang.org/u/cyangle)\
**Post date:** [January 12, 2023, 12:49am UTC](https://forum.crystal-lang.org/t/error-using-bigdecimal-undefined-reference-to-gmp-set-memory-functions-crystal-loaderror/5254/3 "2023-01-12T00:49:55Z")

</div>

It works if you run file requiring big decimal with interpreter:

```auto
# test.cr
require "big/big_decimal"

debugger
puts 1

```

Then `crystal i test.cr`

---

<div class="post-metadata">

**Author:** ![yawaramin](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.crystal-lang.org/yawaramin/32/1872_2.png) [@yawaramin](https://forum.crystal-lang.org/u/yawaramin)\
**Post date:** [January 12, 2023, 1:03am UTC](https://forum.crystal-lang.org/t/error-using-bigdecimal-undefined-reference-to-gmp-set-memory-functions-crystal-loaderror/5254/4 "2023-01-12T01:03:22Z")

</div>

Thank you, it worked. I tried:

```auto
require "big/big_decimal"

puts(BigDecimal.new("1.1") + BigDecimal.new("2.2"))

```

Which printed the expected `3.3`.
