c++ program compiled in Xcode 4.1 does not run on other computers (permission denied)

Discussion in 'Mac Programming' started by gregor.hoch, Aug 15, 2011.

  1. gregor.hoch macrumors member

    Joined:
    Apr 5, 2011
    #1
    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!
     
  2. Sander macrumors 6502

    Joined:
    Apr 24, 2008
  3. gregor.hoch thread starter macrumors member

    Joined:
    Apr 5, 2011
    #3
    It extracts annotations and highlighted text from pdfs and is based on the poppler library.
     
  4. KnightWRX macrumors Pentium

    KnightWRX

    Joined:
    Jan 28, 2009
    Location:
    Quebec, Canada
    #4
    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).
     
  5. gregor.hoch thread starter macrumors member

    Joined:
    Apr 5, 2011
    #5
    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!
     
  6. gnasher729 macrumors P6

    gnasher729

    Joined:
    Nov 25, 2005
    #6
    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.
     
  7. KnightWRX macrumors Pentium

    KnightWRX

    Joined:
    Jan 28, 2009
    Location:
    Quebec, Canada
    #7
    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.
     
  8. szymczyk macrumors regular

    Joined:
    Mar 5, 2006
    #8
    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.
     
  9. gregor.hoch thread starter macrumors member

    Joined:
    Apr 5, 2011
    #9
    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)
     
  10. gregor.hoch thread starter macrumors member

    Joined:
    Apr 5, 2011
    #10
    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?
     
  11. gregor.hoch thread starter macrumors member

    Joined:
    Apr 5, 2011
    #11

Share This Page