Cocos2d-x v4 C++ (Abort Error)

I’ve tried but didn’t work again.

Show me a current pic of the left side of your IDE.

resim_2021-05-03_184241
i guess you mean want to these

@sukruBeyy You need to follow the guide on how to create the Visual Studio project, because from the screenshots you posted, the problem is now obvious.

Firstly, do not use the project files in the proj.win32 folder. The fact that a VS solution file and project is still being created in there via the cocos ... CLI command is an issue, and one that should be fixed down the track in a future cocos2d-x release.

Secondly, do not put your resources in win32.proj\Resources. That is the incorrect folder. Your resources should be going into D:\Cocos2d-X-Projeler\FlappyBird_Replica\Resources.

Now, do not delete that proj.win32 folder, since it’s still required, and don’t change anything in it either.

In your case, this is what you need to do on the command line:

Type this:
cd D:\Cocos2d-X-Projeler\FlappyBird_Replica

You’ll be in D:\Cocos2d-X-Projeler\FlappyBird_Replica

Type these:

mkdir win32build
cd win32build

You’ll now be in D:\Cocos2d-X-Projeler\FlappyBird_Replica\win32build\

Type this:
cmake … -G"Visual Studio 16 2019" -Tv142 -A Win32

Now CMake would have created the Visual Studio project and solution files. Open up the solution file (*.sln) in D:\Cocos2d-X-Projeler\FlappyBird_Replica\win32build\ using Visual Studio.

There is more info here: https://github.com/cocos2d/cocos2d-x/tree/v4/cmake

1 Like

image

i fixed, when i changed this command line like this it’s fixed and working

image

I did everything but it’s still not working i don’t understand why did not working. I’m create new project and
i did everything you asked and import my classes in FlappyBird/Classes and import my images in FlappyBird/Resources/images. Do you have another idea about this ?

CMake is definitely not a mistake, and no, you don’t actually need to re-run cmake after every resource change if you make a minor update to your root CMakeLists.txt, but that isn’t the issue for this specific user (as you can see from above posts).

The minor update you need to make to the root CMakeLists.txt of your app was initially posted by CrazyHappyGame, and it was a brilliant change which simply links to your resources instead of adding copy commands to the Visual Studio project file:

Change this:

if(LINUX OR WINDOWS)
    set(APP_RES_DIR "$<TARGET_FILE_DIR:${APP_NAME}>/Resources")
    cocos_copy_target_res(${APP_NAME} COPY_TO ${APP_RES_DIR} FOLDERS ${GAME_RES_FOLDER})
endif()

To this:

if(LINUX OR WINDOWS)
    set(APP_RES_DIR "$<TARGET_FILE_DIR:${APP_NAME}>/Resources")
    add_custom_command(TARGET ${APP_NAME} PRE_BUILD COMMAND ${CMAKE_COMMAND} -E create_symlink ${GAME_RES_FOLDER} ${APP_RES_DIR})
endif()

Also, the resource copying was only an issue for Linux and Windows, so didn’t apply to Android or iOS/OS X.

Using CMake has meant significantly less time spent maintaining different platform builds, so give it a chance before you post personal opinions about stuff like this on an open forum, which serves no purpose but to confuse new users.

I can’t say that I’m happy to read this.

I feel like CMake is a great tool and technically designed to replace an IDE if you so wish. I do think that it has a learning curve and honestly there are always peices to learn so I don’t even feel super confident all the time with it.

This could be an option to get you started. But don’t use the 3.17.2 .zip, download the current source from GitHub. CMake isn’t required for 3.17.x.

Zip up your project (without the cocos2d folder to keep the archive small), and post it somewhere, because it’s really hard guessing what your problem is when you’re not giving much information about it besides screenshots.

1 Like

Hey, I use CMake everyday, so thats not an issue. Thing is, I am annoyed that cmake call is must after minor changes. o/w i use cmake for 3.17.2 as well for additional libs. But i never got lucky with 4.0
Will try again now.
@slackmoehrle
sry for those words, but that what i feel for 4.0

Are you sure? because i tried with xcode as well.
I remember if we add any new cpp/hpp/png then we need to call cmake which eventually create new xcode proj files (so again we need to set all proj settings again). Am i wrong?

For source files, yes, you do need to call cmake again, and that’s required for all platforms (just put the command in a script, and run that script). For resources, I’m not entirely sure, since I’ve just started working on the Xcode version of it, so I’ll find out soon.

As for the project settings in Xcode, you should be able to add all of them in CMakeLists.txt, like the provisioning settings, team ID etc, so you don’t have to re-enter them manually into the project each time, and that is exactly what I’m doing in my project. I haven’t yet come across something in the Xcode project that I couldn’t set in CMakeLists.txt.

I did run into one problem though with the latest CMake (3.20.2) when running it for Xcode, but that was easily fixed, and the PR for it has been submitted.

But what about additional libs? like if you are implementing Sign in with Apple, 3rd Party Ads framework, Custom C++ Frameworks. How those all can be handled from cmake?

@slackmoehrle Dude, we need 4.1 & 3.17.3

I asked the team about this and they aren’t going to make a new release quite yet. It’s best to pull from GitHub.

You mean something like this?

target_link_libraries(${APP_NAME} "-framework AuthenticationServices")

Assuming AuthenticationServices is the correct framework for the sign in with Apple support. I use target_link_library for all required frameworks, like for MediaPlayer:

target_link_libraries(${APP_NAME} "-framework MediaPlayer")

Couple of things :

  1. Suppose for Sign in with Apple, you need to goto Signing & Capabilities => + Capability => Search Sign in with Apple => Add
    I am just taking one example, same way we might need to add push-notification capabilities. So do we need to add all this everytime new xcode proj creates?

  2. In Build Settings => Framework/Header/Library search path is there, that need to edit for Ads/etc plugins so that can be handle from cmake?

  3. Sometimes Apple changes something on update and we manually need to edit few parameters in Build Settings, what about that? Can all those changes be done through cmake? For exm:
    Xcode 12.4 cocos 3.17.2 build error - #4 by antn9x

All that info will be in the CMake documentation. I haven’t had to mess with any of those fields yet, so don’t know what their names would be in the CMake config.

if you can give me the link then it will be great.

At last, If you can tell me,
What are the pros to this cmake implementation compare to 3.17.2 cmake implementation?

Oh I just meant the CMake documentation site has everything you would want to know, like this:
https://cmake.org/cmake/help/latest/prop_tgt/XCODE_ATTRIBUTE_an-attribute.html

If you mean between v4 and v3.17.2 of cocos2d-x, then I’m not sure that I understand what you are asking. CMake has nothing to do with cocos2d-x, besides the fact that 3.17.2 and 4.0 support it, and the only thing that does make a difference is the version of CMake you use, so it’s probably a good idea to use the latest version, which should have better support fort Xcode etc.

There are minor differences between the cocos2d-x 3.17.2 and 4.0 with regards to the stuff in cocos2d/cmake/Modules, but that has very little to do with Xcode support. You can add whatever you want in the CMakeLists.txt of your project.