I'm trying to setup cocos2d-x (3.2, for windows development only) on windows 7 64bit using MSVC 2013 express. I've done so using provided "win32-msvc-2013-x86.cmd" bat file which calls cmake.
After getting through usual errors (machine has shift-jis locale, and microsoft c++ compiler refuses to recognize utf8 encoding unless it has a BOM, which leads to compilation errors in shift-jis locale if you put unicode string into file (cocos2d-x has a lot of them)), I've come to a point where single subproject (cpp-tests_PRE_BUILD) refuses to compile because it can't find sqlite3.h and sqlite3.lib.
So. Quick search through cocos2d-x project revealed that sqlite3.h is there,sqlite3.lib is missing, and sqlite3.h is stored in "external" subdirectory which is genersouly excluded from compilation (apparently it is android only).
Sqlite3 website has two vsix files (sqlite-winrt-3080704.vsix and sqlite-winrt81-3080704.vsix) which as I understand it, are supposed to install sqlite3.h and lib globally. I've downloaded and installed them both, even after installation sqlite3.h is not visible in global include path (even after restarting msvc), and sqlite3.h is not actually installed anywhere.
So... I could tear apart *.vsix file extract *.h and *.lib and put them into cocos2d-x subdirectory where compiler can find them, but what is the proper way to make it work?
Steps down below are only required if you're trying to compile cocos2d-x tests for version 3.2. Normal application use does not need them.
After many issues, I finally managed to get this thing compiled on vs2013 express.
Workarounds used:
In cocos2d_root/CMakeLists.txt Had to change
if(WIN32)
if(NOT MINGW)
link_directories(
${CMAKE_CURRENT_SOURCE_DIR}/external/jpeg/prebuilt/${PLATFORM_FOLDER}
${CMAKE_CURRENT_SOURCE_DIR}/external/tiff/prebuilt/${PLATFORM_FOLDER}
${CMAKE_CURRENT_SOURCE_DIR}/external/png/prebuilt/${PLATFORM_FOLDER}
${CMAKE_CURRENT_SOURCE_DIR}/external/freetype2/prebuilt/${PLATFORM_FOLDER}
${CMAKE_CURRENT_SOURCE_DIR}/external/curl/prebuilt/${PLATFORM_FOLDER}
${CMAKE_CURRENT_SOURCE_DIR}/external/${PLATFORM_FOLDER}-specific/icon/prebuilt
${CMAKE_CURRENT_SOURCE_DIR}/external/${PLATFORM_FOLDER}-specific/zlib/prebuilt
)
endif()
elseif(APPLE)
to
if(WIN32)
if(NOT MINGW)
link_directories(
${CMAKE_CURRENT_SOURCE_DIR}/external/jpeg/prebuilt/${PLATFORM_FOLDER}
${CMAKE_CURRENT_SOURCE_DIR}/external/tiff/prebuilt/${PLATFORM_FOLDER}
${CMAKE_CURRENT_SOURCE_DIR}/external/png/prebuilt/${PLATFORM_FOLDER}
${CMAKE_CURRENT_SOURCE_DIR}/external/freetype2/prebuilt/${PLATFORM_FOLDER}
${CMAKE_CURRENT_SOURCE_DIR}/external/curl/prebuilt/${PLATFORM_FOLDER}
${CMAKE_CURRENT_SOURCE_DIR}/external/${PLATFORM_FOLDER}-specific/icon/prebuilt
${CMAKE_CURRENT_SOURCE_DIR}/external/${PLATFORM_FOLDER}-specific/zlib/prebuilt
${CMAKE_CURRENT_SOURCE_DIR}/external/sqlite3/libraries/${PLATFORM_FOLDER}
${CMAKE_CURRENT_SOURCE_DIR}/external/websockets/prebuilt/${PLATFORM_FOLDER}
${CMAKE_CURRENT_SOURCE_DIR}/external/webp/prebuilt/${PLATFORM_FOLDER}
${CMAKE_CURRENT_SOURCE_DIR}/external/glfw3/prebuilt/${PLATFORM_FOLDER}
${CMAKE_CURRENT_SOURCE_DIR}/external/${PLATFORM_FOLDER}-specific/gles/prebuilt
)
endif()
elseif(APPLE)
Since otherwise multiple test solutions failed to link with gles, websockets, glfwv, sqlite3 and pretty much everything.
In cocos2d_root/tests/cpp-empty-test/CMakeLists.txt, had to change
if(WIN32 AND MSVC)
#get our resources
add_custom_command(TARGET ${APP_NAME} PRE_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_directory
${CMAKE_CURRENT_SOURCE_DIR}/Resources ${CMAKE_CURRENT_BINARY_DIR})
#get our dlls
add_custom_command(TARGET ${APP_NAME} PRE_BUILD
COMMAND ${CMAKE_COMMAND} -E copy
${CMAKE_CURRENT_SOURCE_DIR}/../../../external/win32-specific/gles/prebuilt/glew32.dll
${CMAKE_CURRENT_BINARY_DIR})
add_custom_command(TARGET ${APP_NAME} PRE_BUILD
COMMAND ${CMAKE_COMMAND} -E copy
${CMAKE_CURRENT_SOURCE_DIR}/../../../external/win32-specific/zlib/prebuilt/zlib1.dll
${CMAKE_CURRENT_BINARY_DIR}/Debug)
#Visual Studio Defaults to wrong type
set_target_properties(${APP_NAME} PROPERTIES LINK_FLAGS_DEBUG "/SUBSYSTEM:WINDOWS")
set_target_properties(${APP_NAME} PROPERTIES LINK_FLAGS_RELEASE "/SUBSYSTEM:WINDOWS")
else()
to
if(WIN32 AND MSVC)
#get our resources
add_custom_command(TARGET ${APP_NAME} PRE_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_directory
${CMAKE_CURRENT_SOURCE_DIR}/Resources ${CMAKE_CURRENT_BINARY_DIR})
#get our dlls
add_custom_command(TARGET ${APP_NAME} PRE_BUILD
COMMAND ${CMAKE_COMMAND} -E copy
${CMAKE_CURRENT_SOURCE_DIR}/../../external/win32-specific/gles/prebuilt/glew32.dll
${CMAKE_CURRENT_BINARY_DIR})
add_custom_command(TARGET ${APP_NAME} PRE_BUILD
COMMAND ${CMAKE_COMMAND} -E copy
${CMAKE_CURRENT_SOURCE_DIR}/../../external/win32-specific/zlib/prebuilt/zlib1.dll
${CMAKE_CURRENT_BINARY_DIR}/Debug)
#Visual Studio Defaults to wrong type
set_target_properties(${APP_NAME} PROPERTIES LINK_FLAGS_DEBUG "/SUBSYSTEM:WINDOWS")
set_target_properties(${APP_NAME} PROPERTIES LINK_FLAGS_RELEASE "/SUBSYSTEM:WINDOWS")
else()
Because ../../../external points outside of project directory and there's nothing in there.
In both cpp-tests and cpp-tests-empty, had to manually add ws2_32 as ifdef.
cpp-tests/CMakeLists.txt:
if(WIN32 AND MSVC)
target_link_libraries(${APP_NAME}
spine
cocostudio
cocosbuilder
extensions
audio
cocos2d
box2d
ws2_32
)
else()
target_link_libraries(${APP_NAME}
spine
cocostudio
cocosbuilder
extensions
audio
cocos2d
box2d
)
endif()
cpp-empty-test/CMakeLists.txt
if(WIN32 AND MSVC)
target_link_libraries(${APP_NAME} audio cocos2d ws2_32)
else()
target_link_libraries(${APP_NAME} audio cocos2d)
endif()
Because otherwise I kept getting unresolved externals to WSA functions
In cpp-tests/CMakeLists.txt had to add WIN32 marker to add_executable, because otherwise compiler didn't see tWinMainStartup.
if(WIN32 AND MSVC)
# add the executable
add_executable(${APP_NAME} WIN32
${SAMPLE_SRC}
)
else()
# add the executable
add_executable(${APP_NAME}
${SAMPLE_SRC}
)
endif()
Had to add utf8 BOM marker to multiple files because Microsoft compiler can't recognize utf8 without them, and in shift-jis locale rogue character in comment section can cause compile error elsewhere.
Also I'm getting tons of warnings regarding conflicting crt libraries, hopefully they're related to sqlite3 and glew being precompiled.
Overall I'm fairly disappointed with lack of responses here and amount of compiler errors. Wasn't it supposed to be simple to install 2d engine?