# Running a compiled DLL on a different platforms it give me error

**URL:** <https://discourse.julialang.org/t/running-a-compiled-dll-on-a-different-platforms-it-give-me-error/1278>\
**Category:** General Usage\
**Created:** [January 4, 2017, 2:23pm UTC](https://discourse.julialang.org/t/running-a-compiled-dll-on-a-different-platforms-it-give-me-error/1278 "2017-01-04T14:23:30Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![Martin\_Florek](https://avatars.discourse-cdn.com/v4/letter/m/f4b2a3/32.png) [@Martin\_Florek](https://discourse.julialang.org/u/Martin_Florek)\
**Post date:** [January 4, 2017, 2:23pm UTC](https://discourse.julialang.org/t/running-a-compiled-dll-on-a-different-platforms-it-give-me-error/1278/1 "2017-01-04T14:23:30Z")

</div>

ERROR: Target architecture mismatch. Please delete or regenerate sys.{so,dll,dylib}.

I compiled my user image following command from the command line (In directory C:\Julia-0.5.0\bin):

> julia.exe “C:/Julia-0.5.0/build\_sysimg\_tim.jl” libFOO native “C:/Julia-0.5.0/userimg.jl” --force

Then I got a **libFOO.dll** that I call from the C language with using julia.h and I have the executable file **Project.exe**. This **EXE** file run on my computer, but when copy EXE with needed DLLs to another platform I getting the above mentioned error.

Compiled on processor:  
Intel(R) Xeon(R) CPU E5-2430L v2 @ 2.40GHz, 2400 Mhz, 12 Core(s), 12 Logical Processor(s)

Tested on processors:  
Intel(R) Core™ i5-4300U CPU @ 1.90GHz, 2494 Mhz, 2 Core(s), 4 Logical Processor(s)  
and Intel(R) Core™ i7-6700HQ CPU 2.6GHz

Any advice is welcome, thanks.

---

<div class="post-metadata">

**Author:** ![ihnorton](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ihnorton/32/26_2.png) [@ihnorton](https://discourse.julialang.org/u/ihnorton)\
**Post date:** [January 4, 2017, 2:28pm UTC](https://discourse.julialang.org/t/running-a-compiled-dll-on-a-different-platforms-it-give-me-error/1278/2 "2017-01-04T14:28:08Z")

</div>

To work across different processor models within the same architecture, specify a specific (older) CPU vintage; replacing `native` with `core2` should work. `native` will use the highest instruction set available on the processor where the image is compiled.

see [http://docs.julialang.org/en/stable/devdocs/sysimg/#build\_sysimg](http://docs.julialang.org/en/stable/devdocs/sysimg/#build_sysimg)

---

<div class="post-metadata">

**Author:** ![Martin\_Florek](https://avatars.discourse-cdn.com/v4/letter/m/f4b2a3/32.png) [@Martin\_Florek](https://discourse.julialang.org/u/Martin_Florek)\
**Post date:** [January 5, 2017, 9:25am UTC](https://discourse.julialang.org/t/running-a-compiled-dll-on-a-different-platforms-it-give-me-error/1278/3 "2017-01-05T09:25:53Z")

</div>

Yes, core2 is sufficient.Thanks

---

<div class="post-metadata">

**Author:** ![Martin\_Florek](https://avatars.discourse-cdn.com/v4/letter/m/f4b2a3/32.png) [@Martin\_Florek](https://discourse.julialang.org/u/Martin_Florek)\
**Post date:** [January 10, 2017, 3:43pm UTC](https://discourse.julialang.org/t/running-a-compiled-dll-on-a-different-platforms-it-give-me-error/1278/4 "2017-01-10T15:43:27Z")

</div>

However on newer processor (Intel(R) Core™ i7-6700HQ CPU 2.6GHz) I have always mentioned error. I tried both switches “core2” also “native” for cpu\_target. Without success ☹

---

<div class="post-metadata">

**Author:** ![ihnorton](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ihnorton/32/26_2.png) [@ihnorton](https://discourse.julialang.org/u/ihnorton)\
**Post date:** [January 11, 2017, 3:23pm UTC](https://discourse.julialang.org/t/running-a-compiled-dll-on-a-different-platforms-it-give-me-error/1278/5 "2017-01-11T15:23:42Z")

</div>

> [@Martin\_Florek](#):
>
> Target architecture mismatch

Do the nightly binaries work?

---

<div class="post-metadata">

**Author:** ![Martin\_Florek](https://avatars.discourse-cdn.com/v4/letter/m/f4b2a3/32.png) [@Martin\_Florek](https://discourse.julialang.org/u/Martin_Florek)\
**Post date:** [January 12, 2017, 10:52am UTC](https://discourse.julialang.org/t/running-a-compiled-dll-on-a-different-platforms-it-give-me-error/1278/6 "2017-01-12T10:52:41Z")

</div>

I tried to test it with nightly build (julia-0.6.0-29a35637b4-win64) but unsuccessfully. I could not install package WinRPM without error and when run compile script it is cyclic repeated.

> julia.exe “C:/Julia-0.6.0-dev/build\_sysimg\_tim.jl” libFOO core2 “C:/Julia-0.6.0-dev/userimg.jl” --force

Any other ideas?

---

<div class="post-metadata">

**Author:** ![jameson](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jameson/32/23_2.png) [@jameson](https://discourse.julialang.org/u/jameson)\
**Post date:** [January 17, 2017, 6:27pm UTC](https://discourse.julialang.org/t/running-a-compiled-dll-on-a-different-platforms-it-give-me-error/1278/7 "2017-01-17T18:27:07Z")

</div>

What errors are you seeing in each case (always the same, or one of the similarly worded ones)?

The matching of architectures is usually handled by `jl_preload_sysimg_so`, and gets largely disabled if you’ve specified a target architecture. Maybe confirm that `jl_options.image_file` is being set correctly in your `exe`?

---

<div class="post-metadata">

**Author:** ![Martin\_Florek](https://avatars.discourse-cdn.com/v4/letter/m/f4b2a3/32.png) [@Martin\_Florek](https://discourse.julialang.org/u/Martin_Florek)\
**Post date:** [January 18, 2017, 8:25am UTC](https://discourse.julialang.org/t/running-a-compiled-dll-on-a-different-platforms-it-give-me-error/1278/8 "2017-01-18T08:25:07Z")

</div>

If it gives me error is still the same. I create run exe with own.dll and after opening on the above-mentioned processor I got error "Target architecture mismatch… ". When I try to open the DLL by Julia C API program fell in function `jl_init_with_image` with a similar type of ERROR:  
Unhandled exception at 0x0000000064F3C4BA (libjulia.dll) in TIM.exe: 0xC00000FD: Stack overflow (parameters: 0x0000000000000001, 0x000000FEC0D33FF8).

I could not open the DLL, but at the moment after further build it mysteriously works.

---

<div class="post-metadata">

**Author:** ![ihnorton](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ihnorton/32/26_2.png) [@ihnorton](https://discourse.julialang.org/u/ihnorton)\
**Post date:** [January 18, 2017, 1:37pm UTC](https://discourse.julialang.org/t/running-a-compiled-dll-on-a-different-platforms-it-give-me-error/1278/9 "2017-01-18T13:37:46Z")

</div>

> [@Static julia compilation with own package](https://discourse.julialang.org/t/static-julia-compilation-with-own-package/1435/2):
>
> Please provide a minimal, complete, reproducible example. We cannot help without more information: your C code, which compiler and arguments, etc. Try building the example in examples/embedding.c, and make sure that your initialization code works on the default sysimg.

---

<div class="post-metadata">

**Author:** ![Martin\_Florek](https://avatars.discourse-cdn.com/v4/letter/m/f4b2a3/32.png) [@Martin\_Florek](https://discourse.julialang.org/u/Martin_Florek)\
**Post date:** [January 19, 2017, 10:28am UTC](https://discourse.julialang.org/t/running-a-compiled-dll-on-a-different-platforms-it-give-me-error/1278/10 "2017-01-19T10:28:29Z")

</div>

Maybe it’s Windows update because I use still the same procedure compilation. In the near future I will make a minimal reproducible example mainly due to compile a custom packages.
