Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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')

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
like image 603
Peter Andela Avatar asked Nov 15 '20 07:11

Peter Andela


2 Answers

you can fix this issue like this.

Other Linker Flags

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

good luck.

like image 190
ryan huh Avatar answered Sep 29 '22 07:09

ryan huh


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.

like image 25
Peter Andela Avatar answered Sep 29 '22 06:09

Peter Andela