Skip to content

failure building with openssl@3, works with [email protected] #30

Closed

Description

@stepheneb

Building gitx I got this error building the ObjectiveGit.framework in xcode 13.2.1 on macos 11.6.3.

Undefined symbols for architecture x86_64:
  "_EVP_PKEY_id", referenced from:
      __libssh2_ed25519_new_private_frommemory in libssh2.a(openssl.o)
      __libssh2_pub_priv_keyfile in libssh2.a(openssl.o)
      __libssh2_pub_priv_keyfilememory in libssh2.a(openssl.o)
ld: symbol(s) not found for architecture x86_64

Building succeeded adding LDFLAGS="-L/usr/local/opt/[email protected]/lib" to the ObjectiveGit.framework target build settings.

image

see: gitx/gitx#239 (comment)

Activity

  1. hannesa2 commented on Feb 8, 2022

    @hannesa2

    When I do this on my x86 Mac it still fails with same error.

    image

    To be able to verify your changes locally, please can you put your changes into a pull request ?

  2. stepheneb commented on Feb 8, 2022

    @stepheneb
    Author

    Have master checked out separately from gitx.

    $ git show
    commit 972f9aad0e276d30547fdb0a3b93e26407c29a2a (HEAD -> openssl1.1, origin/master, origin/HEAD, master)
    Merge: 845bab0e 8f1da7a8
    Author: Hannes Achleitner <[email protected]>
    Date:   Sun Feb 6 16:23:55 2022 +0100
    
        Merge pull request #29 from gitx/Xcode_13.2.1
        
        Xcode 13.2.1
    

    Opened ObjectiveGitFramework.xcworkspace in xcode 13.2.1 on macos 11.6.3 and got this error: SWIFT_VERSION '3.0' is unsupported, supported versions are: 4.0, 4.2, 5.0.

    image

  3. hannesa2 commented on Feb 11, 2022

    @hannesa2

    Opened ObjectiveGitFramework.xcworkspace in xcode 13.2.1 on macos 11.6.3 and got this error: SWIFT_VERSION '3.0' is unsupported, supported versions are: 4.0, 4.2, 5.0.

    I guess this should solved now with

    @stepheneb please give it a try on recent master

  4. hannesa2 commented on Feb 11, 2022

    @hannesa2

    On my side your primary message disappeared after a simple
    brew reinstall openssl@3

  5. stepheneb commented on Feb 11, 2022

    @stepheneb
    Author

    Got further:

    • error: no such file or directory: 'External/libssh2.a'

    Steps:

    • brew reinstall openssl@3.
    • Checked out master branch in new dir.
    • in dir: git submodule update --init --recursive
    • open ObjectiveGitFramework.xcworkspace in xcode 13.2.1
    • start build for my computer: macOS 11.6.3, MacBook Pro Retina, late 2013
    Ld /Users/stephen/Library/Developer/Xcode/DerivedData/ObjectiveGitFramework-fyaphaesxegukpfgkwopelgpztry/Build/Products/Debug/ObjectiveGit.framework/Versions/A/ObjectiveGit normal (in target 'ObjectiveGit-Mac' from project 'ObjectiveGitFramework')
        cd /Users/stephen/dev/macos/objgit/objective-git
        /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -target x86_64-apple-macos10.9 -dynamiclib -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.1.sdk -L/Users/stephen/Library/Developer/Xcode/DerivedData/ObjectiveGitFramework-fyaphaesxegukpfgkwopelgpztry/Build/Products/Debug -L. -LExternal -L/usr/local/opt/openssl/lib -L/Users/stephen/dev/macos/objgit/objective-git/External/build/lib -F/Users/stephen/Library/Developer/Xcode/DerivedData/ObjectiveGitFramework-fyaphaesxegukpfgkwopelgpztry/Build/Products/Debug -filelist /Users/stephen/Library/Developer/Xcode/DerivedData/ObjectiveGitFramework-fyaphaesxegukpfgkwopelgpztry/Build/Intermediates.noindex/ObjectiveGitFramework.build/Debug/ObjectiveGit-Mac.build/Objects-normal/x86_64/ObjectiveGit.LinkFileList -install_name @rpath/ObjectiveGit.framework/ObjectiveGit -Xlinker -rpath -Xlinker @loader_path/Frameworks -Xlinker -rpath -Xlinker @executable_path/../Frameworks -Xlinker -object_path_lto -Xlinker /Users/stephen/Library/Developer/Xcode/DerivedData/ObjectiveGitFramework-fyaphaesxegukpfgkwopelgpztry/Build/Intermediates.noindex/ObjectiveGitFramework.build/Debug/ObjectiveGit-Mac.build/Objects-normal/x86_64/ObjectiveGit_lto.o -Xlinker -export_dynamic -Xlinker -no_deduplicate -fobjc-arc -fobjc-link-runtime -fapplication-extension -lgit2 -force_load External/libgit2.a External/libssh2.a -lcrypto -lssl -lcurl -lz -liconv -lgit2 -framework Cocoa -compatibility_version 1 -current_version 1 -Xlinker -dependency_info -Xlinker /Users/stephen/Library/Developer/Xcode/DerivedData/ObjectiveGitFramework-fyaphaesxegukpfgkwopelgpztry/Build/Intermediates.noindex/ObjectiveGitFramework.build/Debug/ObjectiveGit-Mac.build/Objects-normal/x86_64/ObjectiveGit_dependency_info.dat -o /Users/stephen/Library/Developer/Xcode/DerivedData/ObjectiveGitFramework-fyaphaesxegukpfgkwopelgpztry/Build/Products/Debug/ObjectiveGit.framework/Versions/A/ObjectiveGit
    
    clang: error: no such file or directory: 'External/libssh2.a'
    Command Ld failed with a nonzero exit code
    

    image

  6. hannesa2 commented on Feb 11, 2022

    @hannesa2

    you need to run ./script/bootstrap in advance.

    Wrong or not, I do all in command line

  7. stepheneb commented on Feb 11, 2022

    @stepheneb
    Author

    What are your commands to build completely from the command line?

    After clone I presume they start like this:

    git submodule update --init --recursive
    ./script/bootstrap
    

    Now getting this error:

    Undefined symbols for architecture x86_64:
      "_EVP_PKEY_id", referenced from:
          __libssh2_ed25519_new_private_frommemory in libssh2.a(openssl.o)
    

    More complete output from log:

    Ld /Users/stephen/Library/Developer/Xcode/DerivedData/ObjectiveGitFramework-fyaphaesxegukpfgkwopelgpztry/Build/Products/Debug/ObjectiveGit.framework/Versions/A/ObjectiveGit normal (in target 'ObjectiveGit-Mac' from project 'ObjectiveGitFramework')
        cd /Users/stephen/dev/macos/objgit/objective-git
        /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -target x86_64-apple-macos10.9 -dynamiclib -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.1.sdk -L/Users/stephen/Library/Developer/Xcode/DerivedData/ObjectiveGitFramework-fyaphaesxegukpfgkwopelgpztry/Build/Products/Debug -L. -LExternal -L/usr/local/opt/openssl/lib -L/Users/stephen/dev/macos/objgit/objective-git/External/build/lib -F/Users/stephen/Library/Developer/Xcode/DerivedData/ObjectiveGitFramework-fyaphaesxegukpfgkwopelgpztry/Build/Products/Debug -filelist /Users/stephen/Library/Developer/Xcode/DerivedData/ObjectiveGitFramework-fyaphaesxegukpfgkwopelgpztry/Build/Intermediates.noindex/ObjectiveGitFramework.build/Debug/ObjectiveGit-Mac.build/Objects-normal/x86_64/ObjectiveGit.LinkFileList -install_name @rpath/ObjectiveGit.framework/ObjectiveGit -Xlinker -rpath -Xlinker @loader_path/Frameworks -Xlinker -rpath -Xlinker @executable_path/../Frameworks -Xlinker -object_path_lto -Xlinker /Users/stephen/Library/Developer/Xcode/DerivedData/ObjectiveGitFramework-fyaphaesxegukpfgkwopelgpztry/Build/Intermediates.noindex/ObjectiveGitFramework.build/Debug/ObjectiveGit-Mac.build/Objects-normal/x86_64/ObjectiveGit_lto.o -Xlinker -export_dynamic -Xlinker -no_deduplicate -fobjc-arc -fobjc-link-runtime -fapplication-extension -lgit2 -force_load External/libgit2.a External/libssh2.a -lcrypto -lssl -lcurl -lz -liconv -lgit2 -framework Cocoa -compatibility_version 1 -current_version 1 -Xlinker -dependency_info -Xlinker /Users/stephen/Library/Developer/Xcode/DerivedData/ObjectiveGitFramework-fyaphaesxegukpfgkwopelgpztry/Build/Intermediates.noindex/ObjectiveGitFramework.build/Debug/ObjectiveGit-Mac.build/Objects-normal/x86_64/ObjectiveGit_dependency_info.dat -o /Users/stephen/Library/Developer/Xcode/DerivedData/ObjectiveGitFramework-fyaphaesxegukpfgkwopelgpztry/Build/Products/Debug/ObjectiveGit.framework/Versions/A/ObjectiveGit
    
    ld: warning: dylib (/usr/local/opt/openssl/lib/libcrypto.dylib) was built for newer macOS version (11.0) than being linked (10.9)
    ld: warning: dylib (/usr/local/opt/openssl/lib/libssl.dylib) was built for newer macOS version (11.0) than being linked (10.9)
    ld: warning: linking against a dylib which is not safe for use in application extensions: /usr/local/opt/openssl/lib/libcrypto.dylib
    ld: warning: linking against a dylib which is not safe for use in application extensions: /usr/local/opt/openssl/lib/libssl.dylib
    ld: warning: object file (External/libssh2.a(agent.o)) was built for newer macOS version (11.0) than being linked (10.9)
    ld: warning: object file (External/libssh2.a(channel.o)) was built for newer macOS version (11.0) than being linked (10.9)
    ld: warning: object file (External/libssh2.a(global.o)) was built for newer macOS version (11.0) than being linked (10.9)
    ld: warning: object file (External/libssh2.a(hostkey.o)) was built for newer macOS version (11.0) than being linked (10.9)
    ld: warning: object file (External/libssh2.a(session.o)) was built for newer macOS version (11.0) than being linked (10.9)
    ld: warning: object file (External/libssh2.a(userauth.o)) was built for newer macOS version (11.0) than being linked (10.9)
    ld: warning: object file (External/libssh2.a(misc.o)) was built for newer macOS version (11.0) than being linked (10.9)
    ld: warning: object file (External/libssh2.a(openssl.o)) was built for newer macOS version (11.0) than being linked (10.9)
    ld: warning: object file (External/libssh2.a(kex.o)) was built for newer macOS version (11.0) than being linked (10.9)
    ld: warning: object file (External/libssh2.a(packet.o)) was built for newer macOS version (11.0) than being linked (10.9)
    ld: warning: object file (External/libssh2.a(transport.o)) was built for newer macOS version (11.0) than being linked (10.9)
    ld: warning: object file (External/libssh2.a(keepalive.o)) was built for newer macOS version (11.0) than being linked (10.9)
    ld: warning: object file (External/libssh2.a(comp.o)) was built for newer macOS version (11.0) than being linked (10.9)
    ld: warning: object file (External/libssh2.a(mac.o)) was built for newer macOS version (11.0) than being linked (10.9)
    ld: warning: object file (External/libssh2.a(pem.o)) was built for newer macOS version (11.0) than being linked (10.9)
    ld: warning: object file (External/libssh2.a(bcrypt_pbkdf.o)) was built for newer macOS version (11.0) than being linked (10.9)
    ld: warning: object file (External/libssh2.a(crypt.o)) was built for newer macOS version (11.0) than being linked (10.9)
    ld: warning: object file (External/libssh2.a(blowfish.o)) was built for newer macOS version (11.0) than being linked (10.9)
    Undefined symbols for architecture x86_64:
      "_EVP_PKEY_id", referenced from:
          __libssh2_ed25519_new_private_frommemory in libssh2.a(openssl.o)
          __libssh2_pub_priv_keyfile in libssh2.a(openssl.o)
          __libssh2_pub_priv_keyfilememory in libssh2.a(openssl.o)
    ld: symbol(s) not found for architecture x86_64
    clang: error: linker command failed with exit code 1 (use -v to see invocation)
    
  8. hannesa2 commented on Feb 11, 2022

    @hannesa2

    I do almost the same like this https://github.com/gitx/objective-git/blob/master/.github/workflows/BuildPR.yml#L21-L24

    But I only build arm64 (I use a M1) without x86_64

    script/bootstrap && script/update_libgit2
    xcodebuild -workspace ObjectiveGitFramework.xcworkspace -scheme "ObjectiveGit Mac" test archive ARCHS="arm64"
    
  9. hannesa2 commented on Feb 11, 2022

    @hannesa2

    I could swear, it was working before lunch, but the test doesn't work anymore, but this works

    xcodebuild -workspace ObjectiveGitFramework.xcworkspace -scheme "ObjectiveGit Mac" archive ARCHS="arm64"

    image

    This is all dirty :

    image

    And should be solved only by (architecture dependent) search path. I spent the half day with this, but still no success...

    What's your output of find /opt/homebrew -name "libssh*.a" ?

  10. hannesa2 commented on Feb 11, 2022

    @hannesa2

    Ahh, on your side the output of find /usr/local -name "libssh*.a" ?

  11. stepheneb commented on Feb 11, 2022

    @stepheneb
    Author
    $ find /usr/local -name "libssh*.a"
    /usr/local/lib/libssh2.a
    /usr/local/Cellar/libssh2/1.10.0/lib/libssh2.a
    
    $ ls -l /usr/local/lib/libssh2.a
    lrwxr-xr-x  1 stephen  admin  38 Sep 27 11:18 /usr/local/lib/libssh2.a -> ../Cellar/libssh2/1.10.0/lib/libssh2.a
    

    In tests below I am now doing this to setup for building:

    git clone [email protected]:gitx/objective-git.git
    cd objective-git
    git submodule update --init --recursive
    script/bootstrap && script/update_libgit2
    

    Then tried with and without test in the xcodebuild invocation:

    xcodebuild -workspace ObjectiveGitFramework.xcworkspace -scheme "ObjectiveGit Mac" test archive ARCHS="x86_64"
    

    Same error when building in xcode app:

    Undefined symbols for architecture x86_64:
      "_EVP_PKEY_id", referenced from:
          __libssh2_ed25519_new_private_frommemory in libssh2.a(openssl.o)
          __libssh2_pub_priv_keyfile in libssh2.a(openssl.o)
          __libssh2_pub_priv_keyfilememory in libssh2.a(openssl.o)
    ld: symbol(s) not found for architecture x86_64
    
    xcodebuild -workspace ObjectiveGitFramework.xcworkspace -scheme "ObjectiveGit Mac" archive ARCHS="x86_64"
    

    Different (but probably related??):

    ** ARCHIVE FAILED **
    
    
    The following build commands failed:
    	Ld /Users/stephen/Library/Developer/Xcode/DerivedData/ObjectiveGitFramework-fyaphaesxegukpfgkwopelgpztry/Build/Intermediates.noindex/ArchiveIntermediates/ObjectiveGit\ Mac/IntermediateBuildFilesPath/UninstalledProducts/macosx/ObjectiveGit.framework/Versions/A/ObjectiveGit normal (in target 'ObjectiveGit-Mac' from project 'ObjectiveGitFramework')
    
  12. hannesa2 commented on Feb 11, 2022

    @hannesa2

    And do you have these files ? find . -name "libss*.a" | xargs ls -la

    image

  13. stepheneb commented on Feb 11, 2022

    @stepheneb
    Author

    I only seem to have: ./External/libssh2.a

    [objective-git  (master)]$ find . -name "libss*.a" | xargs ls -la
    -r--r--r--  1 stephen  staff  295272 Feb 11 12:24 ./External/libssh2.a
    [objective-git ruby-2.7.5 (master)]$ 
    
  14. hannesa2 commented on Feb 12, 2022

    @hannesa2

    Ahh sorry, this was a pointer into the wrong direction. It was a leftover from an other try. You don't need it
    This is how it looks like on my side
    image

    I tried it again in a new directory, without test (don't work for locally for arm64) and for arm64 (CI does it with x86_64)

    git clone [email protected]:gitx/objective-git.git
    cd objective-git
    git submodule update --init --recursive
    script/bootstrap && script/update_libgit2
    xcodebuild -workspace ObjectiveGitFramework.xcworkspace -scheme "ObjectiveGit Mac" archive ARCHS="arm64" | tee outputARM64.log`
    

    image

    For me it looks like the issue is somehow related outside of the repo ? brew ?

    Please can you share your output outputARM64.log to be able todo a file compare.

  15. stepheneb commented on Feb 12, 2022

    @stepheneb
    Author

    I've attached outputARM64.log. The build seems to have completed successfully. Building with ARCHS="x86_64" still fails as it did before.

    cd ..
    rm -rf objective-git
    git clone [email protected]:gitx/objective-git.git && cd objective-git
    git submodule update --init --recursive
    script/bootstrap && script/update_libgit2
    xcodebuild -workspace ObjectiveGitFramework.xcworkspace -scheme "ObjectiveGit Mac" archive ARCHS="arm64" | tee outputARM64.log
    

    outputARM64.log

    FYI: here's what's in ./External:

    $ tree -L 1 External/
    External/
    |-- libextobjc
    |-- libgit2
    |-- libgit2.a
    |-- libssh2
    |-- libssh2.a
    `-- openssl
    
  16. hannesa2 commented on Feb 12, 2022

    @hannesa2

    Hmm, I guess you need to run
    xcodebuild -workspace ObjectiveGitFramework.xcworkspace -scheme "ObjectiveGit Mac" archive ARCHS="x86_64" | tee outputx86_64.log

    or do you own an Apple Silicon ?

  17. stepheneb commented on Feb 12, 2022

    @stepheneb
    Author

    Don't have a newer mac.

    Here's the ARCHS="x86_64" log: outputx86_64.log

  18. hannesa2 commented on Feb 12, 2022

    @hannesa2

    I see this as a probably major issue
    image

    /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib: file: ../libgit2.a(auth_negotiate.c.o) has no symbols
    /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib: file: ../libgit2.a(winhttp.c.o) has no symbols
    /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib: file: ../libgit2.a(auth_negotiate.c.o) has no symbols
    /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib: file: ../libgit2.a(winhttp.c.o) has no symbols
    

    Which ends into this finally

    ld: warning: object file (External/libssh2.a(crypt.o)) was built for newer macOS version (11.0) than being linked (10.9)
    ld: warning: object file (External/libssh2.a(blowfish.o)) was built for newer macOS version (11.0) than being linked (10.9)
    Undefined symbols for architecture x86_64:
      "_EVP_PKEY_id", referenced from:
          __libssh2_ed25519_new_private_frommemory in libssh2.a(openssl.o)
          __libssh2_pub_priv_keyfile in libssh2.a(openssl.o)
          __libssh2_pub_priv_keyfilememory in libssh2.a(openssl.o)
    ld: symbol(s) not found for architecture x86_64
    clang: error: linker command failed with exit code 1 (use -v to see invocation)
    

    The big question is: Why do your objects have no symbols ?
    It's only related to your local machine, because CI can build and link it

  19. stepheneb commented on Feb 12, 2022

    @stepheneb
    Author

    Thanks for all the help.

    Do you have an x86_64 mac? If so can you attach a log from your build that is successful.

    Does ./External/libgit2.a in your build dir have symbols for auth_negotiate and winhttp?

    $ nm -gC ./External/libgit2.a | grep auth_negotiate
    ./External/libgit2.a:auth_negotiate.c.o: no symbols
    ./External/libgit2.a(auth_negotiate.c.o):
    ./External/libgit2.a:winhttp.c.o: no symbols
    

    I also noticed in the last clang invocation which generates the Undefined symbols for architecture x86_64: "_EVP_PKEY_id" error a nonexistent directory is included.

    ld: warning: directory not found for option '-L/Users/stephen/dev/macos/objgit/objective-git/External/build/lib'
    
  20. hannesa2 commented on Feb 12, 2022

    @hannesa2

    arm64

    image

  21. hannesa2 commented on Feb 12, 2022

    @hannesa2

    local x86

    (today I've access)

    image

    Unfortunately the same like on your local machine

    CI x86

    hannesa2#39

    image

    image

    Sorry, I don't understand why CI builds properly.

  22. hannesa2 commented on Feb 12, 2022

    @hannesa2

    Ci comes only with [email protected] only !
    image

    So I removed local
    brew remove openssl@3

    and now, it looks like different

    image

    This missing openssl directory is interesting ...

  23. hannesa2 commented on Feb 12, 2022

    @hannesa2

    I made it work locally ! Thank you, this ticket helped me to understand the problem, even gitx/gitx#239 works now.

    Btw, there is no reason to brew remove openssl@3 anymore

  24. stepheneb commented on Feb 12, 2022

    @stepheneb
    Author

    Just tried again from scratch and the objective-git build also works for me! Thanks for your hard work!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions