I download SDK from official site, and create new project with following commands:
cocos new foo -p com.foo.bar -l cpp -d .
So, new project foo
created and I enter its directory.
I know proj.win32
has solution files for visual studio prebuilt in it. But I want regenerate them from CMakeLists.txt
at root project directory.
So I mkdir -p cmake-out/vs2012
, enter directory , and cmake -G "Visual Studio 11 2012" ../../
.
Everything's fine, solution files are built by cmake, so I rebuilt whole solution in visual studio.
Compilation all passed*, but final link process is fail because following errors:
4>cocos2d.lib(CCConsole.obj) : error LNK2019: unresolved external symbol '___WSAFDIsSet@8' referenced in function '"protected: void __thiscall cocos2d::Console::loop(void)" (?loop@Console@cocos2d@@IAEXXZ)'
4>cocos2d.lib(CCConsole.obj) : error LNK2019: unresolved external symbol '__imp__accept@12' referenced in function '"protected: void __thiscall cocos2d::Console::addClient(void)" (?addClient@Console@cocos2d@@IAEXXZ)'
4>cocos2d.lib(CCConsole.obj) : error LNK2019: unresolved external symbol '__imp__bind@12' referenced in function '"public: bool __thiscall cocos2d::Console::listenOnTCP(int)" (?listenOnTCP@Console@cocos2d@@QAE_NH@Z)'
4>cocos2d.lib(CCConsole.obj) : error LNK2019: unresolved external symbol '__imp__closesocket@4' referenced in function '"protected: void __thiscall cocos2d::Console::commandExit(int,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (?commandExit@Console@cocos2d@@IAEXHABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z)'
4>cocos2d.lib(CCConsole.obj) : error LNK2019: unresolved external symbol '__imp__ioctlsocket@12' referenced in function '"protected: void __thiscall cocos2d::Console::loop(void)" (?loop@Console@cocos2d@@IAEXXZ)'
4>cocos2d.lib(CCConsole.obj) : error LNK2019: unresolved external symbol '__imp__listen@8' referenced in function '"public: bool __thiscall cocos2d::Console::listenOnTCP(int)" (?listenOnTCP@Console@cocos2d@@QAE_NH@Z)'
4>cocos2d.lib(CCConsole.obj) : error LNK2019: unresolved external symbol '__imp__ntohs@4' referenced in function '"public: bool __thiscall cocos2d::Console::listenOnTCP(int)" (?listenOnTCP@Console@cocos2d@@QAE_NH@Z)'
4>cocos2d.lib(CCConsole.obj) : error LNK2019: unresolved external symbol '__imp__recv@16' referenced in function '"protected: void __thiscall cocos2d::Console::commandUpload(int)" (?commandUpload@Console@cocos2d@@IAEXH@Z)'
4>cocos2d.lib(CCConsole.obj) : error LNK2019: unresolved external symbol '__imp__select@20' referenced in function '"protected: void __thiscall cocos2d::Console::loop(void)" (?loop@Console@cocos2d@@IAEXXZ)'
4>cocos2d.lib(CCConsole.obj) : error LNK2019: unresolved external symbol '__imp__send@16' referenced in function '"public: void __thiscall <lambda_18a69eabc233d9cfc5fb2fb65c07cfe6>::operator()(void)const " (??R<lambda_18a69eabc233d9cfc5fb2fb65c07cfe6>@@QBEXXZ)'
4>cocos2d.lib(CCConsole.obj) : error LNK2019: unresolved external symbol '__imp__setsockopt@20' referenced in function '"public: bool __thiscall cocos2d::Console::listenOnTCP(int)" (?listenOnTCP@Console@cocos2d@@QAE_NH@Z)'
4>cocos2d.lib(CCConsole.obj) : error LNK2019: unresolved external symbol '__imp__socket@12' referenced in function '"public: bool __thiscall cocos2d::Console::listenOnTCP(int)" (?listenOnTCP@Console@cocos2d@@QAE_NH@Z)'
4>cocos2d.lib(CCConsole.obj) : error LNK2019: unresolved external symbol '__imp__WSAStartup@8' referenced in function '"public: bool __thiscall cocos2d::Console::listenOnTCP(int)" (?listenOnTCP@Console@cocos2d@@QAE_NH@Z)'
4>cocos2d.lib(CCConsole.obj) : error LNK2019: unresolved external symbol '__imp__WSACleanup@0' referenced in function '"protected: void __thiscall cocos2d::Console::loop(void)" (?loop@Console@cocos2d@@IAEXXZ)'
4>cocos2d.lib(CCConsole.obj) : error LNK2019: unresolved external symbol '__imp__getaddrinfo@16' referenced in function '"public: bool __thiscall cocos2d::Console::listenOnTCP(int)" (?listenOnTCP@Console@cocos2d@@QAE_NH@Z)'
4>cocos2d.lib(CCConsole.obj) : error LNK2019: unresolved external symbol '__imp__freeaddrinfo@4' referenced in function '"public: bool __thiscall cocos2d::Console::listenOnTCP(int)" (?listenOnTCP@Console@cocos2d@@QAE_NH@Z)'
4>cocos2d.lib(CCConsole.obj) : error LNK2019: unresolved external symbol '_inet_ntop@16' referenced in function '"public: bool __thiscall cocos2d::Console::listenOnTCP(int)" (?listenOnTCP@Console@cocos2d@@QAE_NH@Z)'
Original solution have no errors, I know. But visual studio solution files should be able to generated by cmake, What problem with CMakeLists.txt
?
*: In fact, include directories settings aren't correct, so I patch them:
include_directories(
${CMAKE_CURRENT_SOURCE_DIR}/Classes
${COCOS2D_ROOT}
${COCOS2D_ROOT}/cocos
${COCOS2D_ROOT}/cocos/audio/include
${COCOS2D_ROOT}/cocos/2d
${COCOS2D_ROOT}/cocos/2d/renderer
${COCOS2D_ROOT}/cocos/2d/platform
${COCOS2D_ROOT}/cocos/2d/platform/desktop
${COCOS2D_ROOT}/cocos/2d/platform/win32
${COCOS2D_ROOT}/cocos/base
with them:
include_directories(
${CMAKE_CURRENT_SOURCE_DIR}/Classes
${COCOS2D_ROOT}
${COCOS2D_ROOT}/cocos
${COCOS2D_ROOT}/cocos/audio/include
${COCOS2D_ROOT}/cocos/2d
${COCOS2D_ROOT}/cocos/renderer
${COCOS2D_ROOT}/cocos/platform
${COCOS2D_ROOT}/cocos/platform/desktop
${COCOS2D_ROOT}/cocos/platform/win32
${COCOS2D_ROOT}/cocos/base
Yes, renderer
,platform
... not in cocos/2d
path.
That's the only change I must do to the sources.