Import ULedger SDK
Based on your platform you will have different setup requirements, however, curl and openssl are required regardless of the platform.
Setup
Windows
Requires:
- Visual Studio 2022: https://visualstudio.microsoft.com/vs/
- OpenSSL for Windows: https://slproweb.com/products/Win32OpenSSL.html
- Curl Dev lib for Windows: https://curl.se/windows/
Pre-Requisites
OpenSSL
To install OpenSSL, go to the Shining Light Productions website and install Win64 OpenSSL v3.1.3
Now, we need to set up the environment variables to use OpenSSL properly; follow these steps:
1. In the Windows start menu, type "edit the system environment variables" and click "Environment Variables..."**.**
2. In the User variables, click "New...", use "OPENSSL_CONF" for the variable name, and for the value, paste the path to your OpenSSL install, specifically bin\openssl.cfg
, for example E:\Tools\OpenSSL-Win64\bin\openssl.cfg
Curl Dev Lib
You do not need to set any environment variables to proceed with the Visual Studio setup.
Setup Visual Studio
To configure Visual Studio to compile and use the C SDK, you need to link both cURL and OpenSSL. Follow these steps to do so:
1. Update the additional include directories to point to your OpenSSL and cURL installations by opening the Solution Explorer panel in your Visual Studio project. Right-click on the project and navigate to Configuration Properties -> C/C++ -> General. Then click on the Additional Include Directories field and open the dropdown menu. Now, you can click on the folder icon at the top right and browse to your installation locations. Here is an example of what that process looks like.
2. Update the additional dependencies to point to the required libraries. From the previous step, open Linker -> Input and click on the Additional Dependencies field, then open the dropdown menu. Now you can paste the install location, ensuring you change the include folder to the lib folder. The two libraries required are libssl.lib
and libcrypto.lib
.
3. In the additional dependencies, you must also point to the required static libraries for cURL. In the same menu, add a path similar to: E:\Tools\curl-7.80.0-win64-mingw\lib\libcurl.dll.a
New Project
Start by downloading the ULC project so that you have access to the ULC.hpp file; this can be anywhere. You will need both json.hpp and ULC.hpp; remember this for later.
1. Create a new console application using Visual Studio.
2. Import the ULC.hpp and json.hpp files alongside your main.cpp file.
Mac
Pre-Requisites
You will need the following before proceeding:
CMake
Install Xcode:
- If you haven't already, you need to install Xcode from the Mac App Store. Once Xcode is installed, open it and accept the license agreement.
Install Homebrew:
- Open the Terminal, and paste the following command to install Homebrew:
/bin/bash -c "$(curl -fsSL
[https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"](https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)%22 "https://raw.githubusercontent.com/homebrew/install/head/install.sh)%22")
Install CMake:
- After Homebrew is installed, you can use it to install CMake. In Terminal, run the following command:
brew install cmake
This command will download and install CMake along with its dependencies.
Verify CMake Installation:
- You can verify that CMake has been installed successfully by running:
cmake --version
This should display information about the installed CMake version.
OpenSSL
- After installing Xcode for CMake, you can run:
brew install openssl
echo 'export PATH="/usr/local/opt/openssl/bin:$PATH"' >> ~/.bash_profile
source ~/.bash_profile
This will add OpenSSL to your system path across restarts.
Curl
This comes pre-packaged with Mac; you could run brew install curl
but it is not needed here.
New Project, using CMAKE
Start by downloading the ULC project, so that you have access to the ULC.hpp file; this can be anywhere. You will need both json.hpp and ULC.hpp; remember this for later.
1. Create an empty folder to house you code project.
2. Create your entry point file, main.cpp, to start your code project.
3. Create a CMakeLists.txt file alongside your main.cpp with the following contents:
cmake_minimum_required(VERSION 3.7.0)
project(my-project)
find_package(OpenSSL REQUIRED)
include_directories(${OPENSSL_INCLUDE_DIRS})
find_package(CURL REQUIRED)
include_directories(${CURL_INCLUDE_DIRS})
set(SOURCES
main.cpp
)
add_executable(my-project ${SOURCES})
target_compile_features(my-project PRIVATE cxx_std_17)
target_link_libraries(my-project PRIVATE OpenSSL::SSL OpenSSL::Crypto)
target_link_libraries(my-project PUBLIC ${CURL_LIBRARIES} ${OPENSSL_LIBRARIES})
- Import the ULC.hpp and json.hpp files alongside your main.cpp file.
Linux
Pre-Requisites
CMake
To install run:
sudo apt-install cmake
OpenSSL
To install run:
sudo apt-get install libssl-dev
Curl
To install run:
sudo apt-get install libcurl4-openssl-dev
Once finished be sure to run:
sudo apt update && sudo apt upgrade
New Project, using CMAKE
Start by downloading the ULC project so that you have access to the ULC.hpp file; this can be anywhere. You will need both json.hpp and ULC.hpp; remember this for later.
1. Create an empty folder to house you code project.
2. Create your entry point file, main.cpp, to start your code project.
3. Create a CMakeLists.txt file alongside your main.cpp with the following contents:
cmake_minimum_required(VERSION 3.7.0)
project(my-project)
find_package(OpenSSL REQUIRED)
include_directories(${OPENSSL_INCLUDE_DIRS})
find_package(CURL REQUIRED)
include_directories(${CURL_INCLUDE_DIRS})
set(SOURCES
main.cpp
)
add_executable(my-project ${SOURCES})
target_compile_features(my-project PRIVATE cxx_std_17)
target_link_libraries(my-project PRIVATE OpenSSL::SSL OpenSSL::Crypto)
target_link_libraries(my-project PUBLIC ${CURL_LIBRARIES} ${OPENSSL_LIBRARIES})
- Import the ULC.hpp and json.hpp files alongside your main.cpp file.
We advise to always use the latest maintained version for building ULedger SDK applications.