<p dir="auto">I was being really lazy when I wrote this one-liner:</p>
<div class="highlight highlight-source-julia notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="bytes2hex(arr::Vector{UInt8}) = join([hex(i,2) for i in arr])"><pre class="notranslate"><span class="pl-en">bytes2hex</span>(arr<span class="pl-k">::</span><span class="pl-c1">Vector{UInt8}</span>) <span class="pl-k">=</span> <span class="pl-c1">join</span>([<span class="pl-c1">hex</span>(i,<span class="pl-c1">2</span>) <span class="pl-k">for</span> i <span class="pl-k">in</span> arr])</pre></div>
<p dir="auto">It's a good intro issue to rewrite this to pre-allocate a byte buffer, go through and fill it with hex characters appropriately and then return that buffer wrapped in a string object.</p>
<p dir="auto">I do not manage to call Julia from a C-main program under Windows 7. I am aware of issues<br>
<a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="79956639" data-permission-text="Title is private" data-url="https://github.com/JuliaLang/julia/issues/11419" data-hovercard-type="issue" data-hovercard-url="/JuliaLang/julia/issues/11419/hovercard" href="https://github.com/JuliaLang/julia/issues/11419">#11419</a>, <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="135681870" data-permission-text="Title is private" data-url="https://github.com/JuliaLang/julia/issues/15194" data-hovercard-type="issue" data-hovercard-url="/JuliaLang/julia/issues/15194/hovercard" href="https://github.com/JuliaLang/julia/issues/15194">#15194</a>. I have the following C-Program testc.c to perform a minimal test (as adviced in the Julia documentation about embedding Julia). The program is stored under $JULIA_DIR\bin:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="#include &quot;julia.h&quot;
int main(int argc, char *argv[])
{
    jl_init(NULL);  
    jl_eval_string(&quot;display(2.0)&quot;);
    jl_atexit_hook(0);
    return 0;
}"><pre class="notranslate"><code class="notranslate">#include "julia.h"
int main(int argc, char *argv[])
{
    jl_init(NULL);  
    jl_eval_string("display(2.0)");
    jl_atexit_hook(0);
    return 0;
}
</code></pre></div>
<p dir="auto">All the following is performed under Windows 7 with MSYS2 and MINGW64 as adviced in <a href="https://github.com/JuliaLang/julia/blob/master/README.windows.md">https://github.com/JuliaLang/julia/blob/master/README.windows.md</a>.<br>
In all experiments, I start with a fresh MSYS2 shell and execute the following commands:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="JULIA_DIR=&lt;location of JULIA directory&gt;
JULIA_HOME=$JULIA_DIR/bin
export PATH=$JULIA_DIR/bin:$PATH
export PATH=&lt;location of MINGW installed by JULIA&gt;/usr/x86_64-w64-mingw32/sys-root/mingw/bin:$PATH
cd $JULIA_DIR/bin"><pre class="notranslate"><code class="notranslate">JULIA_DIR=&lt;location of JULIA directory&gt;
JULIA_HOME=$JULIA_DIR/bin
export PATH=$JULIA_DIR/bin:$PATH
export PATH=&lt;location of MINGW installed by JULIA&gt;/usr/x86_64-w64-mingw32/sys-root/mingw/bin:$PATH
cd $JULIA_DIR/bin
</code></pre></div>
<p dir="auto">Running Julia 0.4.3 or 0.4.5 with the command:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="gcc -I$JULIA_DIR/include/julia -L$JULIA_DIR/bin -L$JULIA_DIR/lib -ljulia -lopenlibm testc.c -o testc"><pre class="notranslate"><code class="notranslate">gcc -I$JULIA_DIR/include/julia -L$JULIA_DIR/bin -L$JULIA_DIR/lib -ljulia -lopenlibm testc.c -o testc
</code></pre></div>
<p dir="auto">gives the following error:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="Please submit a bug report with steps to reproduce this fault, and any error messages that follow (in their entirety). Thanks.
Exception: EXCEPTION_ACCESS_VIOLATION at 0x0 -- unknown function (ip: 0000000000000000)
unknown function (ip: 0000000000000000)"><pre class="notranslate"><code class="notranslate">Please submit a bug report with steps to reproduce this fault, and any error messages that follow (in their entirety). Thanks.
Exception: EXCEPTION_ACCESS_VIOLATION at 0x0 -- unknown function (ip: 0000000000000000)
unknown function (ip: 0000000000000000)
</code></pre></div>
<p dir="auto">Running Julia 0.5.0-dev:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="Julia Version 0.5.0-dev+4536
Commit 44d778a (2016-06-05 01:30 UTC)
Platform Info:
  System: NT (x86_64-w64-mingw32)
  CPU: Intel(R) Core(TM) i7-4800MQ CPU @
  WORD_SIZE: 64
  BLAS: libopenblas (USE64BITINT DYNAMIC
  LAPACK: libopenblas64_
  LIBM: libopenlibm
  LLVM: libLLVM-3.7.1 (ORCJIT, haswell)"><pre class="notranslate"><code class="notranslate">Julia Version 0.5.0-dev+4536
Commit 44d778a (2016-06-05 01:30 UTC)
Platform Info:
  System: NT (x86_64-w64-mingw32)
  CPU: Intel(R) Core(TM) i7-4800MQ CPU @
  WORD_SIZE: 64
  BLAS: libopenblas (USE64BITINT DYNAMIC
  LAPACK: libopenblas64_
  LIBM: libopenlibm
  LLVM: libLLVM-3.7.1 (ORCJIT, haswell)
</code></pre></div>
<p dir="auto">again with</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="gcc -I$JULIA_DIR/include/julia -L$JULIA_DIR/bin -L$JULIA_DIR/lib -ljulia -lopenlibm testc.c -o testc"><pre class="notranslate"><code class="notranslate">gcc -I$JULIA_DIR/include/julia -L$JULIA_DIR/bin -L$JULIA_DIR/lib -ljulia -lopenlibm testc.c -o testc
</code></pre></div>
<p dir="auto">is successful. Running the generated testc.exe gives the following error:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="LLVM ERROR: Program used external function 'rint' which could not be resolved!"><pre class="notranslate"><code class="notranslate">LLVM ERROR: Program used external function 'rint' which could not be resolved!
</code></pre></div>
<p dir="auto">From <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="79956639" data-permission-text="Title is private" data-url="https://github.com/JuliaLang/julia/issues/11419" data-hovercard-type="issue" data-hovercard-url="/JuliaLang/julia/issues/11419/hovercard" href="https://github.com/JuliaLang/julia/issues/11419">#11419</a>, libopenlibm should be statically linked (especially since rint is a symbol in libopenlibm). Trying to generate a libopenlibm.dll.a stub library for this:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="dlltool -z libopenlibm.dll.def --export-all-symbol libopenlibm.dll
dlltool -d libopenlibm.dll.def -l libopenlibm.dll.a
gcc -I$JULIA_DIR/include/julia -L$JULIA_DIR/bin -L$JULIA_DIR/lib -ljulia -lopenlibm testc.c -o testc"><pre class="notranslate"><code class="notranslate">dlltool -z libopenlibm.dll.def --export-all-symbol libopenlibm.dll
dlltool -d libopenlibm.dll.def -l libopenlibm.dll.a
gcc -I$JULIA_DIR/include/julia -L$JULIA_DIR/bin -L$JULIA_DIR/lib -ljulia -lopenlibm testc.c -o testc
</code></pre></div>
<p dir="auto">gives error messages due to multiple defintiions of</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="atexit, _encode_pointer, __mingw_init_ehandler, _gnu_exception_handler"><pre class="notranslate"><code class="notranslate">atexit, _encode_pointer, __mingw_init_ehandler, _gnu_exception_handler
</code></pre></div>
<p dir="auto">Removed these symbols in libopenlibm.dll.def and running again:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="dlltool -d libopenlibm.dll.def -l libopenlibm.dll.a
gcc -I$JULIA_DIR/include/julia -L$JULIA_DIR/bin -L$JULIA_DIR/lib -ljulia -lopenlibm testc.c -o testc"><pre class="notranslate"><code class="notranslate">dlltool -d libopenlibm.dll.def -l libopenlibm.dll.a
gcc -I$JULIA_DIR/include/julia -L$JULIA_DIR/bin -L$JULIA_DIR/lib -ljulia -lopenlibm testc.c -o testc
</code></pre></div>
<p dir="auto">This is successful.  Running the generated testc.exe gives the following error:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="testc.exe: error while loading shared libraries: (null): cannot open shared object file: No such file or directory"><pre class="notranslate"><code class="notranslate">testc.exe: error while loading shared libraries: (null): cannot open shared object file: No such file or directory
</code></pre></div>
<p dir="auto">I am stuck and do not know what to else to do. Help is appreciated.</p>