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')
Asked Answered
S

4

7

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
Streamer answered 15/11, 2020 at 7:45 Comment(3)
What solution did you use finally?Incognito
I still use the first answer because i use cmake to build the apps (cmake is doing the same). If you only have one or two project you can use the other answers.Streamer
Setting libz each time is tedious, did you find a solution using CMake ?Incognito
S
6

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.

Streamer answered 16/11, 2020 at 15:16 Comment(3)
This is more like a hack. We need a proper solution to this problem. Have you tried installing the libraries using a package manager like Homebrew? Here are the links: formulae.brew.sh/formula/libiconv and formulae.brew.sh/formula/zlibCorpulence
This doesn't seem to work by itself. Was there anything else you edited ? I get a bunch of errors when I try this....Incognito
Here is what I did, instead of ${ZLIB}, I just did -lz, and instead of ${ICONVLIB} did -liconvIncognito
C
6

you can fix this issue like this.

Other Linker Flags

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

good luck.

Crashaw answered 11/3, 2021 at 13:55 Comment(1)
Is there a way to do this in cmake ?Incognito
L
3

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

Ludly answered 15/11, 2020 at 13:50 Comment(2)
I removed them from build settings (other link flags) and added them to build phases. This manual solution works, thanks for that. But how can i do that with cmake?Streamer
you can refer in the {your_project_name}/cocos2d/cmake/Modules/CocosConfigDepend.cmakeLudly
H
2

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

Horoscopy answered 2/11, 2021 at 8:14 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.