Symbol not found: _fchmodat

Discussion in 'Mac Programming' started by igorland, Mar 19, 2015.

  1. igorland macrumors newbie

    Joined:
    Mar 4, 2014
    #1
    Hello.

    I have made a plugin that links statically to boost_system and boost_filesystem libraries. I successfully compiled the plugin and it works flawlessly on my mac (OSX 10.10). However, another person on OSX 10.9.5 reported to me that he had the following error:

    Code:
    dlerror:dlopen(<link to file>, 6): Symbol not found: _fchmodat
      Referenced from: <link to file>
      Expected in: /usr/lib/libSystem.B.dylib
     in <link to file>
    dlerror:dlsym(0x60800012fbe0, XPluginReceiveMessage): symbol not found
    Can someone please help fix the issue?

    Thanks a lot!
     
  2. chown33 macrumors 604

    Joined:
    Aug 9, 2009
    #2
    What have you tried? Be specific.

    Did you try searching? Again, be specific: what did you search for, what did you find, what did you read, explain why they didn't solve the problem.


    When I google for _fchmodat two of the top results are:
    http://stackoverflow.com/questions/27636393/using-boostfilesystem-fails-due-to-fchmodat-on-mac
    http://ms-cheminfo.com/?q=node/90

    Does one of those solve the problem?


    In general, if you're using a later OS X version than people who use your code, you must tell Xcode to compile for the earliest OS version you intend to deploy to (the "deployment" target). If you don't, then functions that only exist in later OS versions will be used. Since they don't exist on earlier OS versions, there will be compatibility issues.
     
  3. igorland thread starter macrumors newbie

    Joined:
    Mar 4, 2014
    #3
    My deployment target is set to 10.7. I have seen the first link already. It talks about linking the library dynamically, whereas I try to link it statically. The second one I have not tried yet. I have read tens of links, many of which just repeat the first one.
     
  4. igorland thread starter macrumors newbie

    Joined:
    Mar 4, 2014
    #4
    OK. I changed the source code as described in the second link. Tried to use Base SDK 10.9 and get the following error:

    Code:
    Undefined symbols for architecture i386:
      "_fchmodat", referenced from:
          boost::filesystem::detail::permissions(boost::filesystem::path const&, boost::filesystem::perms, boost::system::error_code*) in libboost_filesystem.a(operations.o)
    ld: symbol(s) not found for architecture i386
    clang: error: linker command failed with exit code 1 (use -v to see invocation)
    
    (null): Boost::filesystem::detail::permissions(boost::filesystem::path const&, boost::filesystem::perms, boost::system::error_code*) in libboost_filesystem.a(operations.o)
    
    (null): Symbol(s) not found for architecture i386
    
    (null): Boost::filesystem::detail::permissions(boost::filesystem::path const&, boost::filesystem::perms, boost::system::error_code*) in libboost_filesystem.a(operations.o)
    
    (null): Symbol(s) not found for architecture x86_64
    Compiled it fine with Base SDK 10.10, but waiting whether the file will still work on the other guy's computer.

    Thanks, anyways!
     
  5. chown33 macrumors 604

    Joined:
    Aug 9, 2009
    #5
    At this point, I'm wondering why it compiles for a 10.10 deployment target.

    Here's the chmod(2) man page for OS X:
    https://developer.apple.com/library/mac/documentation/Darwin/Reference/ManPages/man2/chmod.2.html

    It shows chmod() and fchmod(), but not fchmodat().

    That man page could be wrong, so it might be best to look in the associated header on OS X itself (or in the 10.10 SDK's directory). If the header declares fchmodat() on 10.10, then check the same header in the 10.9 SDK.


    The references I can find for the fchmodat() function show it's present on Linux, but nothing I've read says it exists on any version of OS X. To me, that suggests the Boost source you're using isn't as portable as it could be, or its conditional compilation might be broken.

    For example, maybe the Boost code was changed to use fchmodat(), rather than fchmod(), and it doesn't correctly account for the (apparent) fact that this function doesn't exist prior to 10.10. In that case, the source will compile, but it won't link for earlier targets. This is consistent with the posted error messages for a Base SDK of 10.9.

    I'd probably look at the source of the function where fchmodat() is called. I'd probably also look at earlier versions of that Boost func, to see when it was changed to use fchmodat().

    The error messages are pretty good evidence that there's no fchmodat() in 10.9 or earlier, so find the Boost source that works for the 10.9 target, and diff the function in question.

    http://pubs.opengroup.org/onlinepubs/9699919799/functions/chmod.html
     
  6. igorland thread starter macrumors newbie

    Joined:
    Mar 4, 2014
    #6
    Thank you, chown33. I believe that the problem was caused by some error in compiling the boost libraries. I will recompile the libraries. I am also surprised that it worked fine in OSX 10.10.

    For the time being, I solved the issue by avoiding using the boost_filesystem library and replacing it with the good old getcwd() from C. :rolleyes:

    Thank you for your help!
     

Share This Page