Cocos2d-x 4.0 app build no longer works after upgrade to macOS Big Sur 11.01 (error: no such file or directory: '/usr/lib/libz.dylib')

Viewed 2896

After upgrade to macOS Big Sur 11.01 i get the following error:

clang: error: no such file or directory: '/usr/lib/libz.dylib' clang: error: no such file or directory: '/usr/lib/libiconv.dylib' Command Ld failed with a nonzero exit code

How to reproduce: make new cocos2d-x project using:

  • cocos -n -d dirname -l cpp
  • cd dirname/MyCppGame
  • mkdir build-iphone
  • cd build-iphone
  • cmake .. -GXcode -DCMAKE_SYSTEM_NAME=iOS -DCMAKE_OSX_SYSROOT=iphoneos

Open the generated xcode project (change bundle identifier) and build

Versions:

  • macOS Big sur 11.01
  • CMake 3.18 or CMake 3.19.0-rc3
  • cocos2d-x v4.0
  • Xcode 12.2
4 Answers

you can fix this issue like this.

Other Linker Flags

libz.dylib => -lz
libiconv.dylib => -liconv

good luck.

I changed the file: 'CocosConfigDepend.cmake' in cmake/modules/ of the cocos2d-x v4.0 library.

    elseif(IOS)
        # Locate system libraries on iOS
        find_library(UIKIT_LIBRARY UIKit)
        find_library(OPENGLES_LIBRARY OpenGLES)
        find_library(CORE_MOTION_LIBRARY CoreMotion)
        find_library(AVKIT_LIBRARY AVKit)
        find_library(CORE_MEDIA_LIBRARY CoreMedia)
        find_library(CORE_TEXT_LIBRARY CoreText)
        find_library(SECURITY_LIBRARY Security)
        find_library(CORE_GRAPHICS_LIBRARY CoreGraphics)
        find_library(AV_FOUNDATION_LIBRARY AVFoundation)
        find_library(WEBKIT_LIBRARY WebKit)
   
        find_library(ZLIB z)
        find_library(ICONVLIB iconv)

        list(APPEND PLATFORM_SPECIFIC_LIBS
             ${UIKIT_LIBRARY}
             ${OPENGLES_LIBRARY}
             ${CORE_MOTION_LIBRARY}
             ${AVKIT_LIBRARY}
             ${CORE_MEDIA_LIBRARY}
             ${CORE_TEXT_LIBRARY}
             ${SECURITY_LIBRARY}
             ${CORE_GRAPHICS_LIBRARY}
             ${AV_FOUNDATION_LIBRARY}
             ${WEBKIT_LIBRARY}
             ${COCOS_APPLE_LIBS}
             ${ZLIB}
             ${ICONVLIB}
             #"/usr/lib/libz.dylib"
             #"/usr/lib/libiconv.dylib"
             )
    endif()

Added the ZLIB and ICONVLIB, and removed full path rows.

I have checked in the folder /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/lib

the files libz.dylib and libiconv.dylib doesn't exist. I think you should use the files libz.tbd and libiconv.tbd

Project/Build Settings/Other Linker Flags

can build setting find linking and replace

step1

/usr/lib/libz.dylib

replace

/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/usr/lib/libiconv.dylib

step2

/usr/lib/libiconv.dylib

replace

/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/usr/lib/libz.dylib

Related