# Ccall library as a variable string

**URL:** <https://discourse.julialang.org/t/ccall-library-as-a-variable-string/25923>\
**Category:** General Usage\
**Created:** [July 2, 2019, 11:47am UTC](https://discourse.julialang.org/t/ccall-library-as-a-variable-string/25923 "2019-07-02T11:47:23Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mikel\_Antonana](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mikel_antonana/32/3095_2.png) [@Mikel\_Antonana](https://discourse.julialang.org/u/Mikel_Antonana)\
**Post date:** [July 2, 2019, 11:47am UTC](https://discourse.julialang.org/t/ccall-library-as-a-variable-string/25923/1 "2019-07-02T11:47:23Z")

</div>

This works right,  
ccall((:lwrite, “/home/mikel/mylibraries/libCbin\_IO”), void, ())

But if I define a variable to specify the library, it does not work.  
mylib=/home/mikel/mylibraries/libCbin\_IO"  
ccall((:lwrite,mylib), void, ())

Can someone help me?

---

<div class="post-metadata">

**Author:** ![fredrikekre](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/fredrikekre/32/1688_2.png) [@fredrikekre](https://discourse.julialang.org/u/fredrikekre)\
**Post date:** [July 2, 2019, 11:51am UTC](https://discourse.julialang.org/t/ccall-library-as-a-variable-string/25923/2 "2019-07-02T11:51:02Z")

</div>

> [@Mikel\_Antonana](#):
>
> But if I define a variable to specify the library, it does not work.

It is usually quite helpful to include the error message you get; “does not work” is not really much to go on.

I suspect all you need is to make your variable `const`:

```julia
const mylib = "/home/mikel/mylibraries/libCbin_IO"
ccall((:lwrite,mylib), Cvoid, ())

```

See also [PSA: how to quote code with backticks](https://discourse.julialang.org/t/psa-how-to-quote-code-with-backticks/7530)

---

<div class="post-metadata">

**Author:** ![Mikel\_Antonana](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mikel_antonana/32/3095_2.png) [@Mikel\_Antonana](https://discourse.julialang.org/u/Mikel_Antonana)\
**Post date:** [July 2, 2019, 3:47pm UTC](https://discourse.julialang.org/t/ccall-library-as-a-variable-string/25923/3 "2019-07-02T15:47:27Z")

</div>

> [@fredrikekre](#):
>
> const

Using

```julia
I have solve the problem using variable const:
const mylib = "/home/mikel/mylibraries/libCbin_IO"
ccall((:lwrite,mylib), Cvoid, ())

Thank you.

```
