# Embedding Julia into XCODE in a C++ document, on Big Sur

**URL:** <https://discourse.julialang.org/t/embedding-julia-into-xcode-in-a-c-document-on-big-sur/59458>\
**Category:** New to Julia\
**Tags:** question\
**Created:** [April 17, 2021, 2:08am UTC](https://discourse.julialang.org/t/embedding-julia-into-xcode-in-a-c-document-on-big-sur/59458 "2021-04-17T02:08:26Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![1J0A6L6](https://avatars.discourse-cdn.com/v4/letter/1/34f0e0/32.png) [@1J0A6L6](https://discourse.julialang.org/u/1J0A6L6)\
**Post date:** [April 17, 2021, 2:08am UTC](https://discourse.julialang.org/t/embedding-julia-into-xcode-in-a-c-document-on-big-sur/59458/1 "2021-04-17T02:08:26Z")

</div>

Hi!

For those who have already embedded Julia into their XCODE project in C++ on a MacOS, preferably an Apple Macbook Pro with the Big Sur operating system… how did you do it?

I’m curious, and eager to learn because… I’ve been stuck all afternoon trying to find an answer that works, and it seems everyone CAN do it, but no one has actually done it yet.

---

<div class="post-metadata">

**Author:** ![1J0A6L6](https://avatars.discourse-cdn.com/v4/letter/1/34f0e0/32.png) [@1J0A6L6](https://discourse.julialang.org/u/1J0A6L6)\
**Post date:** [April 23, 2021, 9:14pm UTC](https://discourse.julialang.org/t/embedding-julia-into-xcode-in-a-c-document-on-big-sur/59458/2 "2021-04-23T21:14:40Z")

</div>

Hi! Help???

---

<div class="post-metadata">

**Author:** ![groot](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/groot/32/13081_2.png) [@groot](https://discourse.julialang.org/u/groot)\
**Post date:** [April 23, 2021, 11:27pm UTC](https://discourse.julialang.org/t/embedding-julia-into-xcode-in-a-c-document-on-big-sur/59458/3 "2021-04-23T23:27:32Z")

</div>

I find this [Embedding Julia · The Julia Language](https://docs.julialang.org/en/v1/manual/embedding/) helpful when embedding julia into C++. My application is on Linux. I guess MacOS should be similar

---

<div class="post-metadata">

**Author:** ![1J0A6L6](https://avatars.discourse-cdn.com/v4/letter/1/34f0e0/32.png) [@1J0A6L6](https://discourse.julialang.org/u/1J0A6L6)\
**Post date:** [May 4, 2021, 12:25am UTC](https://discourse.julialang.org/t/embedding-julia-into-xcode-in-a-c-document-on-big-sur/59458/4 "2021-05-04T00:25:23Z")

</div>

> [@groot](#):
>
> Embedding Julia · The Julia Language

I will test it out and let you know! Not tonight, though– just updated to the newest OS. Big Sur 11.3, which has some changes to improve command line (terminal app) functionality.

---

<div class="post-metadata">

**Author:** ![RobertN](https://avatars.discourse-cdn.com/v4/letter/r/f0a364/32.png) [@RobertN](https://discourse.julialang.org/u/RobertN)\
**Post date:** [December 10, 2021, 7:45pm UTC](https://discourse.julialang.org/t/embedding-julia-into-xcode-in-a-c-document-on-big-sur/59458/5 "2021-12-10T19:45:43Z")

</div>

Did you get anywhere with this? I’m usually using Swift in Xcode, so I’m unfamiliar with linking `.dylib` files. When I try to run a command line program, I get this:

```nohighlight
> dyld[97695]: Library not loaded: @rpath/libjulia.dylib
> Referenced from: [DebugDir]/TestCxx
> Reason: tried: '[DebugDir]/libjulia.dylib' (no such file),     
    '/usr/lib/system/introspection/libjulia.dylib' (no such file), 
    '/usr/local/lib/libjulia.dylib' (no such file), 
    '/usr/lib/libjulia.dylib' (no such file)

```

```julia
For ease of reading, I've replaced the long directory path:
/Users/rob/Library/Developer/Xcode/DerivedData/TestCxx-arxxwbgeuqckzxgqevyqwmdmcuxq/Build/Products/Debug/
with: 
[DebugDir]

```

There must be some way to set the “rpath” (?) so that it picks up the library. In my build directory there it did copy in the .dylibs, from /Applications/Julia.app/.

And something going on with file names – `libjulia.1.7.dylib` vs `libjulia.dylib`.

```nohighlight
% pwd
[DebugDir]
% ls
TestCxx libjulia.1.7.dylib	libopenlibm.3.0.dylib

```

Those two dylibs are in Xcode as “Embed & Sign”.

 ![Screen Shot 2021-12-10 at 2.43.41 PM](https://global.discourse-cdn.com/julialang/original/3X/5/1/513c2f5d68aff8bda1131e351ac69500f1424261.png)

---

<div class="post-metadata">

**Author:** ![RobertN](https://avatars.discourse-cdn.com/v4/letter/r/f0a364/32.png) [@RobertN](https://discourse.julialang.org/u/RobertN)\
**Post date:** [December 11, 2021, 4:49pm UTC](https://discourse.julialang.org/t/embedding-julia-into-xcode-in-a-c-document-on-big-sur/59458/6 "2021-12-11T16:49:42Z")

</div>

I switched off “Enable Hardened Runtime” in the target’s build settings. Then the shared library stuff is easier to get working. I just have “libjulia.1.7.dylib” in my list of libraries, with “Do Not Embed”, and it all works.

I’ll have to revisit the more secure way later, with signing and embedding, if I ever distribute an app with Julia.

---

<div class="post-metadata">

**Author:** ![Ondo](https://avatars.discourse-cdn.com/v4/letter/o/ecb155/32.png) [@Ondo](https://discourse.julialang.org/u/Ondo)\
**Post date:** [December 22, 2021, 9:18am UTC](https://discourse.julialang.org/t/embedding-julia-into-xcode-in-a-c-document-on-big-sur/59458/7 "2021-12-22T09:18:19Z")

</div>

I am following this with interest but I can already foresee the problem that I will run into when I hopefully succeed in setting up Xcode as described: How do I call a Julia function from my main program? I have a Julia image analysis function which takes a tiff image as input and returns an array of floats with the results, and I want to call this from Objective C in my case (but information in Swift will probably do too) and catch the array of floats that the function returns.  
Any advice on how to accomplish this will be great appreciated, thanks

---

<div class="post-metadata">

**Author:** ![RobertN](https://avatars.discourse-cdn.com/v4/letter/r/f0a364/32.png) [@RobertN](https://discourse.julialang.org/u/RobertN)\
**Post date:** [December 22, 2021, 3:47pm UTC](https://discourse.julialang.org/t/embedding-julia-into-xcode-in-a-c-document-on-big-sur/59458/8 "2021-12-22T15:47:04Z")

</div>

The docs on embedding has a section on calling Julia functions.

[https://docs.julialang.org/en/v1/manual/embedding/#Calling-Julia-Functions](https://docs.julialang.org/en/v1/manual/embedding/#Calling-Julia-Functions)

But that doesn’t describe how to load the Julia code from C/C++. You can probably use `jl_eval_string`, but it looks like `jl_load_file_string` is better. But that function is not described on in the documentation page.

---

<div class="post-metadata">

**Author:** ![Ondo](https://avatars.discourse-cdn.com/v4/letter/o/ecb155/32.png) [@Ondo](https://discourse.julialang.org/u/Ondo)\
**Post date:** [December 25, 2021, 8:54am UTC](https://discourse.julialang.org/t/embedding-julia-into-xcode-in-a-c-document-on-big-sur/59458/9 "2021-12-25T08:54:41Z")

</div>

Dear Robert,

Thanks for a quick reply.

Best regards,

Peter
