# MACOSX\_BUNDLE and dynlibs

**URL:** https://discourse.cmake.org/t/macosx-bundle-and-dynlibs/1294
**Category:** Usage
**Created:** [May 29, 2020, 8:52pm UTC](https://discourse.cmake.org/t/macosx-bundle-and-dynlibs/1294 "2020-05-29T20:52:27Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Gonzalo\_Garramuno](https://discourse.cmake.org/user_avatar/discourse.cmake.org/gonzalo_garramuno/32/265_2.png) [@Gonzalo\_Garramuno](https://discourse.cmake.org/u/Gonzalo_Garramuno)
#### Post date: [May 29, 2020, 8:52pm UTC](https://discourse.cmake.org/t/macosx-bundle-and-dynlibs/1294/1 "2020-05-29T20:52:27Z")

</div>

Hi. I am new to MacOSX and I am pulling my hair.

I am creating an application on MacOSX that relies on multiple dynlibs  
and frameworks that get pulled from FindXXX.cmake or from direct linking  
them.

I am looking for a way to create a bundle with all the dynlibs in them  
ready for deployment. I tried cpack but it did not work. It created a  
bundle with my application with the stop symbol in it, as if it was  
missing something.

Ideally I am looking for a simple solution that just dumps all my  
dynlibs into a lib directory and then I can use the  
DYLD\_FALLBACK\_LIBRARY\_PATH to find them in a startup script.

Also, is there a way to have the executable be placed in a bin/  
directory instead of the Contents/MacOS/ one, so that I can place my  
startup script in the MacOS directory with the name of the executable?

---

<div class="post-metadata">

### Author: ![Gonzalo\_Garramuno](https://discourse.cmake.org/user_avatar/discourse.cmake.org/gonzalo_garramuno/32/265_2.png) [@Gonzalo\_Garramuno](https://discourse.cmake.org/u/Gonzalo_Garramuno)
#### Post date: [May 30, 2020, 10:54pm UTC](https://discourse.cmake.org/t/macosx-bundle-and-dynlibs/1294/3 "2020-05-30T22:54:26Z")

</div>

> [@Gonzalo\_Garramuno](#):
>
> Hi. I am new to MacOSX and I am pulling my hair.

I have made some progress.

> [@Gonzalo\_Garramuno](#):
>
> I am creating an application on MacOSX that relies on multiple dylibs.
> 
> I tried cpack but it did not work. It created a  
> bundle with my application with the stop symbol in it, as if it was  
> missing something.

I found out that OSX does not like executables with the -v1.0 in their names. Once I removed them, the stop sign disappeared.

> [@](#):
>
> Ideally I am looking for a simple solution that just dumps all my  
> dynlibs into a lib directory and then I can use the  
> DYLD\_FALLBACK\_LIBRARY\_PATH to find them in a startup script.

I have this working.

> [@](#):
>
> Also, is there a way to have the executable be placed in a bin/  
> directory instead of the Contents/MacOS/ one, so that I can place my  
> startup script in the MacOS directory with the name of the executable?

I have this working. I had to set:

```
set(CPACK_BUNDLE_STARTUP_COMMAND ${PROJECT_BINARY_DIR}/startup.sh)

```

and the startup.sh script got renamed with the name of my application and placed in the name.app/Contents/MacOS directory.

However, I am still facing another issue regarding executable permissions. The real executable gets placed in name.app/Contents/Resources/bin/name.app/Contents/MacOS/name. I do not know why it is placed on another name.app directory and, more importantly, why it does not have executable permissions.

---

<div class="post-metadata">

### Author: ![ben.boeckel](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.cmake.org/u/ben.boeckel)
#### Post date: [December 30, 2020, 7:54pm UTC](https://discourse.cmake.org/t/macosx-bundle-and-dynlibs/1294/4 "2020-12-30T19:54:14Z")

</div>

I’m not sure about executable permissions, but the `Contents/MacOS` directory is where the “main” binary for a `.app` bundle belongs. Do you have a custom `install()` command for this or is it an `add_executable()` target in your project?
