Share via

libc.dylib not found in Mac Excel 2016 vba code

Anonymous
2018-12-15T01:01:05+00:00

I am declaring a function in libc.dylib in a vba code in Excel for Mac 2016 as below:

Private Declare PtrSafe Function system Lib "Macintosh HD:usr:lib:libc.dylib" (ByVal command As String) As Long

When I run the code I get the following error message:

Library libc.dylib is in folder ./usr/lib.

Microsoft 365 and Office | Excel | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

7 answers

Sort by: Most helpful
  1. Anonymous
    2019-01-18T21:46:17+00:00

    Think the answer is using the full path using slashes instead of colons. For example:

    Private Declare PtrSafe Function popen64 Lib "/usr/lib/libc.dylib" Alias "popen" (ByVal command As String, ByVal mode As String) As LongPtr

    Apparently they got along fine with just "libc.dylib" before. Perhaps they changed the way the sandboxing works (or other) and now everything external needs the slashed path.

    3 people found this answer helpful.
    0 comments No comments
  2. Anonymous
    2019-01-23T16:17:05+00:00

    Think the answer is using the full path using slashes instead of colons. For example:

    Private Declare PtrSafe Function popen64 Lib "/usr/lib/libc.dylib" Alias "popen" (ByVal command As String, ByVal mode As String) As LongPtr

    Apparently they got along fine with just "libc.dylib" before. Perhaps they changed the way the sandboxing works (or other) and now everything external needs the slashed path.

    Hi Mark, I'm new to VBA and I have this module in my file and I get the same error as the OP.

    Can you advise if I need to replace popen with popen64 on both the IF and else first line?

    And if I need to add the full path to all occurrences of libc.dylib

    #If Mac Then

        #If VBA7 Then

            Private Declare PtrSafe Function popen Lib "libc.dylib" (ByVal command As String, ByVal mode As String) As LongPtr

            Private Declare PtrSafe Function pclose Lib "libc.dylib" (ByVal file As LongPtr) As Long

            Private Declare PtrSafe Function fread Lib "libc.dylib" (ByVal outStr As String, ByVal size As LongPtr, ByVal items As LongPtr, ByVal stream As LongPtr) As Long

            Private Declare PtrSafe Function feof Lib "libc.dylib" (ByVal file As LongPtr) As LongPtr

        #Else

            Private Declare Function popen Lib "libc.dylib" (ByVal command As String, ByVal mode As String) As Long

            Private Declare Function pclose Lib "libc.dylib" (ByVal file As Long) As Long

            Private Declare Function fread Lib "libc.dylib" (ByVal outStr As String, ByVal size As Long, ByVal items As Long, ByVal stream As Long) As Long

            Private Declare Function feof Lib "libc.dylib" (ByVal file As Long) As Long

        #End If

    #End If

    0 comments No comments
  3. Anonymous
    2019-01-19T00:29:11+00:00

    Cheers. To be fair, I stumbled upon the answer by reading the question.

    I had a routine that reads internet usage through a shell call to netstat, which suddenly no longer worked after upgrading to 16.21. Doing a search and seeing the error message made me think "maybe..." and luckily it worked.

    0 comments No comments
  4. Anonymous
    2019-01-18T23:37:42+00:00

    full path worked like a charm.    Thanks for the suggestion.   You'd think it would use the search path but whatever.   explicit works path works in this situation.

    0 comments No comments
  5. Anonymous
    2019-01-18T21:31:59+00:00

    Same issue.   I've been told it can be fixed by rolling back to 16.20 version.   But I don't want to do that.   Any ETA on bugfix?

    0 comments No comments