Console "Hello World" Example
A very simple example using clanCore and clanApplication:
#include <ClanLib/core.h> #include <ClanLib/application.h> class ConsoleProgram { public: static int main(const std::vector<CL_String> &args); }; // Create global application object: // You MUST include this line or the application start-up will fail to // locate your console application object. CL_ClanApplication app(&ConsoleProgram::main); int ConsoleProgram::main(const std::vector<CL_String> &args) { // Setup clanCore: CL_SetupCore setup_core; // Create a console Window if one does not exist: CL_ConsoleWindow console_window("Console"); // Write a line to the console: CL_Console::write_line("Hello World!"); return 0; }
To build this example with Visual C++:
- Create a new Win32 project.
- Add the source file to the project.
- Change the threading model to Multithreaded Debug (or just Multithreaded for release builds) in the project settings' C/C++ Code Generation section.
- Change the character set to Multi-Byte Character Set in the project settings General section, if you did not build the Unicode version of ClanLib.