Difference between revisions of "HowToCreateYourLibrary"
Criccobene (Talk | contribs) |
Criccobene (Talk | contribs) (→2. Open CSnake, specify the new MyLib library as the source file and generate the MyLib solution) |
||
Line 43: | Line 43: | ||
{| | {| | ||
− | |[[File: Csnake_my_lib.png|500px | | + | |[[File: Csnake_my_lib.png|500px |Configuration of CSnake to create a solution with the new library|thumb|left]] |
|} | |} | ||
Revision as of 03:47, 28 February 2011
Contents
Create Folders and Templates
In order to generate the folder structure and the basic files needed for your new library, run the StartNewModule tool from the installation path.
1. Specify the name of the new library in the Name field (e.g. MyLib)
2. Specify the path where the new library will be created in the Root path field (e.g. MyProject/MyProject_src/modules)
3. Select Library in the Type combo box
4. Specify csnMyProjectToolkit.py in the Toolkit csn file field
5. Press Start New Module
The tool will create a new folder ’MyLib’ in the ’modules’ folder. The content of this folder is
shown in the following picture. The new library will also be added to the python file csnMyProjectToolkit.py.
How to create a solution with my library
1. Edit the python file for the new MyLib library
- specify all dependencies of the new library. For instance, if your new library will use vtk functions, include vtk in the projects as follows: myLib.AddProjects([baseLib,vtk])
- specify all library modules. The library module created by default is ’tlFirst’ and includes template files (.cpp and .h) containing one template class. To create your own classes it is suggested to make a copy of the ’tlFirst’ folder, rename it (e.g. ’tlMyClass’), rename the source and include files (e.g. ’tlMyClass.cpp’ and ’tlMyClass.h’) contained in the folder and include it in the library modules, as follows: myLib.AddLibraryModules([“tlMyClass]“).
2. Open CSnake, specify the new MyLib library as the source file and generate the MyLib solution
- press Update and select the Instance mylib
- press Create CMake files and Run CMake
- press Launch IDE
3. Implement your class
In the Visual Studio solution of your new module edit tlMyClass.cpp and tlMyClass.h to implement your class (e.g. ’MyClass’)
4. Implement your application
- Rename the ’tlAppFirst’ folder and the ’tlAppFirst.cpp’ with the name of your application (e.g. ’tlMyApp’)
- Edit ’csnMyLibApps.py’ and include your application: myLibApps.AddApplications([“tlMyApp”])
- Open CSnake, specify csnMyLibApps.py as CSnake file, and press update
- press Create CMake files and Run CMake
- press Launch IDE
- compile the solution in Visual Studio
Next/Previous Steps:
- Project
- ThirdParty
- Plugin
- CommandLinePlugin