Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

gregor.hoch

macrumors member
Original poster
Apr 5, 2011
51
6
Hi, I have written a small c++ program that runs without problems on my mac. When I send it to other people, they get a 'permission denied' error though. The permissions are '-rwxr-xr-x'. I have tried it at two other macs and on both I got the same error.
I am running 10.7 and the other two 10.6.

Thanks!
 
What is the full error message ? How is this compiled ? Is this an app bundle or a plain binary executable ? Dynamically or staticly linked ? Did the other people put it on a noexec filesystem ?

There's a few questions that should help you diagnose this problem.

(my money is on missing libraries).
 
What is the full error message ? How is this compiled ? Is this an app bundle or a plain binary executable ? Dynamically or staticly linked ? Did the other people put it on a noexec filesystem ?

There's a few questions that should help you diagnose this problem.

(my money is on missing libraries).

I am pretty much a newbie in this regard and haven't found a nice and comprehensive introduction online so far. So I just jumped right in... Xcode set up a lot of things automatically and the rest was trial and error. So I will try to answer your questions as good as a can:

the full error message is:
-bash: ~/Downloads/ExtractPDFMarkUp: Permission denied

It's a plain binary executable (Unix Executable File).

I have compiled it with Xcode based on 64-Bit. The linking is dynamical but I don't know how to change that. I tried all kind of things but wasn't successful. When I rename the dynamic library file on my computer I get a different error message though (something like library not found). I don't know how to get more details.

No, the other people didn't put it on a noexec filesystem.

Thanks!
 
I am pretty much a newbie in this regard and haven't found a nice and comprehensive introduction online so far. So I just jumped right in... Xcode set up a lot of things automatically and the rest was trial and error. So I will try to answer your questions as good as a can:

the full error message is:
-bash: ~/Downloads/ExtractPDFMarkUp: Permission denied

It's a plain binary executable (Unix Executable File).

I have compiled it with Xcode based on 64-Bit. The linking is dynamical but I don't know how to change that. I tried all kind of things but wasn't successful. When I rename the dynamic library file on my computer I get a different error message though (something like library not found). I don't know how to get more details. Someone has to do a chmod by hand to get downloaded unix files working.

No, the other people didn't put it on a noexec filesystem.

Thanks!

When you posted the flags (read, write, execute) on the file, did you get them from your system or from the computer the file was copied to? If it was downloaded into someone's download folder, it is very very very unlikely that it has the execute flag set.
 
I am pretty much a newbie in this regard and haven't found a nice and comprehensive introduction online so far. So I just jumped right in... Xcode set up a lot of things automatically and the rest was trial and error. So I will try to answer your questions as good as a can:

the full error message is:
-bash: ~/Downloads/ExtractPDFMarkUp: Permission denied

It's a plain binary executable (Unix Executable File).

I have compiled it with Xcode based on 64-Bit. The linking is dynamical but I don't know how to change that. I tried all kind of things but wasn't successful. When I rename the dynamic library file on my computer I get a different error message though (something like library not found). I don't know how to get more details.

No, the other people didn't put it on a noexec filesystem.

Thanks!

The following commands should help you get more information :

Code:
$ ls -al ExtractPDFMarkUp
Code:
$ otool -L ExtractPDFMarkUp
Code:
$ file ExtractPDFMarkUp

Compare the output between your system and theirs.
 
Check your deployment target, which is the earliest version of Mac OS X that can run your program. When you create a project, Xcode sets the deployment target to the version of Mac OS X you're running. Because you're running 10.7, your program won't run on 10.6 unless you change the deployment target.

To change the deployment target, select your project file from the project navigator to open the project editor. Select your project from the project editor. Click the Info button at the top of the project editor. Use the Mac OS X Deployment Target combo box to set the deployment target.
 
Thanks for all the suggestions! I try these things out (I don't have immediate assess to the other mac).
My hope is that the permission problem will be solved and I have already compiled with 10.5 as a deployment target. But I am afraid that the dynamically linked libraries are still going to be a problem. Below is what I get from 'otool -L' on my mac. I would like to easily distribute the binary (other are already compiling for other systems). I wasn't able to use static links and from what I read it's not easy considering that poppler itself depends on other libraries. What is the best approach in this situation (if that ends up being the problem after the additional checks)?


otool -L ExtractPDFMarkUp
ExtractPDFMarkUp:
[poppler dir]/Release/libpoppler.dylib (compatibility version 13.0.0, current version 13.0.0)
/opt/local/lib/libfontconfig.1.dylib (compatibility version 6.0.0, current version 6.4.0)
/usr/lib/libstdc++.6.dylib (compatibility version 7.0.0, current version 52.0.0)
/usr/lib/libgcc_s.1.dylib (compatibility version 1.0.0, current version 1105.0.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 159.0.0)
 
I have now created a .app bundle with the unix executable in 'my.app/Contents/MacOS' and the dynamic libraries in 'my.app/Contents/Frameworks'. After creating the bundle I have changed the lib location in the binary using install_name_tool to @executable_path/../Frameworks/libmylib.dylib.
When I start the app file it crashes right away. I can, however, directly address the binary using 'my.app/Contents/MacOS/my', which works.

How bad is this practice? What would be a better alternative to package the binary with the dynamic libraries?
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.