"ccconsole.h, ccutf8.h error, expected a {"

Those errors in the screenshot are coming from some issue with your CMake generated project, being either missing files or resources.

When you run CMake, check for any warnings or errors. Go into \win32build\CMakeFiles\, and you’ll find the following files which you can open up and review for any problems:
CMakeError.log and CMakeOutput.log

If you are using the default CMakeLists.txt in the root of your game, and you add new resources (like graphics etc), then you need to go into the win32build folder, and delete CMakeLists.txt, then run the CMake command again to regenerate the Visual Studio solution files.

The alternative is to use a slightly modified CMakeLists.txt which no longer copies resources, but instead creates a symbolic link to them. The main benefit of this is that your Windows builds will be so much quicker (depending on how many resources you have).

Open up the root CMakeLists.txt in your game project folder, then scroll down to the bottom, where you’ll see this section:

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

Comment it out, and add this section instead:

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

(I can’t quite recall who originally posted this symbolic linking bit of CMake script, but it does really speed up development on Windows)

Just make sure you re-run CMake again. To make your life easier, add the following to a batch file, put it in your game project folder, and run it whenever you need to:

IF EXIST .\win32build\ GOTO STARTUPDATE
mkdir win32build
:STARTUPDATE
cd .\win32build
cmake .. -G"Visual Studio 16 2019" -Tv142 -A Win32
@REM cmake .. -G"Visual Studio 15 2017" -Tv141

Otherwise you can right-click on the “ZERO_CHECK” project when you have your solution loaded in Visual Studio, and build that specific project. It should also work.
image

1 Like

Actually this is a good tip. Perhaps i can use this as a tech tip

This forum is full of golden bits of info, but I think they just get buried over time. I’ve started adding them to a lightweight notes app that’s always running in the background, Tomboy Notes, just to save time searching for them.

if you are willing to share, I’ll create a post about all of them, we can pin it to our Knowledgebase category.

My CMake build has not generated any errors: This “{” problem appeared very arbitrarily. I reset my PC a few weeks ago and installed cocos2dx again, and everything worked, but a few days ago when I was working on one of my projects, this error appeared out of nowhere (the project I was working on already had hundreds of lines of code so it is not like this error appeared when I made a new project).

Can you please try this if you have the time: Go to this post, and download the test project. It’s for V4 of Cocos2d-x, and all it needs is for you to copy the cocos2d folder into it from one of your other projects. Run the VSUpdateCMake.bat file that’s in it, and open up the solution it creates in the win32build folder. Test that out.

If something is wrong with cocos2d-x on your PC, then this project should have the same issue. The project doesn’t show any errors when I compile it.

Since the project still gives me the same error, something has to be wrong with my cocos2dx installation.
I have reinstalled cocos2dx 2 times, but I think now I should try downloading the android SDK and NDK again, reinstalling CMake and possibly even reinstalling Python 2.7. I think there might be a problem with the NDK and SDK and CMake because I reset my PC, so I will tell you if I fixed this later.
Thanks anyways for the help :grinning:

Alright, nope. I reinstalled Python, I reconfigured the environment variables for Android, I have reinstalled CMake and reinstalled cocos2dx, this error is still occuring. I really do not know what to do and why this is happening.
How can an intellisense error pointing that a brace is missing be linked to anything?
I will try reinstalling visual studio at last but that is about it until I just give up and have to live with it.

What cocos2d-x version? VS 2019?

@lazarpuppet1 Use 3.17.2 version

I use Cocos2dx V4 and Visual Studio 2019.16

Switch to 3.17 please.

Do you use v3.17 yourself?

Of course. I also use v4. It depends on my needs.

Alright, I am so confused and concerned for my computer.
I installed cocos2dx v3.17.2
made the project
this error is still occurring, it is pointing to the SAME two files except the error message is a bit different,
but it is still pointing to the same two files and to the exact same lines in those files.
I am just going to go back to cocos2dx v4 and dismiss this error until it goes away.
in fact i might want to switch to Code::Blocks because Visual Studio and IntelliSense is so buggy.
If someone could please help I am really concerned.

Try Retarget Solution once, i think that will solve your problem.

How would I do that?

https://docs.cocos.com/cocos2d-x/manual/en/faq/

When I right click on the solution or any of my projects it does not give me the option to retarget
:c

So all this time I thought you had build errors, but you’ve been referring to IntelliSense. I just checked my projects, and the same IntelliSense errors appear (plus more), but I’ve simply been ignoring them. They don’t affect the code compilation, so what exactly is it that concerns you about this issue?

Unless you have a build error, there really isn’t anything to worry about.