Just to understand better, but in this way I have to create a CMakeLists.txt myself?
- Build the cocos2d-x with CMakeLists.txt from sources
- For you project (after ensure that cocos builds normally) you can use CMakeLists.txt provided by the generated project (but I donāt test thisā¦). I use my own CMakeLists.txt file (only for desktop platforms). I can share it by request.
I think Iāve made some progress, Iām reading the setup for QT creator that you linked
Installed MSYS2, with pacman installed:
mingw-w64-x86_64-cocos2d-x-git
mingw-w64-x86_64-qt-creator
mingw-w64-x86_64-cmake
Then I tried to open the Cocos Project with generated CMakeLists.txt and tried to build.
Iāve manually edited CMakelists for including all my .cpp and .h files:
set(GAME_SRC
Classes/AppDelegate.cpp
...
...
...
${PLATFORM_SPECIFIC_SRC}
)
set(GAME_HEADERS
Classes/AppDelegate.h
...
...
...
${PLATFORM_SPECIFIC_HEADERS}
)
I got some errors and fixed installing these:
mingw64/mingw-w64-x86_64-openal 1.16.0-2
mingw64/mingw-w64-x86_64-libvorbis 1.3.4-1
mingw64/mingw-w64-x86_64-glfw 3.1-1
Then I installed also the older version of chipmunk, because I got some errors in CCPhysicsBody.obj, manually downloading this:
mingw-w64-x86_64-chipmunk-6.2.1-1-any.pkg.tar.xz
Putting in MSYS2\var\cache\pacman\pkg and then installed with pacman -U
The compiling process continues for 70-80% of all cocos libs, some little warning but nothing special.
Now Iām stucked at this:
\myapp\cocos2d\cocos\platform\desktop\CCGLViewImpl-desktop.h:32: error: glfw3.h: No such file or directory
#include "glfw3.h"
This header file is located here:
\myapp\cocos2d\external\glfw3\include\win32
But I think that path was not found correctly.
Could be a problem in CMakeLists? Maybe some FindPackages functions doesnāt work properly.
From the guide written by @Martell he uses this custom: https://github.com/martell/cpp-template-default/blob/master/CMakeLists.txt
Itās quite different from the recent CMakeLists generated by cocos2dx 3.6, I donāt know if yours CMakeLists will go better, Iām just discovering this new world
BTW: I Forgot to say that Run CMake is ok, without errors.
Ok maybe Iāve done another progress.
When I run CMake Iāve not seen that pkg-config was not installed.
So I run:
pacman -S mingw64/mingw-w64-x86_64-pkg-config
And now it found GLFW3.
Now itās continuing building, Iāll keep you updatedā¦
-
Paths inside the
\myapp\cocos2d\external
folder should not be found. Itās because these libraries built with MSVC compiler. But you will use GCC compiler (mingw is a port of GCC that can generate windows executables) with other object files format. -
glfw3 should be found somewhere inside msys folders. If not, something is wrong, but I canāt say what specifically from the information you provided.
-
Cocos CMakeLists.txt files print the information about found libraries and paths when you run cmake tool. Can you see where its found GLFW (or not found)?
When I found some spare time (in a day or two), I try test cocos with MSYS2 again (I stop doing that after upgrading chipmunk pacakge).
Also I will try to prepare the sample project that we use in our team.
Ah, ok
Really thank you, maybe today Iāll try to finish this build
If so Iāll keep the community updated, writing the last steps for building also in CLionā¦ (ahhh long way )
Anyway really thank you for answering me.
Now the build seems ok, but during linking libs got this:
In my project Iām using rapidjson, but I donāt know if itās related to this or to other things, now Iāll try to rebuild all with an helloworld project maybe itās simpler and I donāt get this error.
Checked also if it was tinyxml2 prob, Iāve installed this:
mingw64/mingw-w64-x86_64-tinyxml2 2.2.0-1
Iāve tried also with a standard helloworld project, and got this:
Maybe something else Iāve forgot to install?
Tried to reinstall from zero all with msys2 and all libs i686, so not x64.
After all the build and compile I got the same identical error as shown above.
For now I give up, no other ideas
Hello. Iām newbie in cocos2d programming. I coming from as3 development and always used Intellij Idea IDE. And I became very happy when discovered that post about making cocos2d work with CLion. It is very sad for me that it doesnāt work yet, but you did good job. Iām very appreciated for all you have done.
Iām a newbie in C++ (and in English too ) and I found the following solution. You can include tinyxml2.cpp and tinyxml2.h in CMakeLists.txt
elseif ( WIN32 )
set(PLATFORM_SPECIFIC_SRC
proj.win32/main.cpp
Classes/tinyxml2.cpp
)
set(PLATFORM_SPECIFIC_HEADERS
proj.win32/main.h
Classes/tinyxml2.h
proj.win32/resource.h
)
endif()
mingw doesnāt have _get_wpgmptr
so you can do this in CCFileUtils-win32.cpp
static void _checkPath()
{
if (0 == s_resourcePath.length())
{
/*WCHAR *pUtf16ExePath = nullptr;
_get_wpgmptr(&pUtf16ExePath);
// We need only directory part without exe
WCHAR *pUtf16DirEnd = wcsrchr(pUtf16ExePath, L'\\');
char utf8ExeDir[CC_MAX_PATH] = { 0 };
int nNum = WideCharToMultiByte(CP_UTF8, 0, pUtf16ExePath, pUtf16DirEnd-pUtf16ExePath+1, utf8ExeDir, sizeof(utf8ExeDir), nullptr, nullptr);
s_resourcePath = convertPathFormatToUnixStyle(utf8ExeDir);*/
s_resourcePath = YOUR_PATH_TO_RESOURCES_DIR;
}
}
for Clion something like this āc:/Users/[USERNAME]/.clion10/system/cmake/generated/be9fed93/be9fed93/Debug/bin/Resources/ā
Itās awful, but it works for me.
Ok now Iāve solved almost all the problems.
Thanks @romsvm for the suggestion on tinyxml and resources!
Iāve only some little problems when I use resources in subfolders, maybe some other tweaks and I think it is ok.
I have written a little guide with all the steps, when this last step is resolved Iāll make a post, so also other ppl can compile with CLion!! YEAH!
Debug works too!!!
Updated step by step:
Need to resolve the Resources problem, really awful even if the solution proposed by @romsvm is working
I had try āLevisā 's method, I encount some problem:
ā¦msys64/mingw64/bin/ā¦/lib/gcc/x86_64-w64-mingw32/5.2.0/ā¦/ā¦/ā¦/ā¦/x86_64-w64-mingw32/bin/ld.exe: cannot find -lbullet
ā¦msys64/mingw64/bin/ā¦/lib/gcc/x86_64-w64-mingw32/5.2.0/ā¦/ā¦/ā¦/ā¦/x86_64-w64-mingw32/bin/ld.exe: cannot find -lrecast
how to fix it?
Iāve just updated Cocos v3.9 and I have tried a new compile, without success.
The same error like you.
Furthermore it seems that: mingw-w64-x86_64-cocos2d-x-git no longer exists
So I have to install more things:
pacman -S mingw-w64-x86_64-openal mingw-w64-x86_64-libvorbis mingw-w64-x86_64-glfw mingw-w64-x86_64-pkg-config mingw-w64-x86_64-glew mingw-w64-x86_64-mpg123 mingw-w64-x86_64-freetype mingw-w64-x86_64-libwebp mingw-w64-x86_64-tinyxml2 mingw-w64-x86_64-libwebsockets mingw-w64-x86_64-xxhash mingw-w64-x86_64-flatbuffers mingw-w64-x86_64-bullet
I have found only bullet library in mingw, but not recast.
Anyway the errors after linking are both for Bullet and Recast
Somebody have fixed this?
cocos2dproj.zip (7.3 KB)
Hey, Levis! I had uploaded my cmake config file. you can try it.
no need to install package that list below:
tinyxml2
xxhash
flatbuffers
bullet
the only two big problem by now I encount is that the libcocos2d.a library file and the target MyGame.exe file are too large, and building project is slow.
Thank you Iāll try soon the -fpermissive flag!
Hey Ricardo, Iāve tried using CMake make/ninja to build a fresh Cocos2d-x game project on OS X / Linux and never had success. Is there a suggested way to setup the cmake OS X/Linux build, or should I read through the replies here and try to sort it out? Iām currently getting the same 'āglfw3.hā file not found" error as the user here.
Simply put, are there any steps other than running cmake on the CMakeLists.txt and then building?