0

When trying to build cocos2d-x v4 based project, 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

This can be fixed by adding the following to other linker flags:

-lz
-liconv

The problem is, that the XcodeProj file is autogenerated by cmake, so each time I generate the XcodeProj file using cmake, I need to manually add the above two lines to each of the "Other Linker Flags" settings....

Is there a way to do this automatically using CMake ?

I have looked at:

https://discuss.cocos2d-x.org/t/xcode-12-2-errors-when-ios-simulator-with-cocos2d-x-4-0/52203/4

https://github.com/cocos2d/cocos2d-x/issues/20608

In the first link, right at the end of the page R101 suggests adding that to the APPLE section in my CMakeLists.txt. I have done that, but it still will not build. What am I missing ? It is very tedious having to add -lz, -liconv flags manually each time.

Rahul Iyer
  • 19,924
  • 21
  • 96
  • 190
  • What do your `CMakeLists.txt` file look like? Have you added commands to look for (and link with) these libraries? – Some programmer dude Apr 18 '22 at 10:02
  • @Someprogrammerdude You can see the CMakeLists file here: https://www.dropbox.com/s/1pgcwm5voqjt8eq/CMakeLists.txt?dl=0 I have not used CMakeLists much so not sure how I would add commands to look for and link with these libraries. – Rahul Iyer Apr 18 '22 at 10:15
  • @Someprogrammerdude Any idea ? – Rahul Iyer Apr 19 '22 at 04:04
  • The shown `CMakeLists.txt` file seems to be for the Cocos2d-x project itself. Do you really use it for your own project? – Some programmer dude Apr 19 '22 at 05:49
  • @Someprogrammerdude That's the Cmakelists for a project created via the command line. It is intended to be used for your cocos2d-x project. – Rahul Iyer Apr 19 '22 at 07:06
  • Where is the `iconv` and `z` libraries listed (in all `CMakeLists.txt` files)? When you run the `cmake` command, what is its output? Does it contain any information about searching for any of the libraries? – Some programmer dude Apr 19 '22 at 07:13
  • @Someprogrammerdude That's a mystery dude. I've moved passed this by hacking around it so cannot investigate further at present as pressing matters have appeared.. But if you solve the mystery you will save countless others from hacking, and instead doing the right thing :) – Rahul Iyer Apr 19 '22 at 07:19

0 Answers0