README.md | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
example/CMakeLists.txt | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
example/example.cpp | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 |
README.md
@@ -26,15 +26,12 @@ The project comes out with a very large freedom of use for everyone (and it will always be). It uses a BSD 3 clauses licensing schema. Elsewhere on Internet ===================== * Wiki main page: * Install and build : * Project web site : How to build ============ ## prerequisites GCC (Linux), MINGW or MSVC (Windows) cmake, boost, openssl (Linux/MINGW) ``` git clone https://github.com/open-license-manager/open-license-manager.git @@ -43,8 +40,7 @@ cd build ``` ## on Linux : ## on Linux ``` cmake .. -DCMAKE_INSTALL_PREFIX=../install make @@ -52,14 +48,12 @@ ``` ## on Windows (with MSVC 2010) ``` cmake .. -G "Visual Studio 10 2010 Win64" -DCMAKE_INSTALL_PREFIX=../install cmake --build . --target install --config Release ``` ## cross compile with MINGW on Linux ``` x86_64-w64-mingw32.static-cmake .. -DCMAKE_INSTALL_PREFIX=../install make @@ -69,12 +63,31 @@ How to test =========== ## on Linux : ## on Linux ``` make test ``` ## on Windows : ## on Windows (MSVC) ``` ctest -C Release ``` How to use ========== This simple example shows how to integrate open-licence-manager into your project ``` $ cd example $ cmake . $ make $ ./example license ERROR : license file not found the pc signature is : Jaaa-aaaa-MG9F-ZhBB $ ../install/bin/license_generator example -s Jaaa-aaaa-MG9F-ZhBB -o example.lic $ ./example licence OK ``` example/CMakeLists.txt
New file @@ -0,0 +1,28 @@ cmake_minimum_required(VERSION 3.0) link_directories ( "${CMAKE_CURRENT_SOURCE_DIR}/../install/lib" ) include_directories( "${CMAKE_CURRENT_SOURCE_DIR}/../install/include" ) SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") if(MSVC) SET(CMAKE_FIND_LIBRARY_SUFFIXES .lib ) else(MSVC) set(CMAKE_FIND_LIBRARY_SUFFIXES .a .so) set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -s -Wl,--exclude-libs,liblicense++_static.a") find_package(OpenSSL REQUIRED) endif(MSVC) include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}) add_executable(example example.cpp) target_link_libraries(example license++_static os base tools_base) if(NOT MSVC) target_link_libraries(example crypto pthread dl z) endif(NOT MSVC) if(MINGW) target_link_libraries(example iphlpapi) endif(MINGW) example/example.cpp
New file @@ -0,0 +1,44 @@ #include <iostream> #include <map> #include "api/license++.h" #include "pc-identifiers.h" using namespace std; int main(int argc, char *argv[]) { map<EVENT_TYPE, string> stringByEventType; stringByEventType[LICENSE_OK ] = "OK "; stringByEventType[LICENSE_FILE_NOT_FOUND ] = "license file not found "; stringByEventType[LICENSE_SERVER_NOT_FOUND ] = "license server can't be contacted "; stringByEventType[ENVIRONMENT_VARIABLE_NOT_DEFINED] = "environment variable not defined "; stringByEventType[FILE_FORMAT_NOT_RECOGNIZED ] = "license file has invalid format (not .ini file) "; stringByEventType[LICENSE_MALFORMED ] = "some mandatory field are missing, or data can't be fully read. "; stringByEventType[PRODUCT_NOT_LICENSED ] = "this product was not licensed "; stringByEventType[PRODUCT_EXPIRED ] = "licence expired "; stringByEventType[LICENSE_CORRUPTED ] = "license signature didn't match with current license "; stringByEventType[IDENTIFIERS_MISMATCH ] = "Calculated identifier and the one provided in license didn't match"; stringByEventType[LICENSE_FILE_FOUND ] = "licence file not found "; stringByEventType[LICENSE_VERIFIED ] = "licence verified "; const string licLocation("example.lic"); LicenseInfo licenseInfo; LicenseLocation licenseLocation; licenseLocation.openFileNearModule = false; licenseLocation.licenseFileLocation = licLocation.c_str(); licenseLocation.environmentVariableName = ""; EVENT_TYPE result = acquire_license("example", licenseLocation, &licenseInfo); if (result != LICENSE_OK){ PcSignature signature; FUNCTION_RETURN generate_ok = generate_user_pc_signature(signature, ETHERNET); cout << "license ERROR :" << endl; cout << " " << stringByEventType[result].c_str() << endl; cout << "the pc signature is :" << endl; cout << " " << signature << endl; } else cout << "licence OK" << endl; }