# Could not load library

**URL:** <https://discourse.julialang.org/t/could-not-load-library/57965>\
**Category:** New to Julia\
**Created:** [March 25, 2021, 7:17pm UTC](https://discourse.julialang.org/t/could-not-load-library/57965 "2021-03-25T19:17:43Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![ovt](https://avatars.discourse-cdn.com/v4/letter/o/87869e/32.png) [@ovt](https://discourse.julialang.org/u/ovt)\
**Post date:** [March 25, 2021, 7:17pm UTC](https://discourse.julialang.org/t/could-not-load-library/57965/1 "2021-03-25T19:17:43Z")

</div>

Hi,

I’ve been trying to run this code that I obtained from [juliaacademy.com](http://juliaacademy.com) but I have the following error computing c\_sum(a) :

```julia
ERROR: could not load library "C:\Users\myusername\AppData\Local\Temp\jl_2ZlYe4PqTE"
� �☺

```

and yes, there’s always some random characters like 0˘☺or Ђ�☺ at the end. I don’t understand…

```julia
a = rand(10^7) 

using Libdl
C_code = """
#include <stddef.h>
double c_sum(size_t n, double *X) {
    double s = 0.0;
    for (size_t i = 0; i < n; ++i) {
        s += X[i];
    }
    return s;
}
"""

const Clib = tempname() # make a temporary file

# compile to a shared library by piping C_code to gcc

open(`gcc -fPIC -O3 -msse3 -xc -shared -o $(Clib * "." * Libdl.dlext) -`, "w") do f
    print(f, C_code) 
end

# define a Julia function that calls the C function:
c_sum(X::Array{Float64}) = ccall(("c_sum", Clib), Float64, (Csize_t, Ptr{Float64}), length(X), X)

c_sum(a)

```
