Win7 + vs2012 + cocos2d-x2.2 Configuration development environment

Source: Internet
Author: User

Starting yesterday to learn cocos2d-x, first of all must be on your own computer to configure the development environment. Yesterday toss a day, the following will be encountered in their own problems and solutions to share with you.  Most of the problems I have encountered, I have met .... 1. Install vs2012 (many online, find a key to crack, and finally attach the key)
2. Download the cocos2d-x-2.2.5 from the official website and unzip it to a specific disk or folder.
My path is: G:\Cocos2d-x.
Website address: Http://www.cocos2d-x.org/download
3. Under G:\Cocos2d-x\cocos2d-x-2.2.5\ path, find Build-win32.bat and run, will pop up console command window, time is very long, suggest this time to do something else.
If this is not possible, you can first open the Cocos2d-win32.vc2012.sln solution, set Testcpp as the startup item, and then compile debugging, which is slow. Run Build-win32.bat after the effect is running, try again. Testcpp Run Result: If Hellocpp is the startup item, the effect is as follows:
After the Build-win32.bat runs, copy the Msvn folder with Installwizardforvs2012.js to the G:\Cocos2d-x\cocos2d-x-2.2.5\template\ path, Double-click to run the Installwizardforvs2012.js file (the Msvn folder will be attached at the end). JS file Run Success information:
This is done to allow vs2012 to have templates for cocos2d-x projects, to make it easier for users to create projects, or to take advantage of Create_ in G:\Cocos2d-x\cocos2d-x-2.2.5\tools\project-creator folders project.py file to produce the project, specifically how to do, this later.
Another way is: the use of the old version of the Install-templates-msvc.bat file (last attached), but the Msvn folder still have to copy, this time without running JS file, directly run the Install-templates-msvc.bat file can be, this execution speed quickly ~
4. Now open vs2012, you can see the template options for COCOS2D-WIN32 application Visual C + + in the templates for creating your project. Such as:

After the project is created, the compilation runs, will not find the wrong xxx (if there is no error ...). So congratulations, you don't have to look at the back ~)
5. For operation error Handling: (1) very silly method, but very straightforward, and project creation path is arbitrary. Copy the four files under the G:\Cocos2d-x\cocos2d-x-2.2.5 path cocos2dx,cocosdenshion,extensions,external to the root of the project you created. Then copy the DLL files that were generated before the G:\Cocos2d-x\cocos2d-x-2.2.5\Debug.win32 path and the Lib files to the Debug.win32 directory of your project (recommended: Right-click, select " Type "to avoid omission). Try again, you should be able to run, if not, you can restart vs test.
(2) A little trouble, but a little better than the above, and do not have to copy things every time (these files are a bit large), the disadvantage is that the project must be created under the G:\Cocos2d-x\cocos2d-x-2.2.5 (because four files are not copied). Sort the files under the G:\Cocos2d-x\cocos2d-x-2.2.5\Debug.win32\ path by type and copy the DLL files under the folder to the C:\Windows\System32 (or system) folder ; Copy all lib files to D:\Program files (x86) \microsoft The Visual Studio 11.0\vc\lib folder (VS2012 installation path varies from person to person). This time to run directly, should be error: Then proceed: Enter project, right-click Properties---Configuration properties The default additional Include directory list is as shown: we can click the "macro (M)" button to see the value of SolutionDir: Where Demo_fr is the name of my project, so there are no folders in the attached directory at all. This is how the method (1) solves the problem by directly copying these folders. Here we can also change the value inside to achieve the same effect. Method A: Direct point. Add or modify the path to these folders directly in the directory list: G:\COCOS2D-X\COCOS2D-X-2.2.52\COCOS2D-X-2.2.2\COCOS2DX
G:\Cocos2d-x\cocos2d-x-2.2.52\cocos2d-x-2.2.2\cocos2dx\include;
G:\Cocos2d-x\cocos2d-x-2.2.52\cocos2d-x-2.2.2\cocos2dx\kazmath\include;
G:\Cocos2d-x\cocos2d-x-2.2.52\cocos2d-x-2.2.2\cocos2dx\platform\win32;
G:\Cocos2d-x\cocos2d-x-2.2.52\cocos2d-x-2.2.2\cocos2dx\platform\third_party\win32;
G:\Cocos2d-x\cocos2d-x-2.2.52\cocos2d-x-2.2.2\cocos2dx\platform\third_party\win32\OGLES;
G:\Cocos2d-x\cocos2d-x-2.2.52\cocos2d-x-2.2.2\external;
G:\Cocos2d-x\cocos2d-x-2.2.52\cocos2d-x-2.2.2\CocosDenshion\include; method B: By customizing the way the system variables are. Right-click Desktop, select Properties, advanced system settings, environment variables, and then select NEW: Variable name in the system variable to define one yourself. Then the value of the variable is the path of our cocos2d-x. See:  Note that the "\" at the back of the variable value is best added, otherwise you have to hit it in the list of directories (as in SolutionDir's value, the last side is "\"). Then, click "OK", you have to click three times ... Then in the attachment contains directory list to change SolutionDir to our own variable name, to avoid a series of copy paste   This time you can see the "macro" also appears in the Cocosdir, and its value is you set before. Click "OK", then run the test, should be able to run, if not, you can restart vs test. (3) An individual is satisfied with the method. Avoids the modification of each of the previous two methods. One modification, lifelong benefit. The prerequisite is to have the Msvc file mentioned earlier. Open the Default.js file under the G:\Cocos2d-x\cocos2d-x-2.2.5\template\msvc\CCAppWiz.win32\Scripts\1033 path. Replace all $ (SolutionDir) (shortcut key ctrl+h) with the COCOS2DX path on the current computer (my is:g:\cocos2d-x\cocos2d-x-2.2.5\  ). Alternatively, you can use the method (2) to customize the way a value is a system variable of the COCOS2DX path, and then replace $ (SolutionDir) with $ (cocosdir), so that it is more advantageous to ensure the JS format, but also more tall, and later if the path of the COCOS2DX is modified , you can modify the system variables as well. After the modification, save, re-run Install-templates-msvc.bat (don't worry, execution speed, or directly execute JS file to try ~). If the above operation is correct, this time to open vs, create a COCOS2DX project template, you will find the attachment contains a list of directories formally our modified $ (cocosdir), is not very happy, removed from the cumbersome operation later. To create a project on any path, remember to sort the files under the G:\Cocos2d-x\cocos2d-x-2.2.5\Debug.win32\ path by type,Files are copied to the C:\Windows\System32 (or system) folder; Copy all lib files to D:\Program files (x86) \microsoft Visual Studio 11.0\vc\ Lib folder (the VS2012 installation path varies from person to person). Direct compile Run ~ There is the "Hello World" we expect:
The previous method for creating a project in Python is mentioned, so here's a quick way to say:
(1) First download install python:http://www.python.org/download/ I downloaded the python-2.7.8.msi, then install, I installed in the D drive, after the installation of D will appear Python27 folder (if it is cocos2d-x2.2 version, do not next 3.0 python, Since the Python syntax before 3.0 is: print ' Hello ', and 3.0 starts with: print (' Hello '), with 3.0 later after the creation of the version will be error). (2) Then is the configuration environment variable where configuration, the article also mentions, here does not repeat. D:\Python27 can be added directly behind path, in the middle in English ";" Semicolon (be careful not to lose into the Chinese semicolon ";") to separate it, or create another variable, and then add the variable behind path (more convenient for later modification). (3) Test if Python is installed successfully win key + R--Input cmd--ok (or direct enter), enterpython to see if the console is recognized. If you enterpython operation, you can either enter exit () or close the console directly. Open the console and enter the create_project.py directory:
CD G:\Cocos2d-x\cocos2d-x-2.2.5\tools\project-creator
If after the CD, the directory character is not under G:\Cocos2d-x\cocos2d-x-2.2.5\tools\project-creator, then perform G: once, make sure the Operation directory under Project-creator and then execute the following command:
Python create_project.py-project firstdemo-package com.cocos2dx.demo-language cpp
Where: Firstdemo is your project name, Com.cocos2dx.demo is your package name, starting with COM, using the three-level directory way.
Normally, then in G:\Cocos2d-x\cocos2d-x-2.2.5\projects, you can see the project you created.
If you don't want to create a project every time you enter a command, you can write a simple batch bat file to create the project automatically. Put in the G:\Cocos2d-x\cocos2d-x-2.2.5\tools\project-creator\ directory, and then directly double-click to run.
Last attached download link: vs2012 key: http://download.csdn.net/detail/shuideyidi/7729039 msvn:http://download.csdn.net/detail/ shuideyidi/7728565 installation template for Install-templates-msvc.bat files: http://download.csdn.net/detail/shuideyidi/7729155 Create a project BAT file with Pyhton: http://download.csdn.net/detail/shuideyidi/7729109 python-2.7.8:http://pan.baidu.com/s/ 1dd1tnal PYTHON-3.4.1:HTTP://PAN.BAIDU.COM/S/1SJUJQVV

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.