next error is
1: error: cannot find -lcurl_imp
is there some modification in CMakeLists.txt according this?
next error is
1: error: cannot find -lcurl_imp
is there some modification in CMakeLists.txt according this?
Hmmmm, this error is new to me, let me find something…
I looked into FindCURL.cmake, there is only implementation for MSVC. So I guess, it must be the source of problem.
The strange thing is that I don’t have this problem, so maybe I have something installed that unintentionally fix this problem.
still wondering why there is these lines when creating cmakelists
– CURL add to include_dirs: C:/TDM-GCC-64/include
– CURL libs added to ‘cocos2d’: C:/TDM-GCC-64/lib/libcurl_imp.lib
although I have deleted it in FindCURL.cmake and the real file (libcurl_imp.lib)
@Levis
Can you post your last CMakeLists.txt? Because my CMakeLists.txt is still looking for .lib library.
Sorry in this moment I’m in another office, as soon as I return to my workstation I’ll find it and post it.
In some way we have to fix this problem
It’s okay, I got past curl problem, I just need to recompile the new CMakesLists.txt and error disappear.
Right now I’m facing this error
D:\mydir\cocos2d\cocos\platform\win32\CCFileUtils-win32.cpp:64: error: undefined reference to `_get_wpgmptr’
I don’t know how to fix it yet
Perfect!
Ok don’t worry for the getwpgmptr error, the fix is described here (thanks to @romsvm) : Trying to make CLion working with CMake and Cocos2DX
It’s awful I know but maybe some guru could help us with the Resources problem
Even if this problem is from mingw that doesn’t have _get_wpgmptr.
wow it’s really awful… is there no other way to fix this? So I have to type in my cocos2d-x project Resource’s folder in CCFileUtils-win32.cpp?
EDIT : I found this solution
I’m trying to modify the code now
Helped me a lot. But I also needed to install the following.
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-freetype mingw-w64-x86_64-mpg123 mingw-w64-x86_64-glew mingw-w64-x86_64-boost mingw-w64-x86_64-chipmunk mingw-w64-x86_64-libwebsockets mingw-w64-x86_64-libwebp
Also _pgmptr can be replaced with GetModuleFileNameW:
<<<
WCHAR *pUtf16ExePath = nullptr;
_get_wpgmptr(&pUtf16ExePath);
===
WCHAR pUtf16ExePath[MAX_PATH];
GetModuleFileNameW(NULL, pUtf16ExePath, MAX_PATH);
>>>
And to fix resources loading, you need to change:
<<<
s_resourcePath = convertPathFormatToUnixStyle(utf8ExeDir);
===
s_resourcePath = convertPathFormatToUnixStyle(utf8ExeDir) + "Resources/";
>>>
in cocos2d/cocos/platform/win32/CCFileUtils-win32.cpp.
Thank you for these other useful tips!
I almost done ! but i encount problem
[100%] Linking CXX executable bin\MyGame.exe
…/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
and I run
pacman -S mingw-w64-x86_64-cocos2d-x-git
it told me --> target not found
what can I do ?
thanks.
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?
Hello, this is my solution, works with cocos2d-x v3.9.
1. Install and setup cocos2d-x as descibed in guide
2. Install msys2 as described in http://msys2.github.io/
3. Install additional “MSYS” build packages (copy-paste in msys shell, and press enter):
pacman -S base-devel \ msys2-devel \ mingw-w64-i686-toolchain \ mingw-w64-x86_64-toolchain \ git \ mingw-w64-x86_64-gcc \ mingw-w64-x86_64-gdb \
4. Clone mingw-packages scripts repository:
git clone https://github.com/Alexpux/MINGW-packages.git
I create pull request to official repository, so i hope “cocos2dx-git” package will be avaliable from “pacman” soon
5. Go to cocos2dx-git package build script folder:
cd MINGW-packages/mingw-w64-cocos2dx-git/
6 Build package:
makepkg-mingw -sLf
7. Install package, in my case it named “mingw-w64-x86_64-cocos2d-x-git-r33416.d371ec2-1-any.pkg.tar.xz” (depends on version in package file, mingw-w64-x86_64-cocos2d-x-git-*.pkg.tar.xz will be placed in current folder) so need run command:
pacman -U mingw-w64-x86_64-cocos2d-x-git-r33416.d371ec2-1-any.pkg.tar.xz
8. You can close MSYS shell, no additional packages requered
9. Now you may open CLion and setup toolchain path (Settings > Build, Execution, Deployment) as describe in guide
10. Then you need edit CMakeLists.txt (only CMakeLists in root of project, don’t need edit cocos2d CMakeLists.txt or other). First add recast and bullet library dependences in CMakeLists.txt:
After string:
add_subdirectory(${COCOS2D_ROOT})
Add:
if(WIN32) add_subdirectory(${COCOS2D_ROOT}/external/bullet) add_subdirectory(${COCOS2D_ROOT}/external/recast) endif()
11. Then you need add tinyxml source path :
Replace
elseif ( WIN32 ) set(PLATFORM_SPECIFIC_SRC proj.win32/main.cpp ) set(PLATFORM_SPECIFIC_HEADERS proj.win32/main.h proj.win32/resource.h ) endif()
By:
elseif ( WIN32 ) set(PLATFORM_SPECIFIC_SRC proj.win32/main.cpp ${COCOS2D_ROOT}/external/tinyxml2/tinyxml2.h ) set(PLATFORM_SPECIFIC_HEADERS proj.win32/main.h proj.win32/resource.h ${COCOS2D_ROOT}/external/tinyxml2/tinyxml2.cpp ) endif()
12. If you try to build, you see some compilation errors. First error in cocos2d\cocos\ui\UIEditBox\UIEditBoxImpl-win32.cpp in function CWin32InputBox::DlgProc:
Need replace:
TIMERPROC lpTiTorFunc = [](HWND, UINT, UINT, DWORD) {
By:
TIMERPROC lpTimerFunc = [](HWND, UINT, UINT_PTR, DWORD) {
13. If you get error message while compiling “bullet” library:
Replace all error lines with:
reinterpret_cast<uint64_t>
By:
reinterpret_cast<uintptr_t>
And:
btCollisionObject** eaPtr = (btCollisionObject**)(taskDesc.m_mainMemoryPtr);
By:
btCollisionObject** eaPtr = reinterpret_cast<btCollisionObject**>(taskDesc.m_mainMemoryPtr);
14. Then in file cocos2d\cocos\platform\win32\CCFileUtils-win32.cpp in function _checkPath()
Replace:
WCHAR *pUtf16ExePath = nullptr; _get_wpgmptr(&pUtf16ExePath);
By:
WCHAR pUtf16ExePath[CC_MAX_PATH]; HMODULE hModule = GetModuleHandle(NULL); GetModuleFileName(hModule, pUtf16ExePath, (sizeof(pUtf16ExePath)));
15. To access to resource folder from app, you need edit CMakeLists.txt OR add line in AppDelegate.cpp in function AppDelegate::applicationDidFinishLaunching():
FileUtils::getInstance()->addSearchPath("Resources\\");
(VS copy resource in build folder, but in CMakeLists resource will be copied in Resources folder)
17. Build and run
Thank you for your contrib!!! Much appreciated!
it works, thanks.
is anybody know how to import sdkbox and his plugins (in case of android project)?
Could someone update this guide to latest Cocos2d-x-3.12 ?
Thanks
Here is an updated guide how to setup CLion devenv on Windows for Cocos2d-x v3.13.1
from here: http://repo.msys2.org/distrib/msys2-x86_64-latest.exe
Install it (c:\msys64\ - i will refer this path, if you choose another one - update paths correspondingly).
MSYS2
, and execute following commands, restarting it after each command:pacman -Sy --noconfirm pacman
pacman -Syu --noconfirm
pacman -Su --noconfirm
MSYS2 MinGW 64-bit
and paste following command (you can copy&paste all following commands at once):pacman -Sy --noconfirm --force \
git \
mingw-w64-x86_64-cmake \
mingw-w64-x86_64-toolchain \
mingw-w64-x86_64-gcc \
mingw-w64-x86_64-gdb \
mingw-w64-x86_64-libvorbis \
mingw-w64-x86_64-openal \
mingw-w64-x86_64-openssl \
mingw-w64-x86_64-glew \
mingw-w64-x86_64-glfw \
mingw-w64-x86_64-pkg-config \
mingw-w64-x86_64-freetype \
mingw-w64-x86_64-mpg123 \
mingw-w64-x86_64-glew \
mingw-w64-x86_64-libwebp \
mingw-w64-x86_64-libtiff \
mingw-w64-x86_64-libjpeg \
mingw-w64-x86_64-libpng \
mingw-w64-x86_64-curl \
mingw-w64-x86_64-zlib
mkdir $TMP/cocos2dx_installation
cd $TMP/cocos2dx_installation
git clone https://github.com/warmcat/libwebsockets.git libwebsockets
cd libwebsockets
git checkout v2.0-stable
mkdir _build
cd _build
cmake -DLWS_WITHOUT_TESTAPPS=ON -DLWS_USE_BUNDLED_ZLIB=OFF -G "MinGW Makefiles" ..
cmake -DLWS_WITHOUT_TESTAPPS=ON -DLWS_USE_BUNDLED_ZLIB=OFF -G "MinGW Makefiles" ..
mingw32-make
mingw32-make install DESTDIR=./install
mkdir /mingw64/lib/cmake/libwebsockets
cp ./install/Program\ Files\ \(x86\)/libwebsockets/lib/* /mingw64/lib
cp ./install/Program\ Files\ \(x86\)/libwebsockets/include/* /mingw64/include
cp ./install/Program\ Files\ \(x86\)/libwebsockets/bin/* /mingw64/bin
cp ./install/Program\ Files\ \(x86\)/libwebsockets/cmake/* /mingw64/lib/cmake
cp ./install/Program\ Files\ \(x86\)/libwebsockets/cmake/* /mingw64/lib/cmake/libwebsockets
cd ../..
git clone https://github.com/slembcke/Chipmunk2D.git Chipmunk2D
cd Chipmunk2D
git checkout tags/Chipmunk-7.0.1
sed -i "s/\#include <sys\/sysctl.h>//g" src/cpHastySpace.c
mkdir _build
cd _build
cmake -DBUILD_DEMOS=OFF -DBUILD_SHARED=ON -DBUILD_STATIC=ON -G "MinGW Makefiles" ..
cmake -DBUILD_DEMOS=OFF -DBUILD_SHARED=ON -DBUILD_STATIC=ON -G "MinGW Makefiles" ..
mingw32-make
mingw32-make install DESTDIR=./install
cp ./install/Program\ Files\ \(x86\)/chipmunk/lib/* /mingw64/lib
cp -r ./install/Program\ Files\ \(x86\)/chipmunk/include/* /mingw64/include
cp ./install/Program\ Files\ \(x86\)/chipmunk/bin/* /mingw64/bin
cd ../../..
rm -rf $TMP/cocos2dx_installation
exit
CMakeLists.txt
:set( USE_SOURCES_EXTERNAL ON CACHE BOOL "Use some libraries from cocos2dx externals" )
add_subdirectory(${COCOS2D_ROOT})
# this line already exists in your project
Set CLion MinGW location to: C:\msys64\mingw64
Set CLion CMake location to: C:\msys64\mingw64\bin\cmake.exe
This way you will have fully setup MinGW environment for cocos2dx + CLion.
P.S. If you want to use bullet+recast - update their sources according posts above.
Bonus
Disable default physics engine - Chipmunk
If you don’t want to use Chipmunk physics engine (for example you use bullet+recast or Box2D)
set( USE_BULLET OFF CACHE BOOL "Turn off Bullet (3d physics)" )
add_subdirectory(${COCOS2D_ROOT})
# this line already exists in your project
add_definitions(-DCC_USE_PHYSICS=0)
Disable 3D physics & path-finding for 2D-only game - Bullet+Recast
If you don’t want to use 3D physics & path-finding (for example 2D game) to shorten compile time:
set( USE_BULLET OFF CACHE BOOL "Turn off Bullet (3d physics)" )
set( USE_RECAST OFF CACHE BOOL "Turn off Recast (3d pathfinding)" )
add_subdirectory(${COCOS2D_ROOT})
# this line already exists in your project
Enable C++ physics engine - Box2D
If you want to use Box2D (don’t forget to disable Chipmunk if it’s not used):
SET( USE_BOX2D ON CACHE BOOL "Turn on Box2D for 2D physics" )
add_subdirectory(${COCOS2D_ROOT})
# this line already exists in your project
###Don’t forget to invalidate project after any changes to
CMakeLists.txt
in CLion.