Skip to content

Latest commit

 

History

History
169 lines (119 loc) · 2.93 KB

File metadata and controls

169 lines (119 loc) · 2.93 KB

Installation

This guide explains how to install and build LazyOrm-CPP in your project.

Requirements

  • CMake: Version 3.15 or higher
  • C++ Compiler: C++20 standard support required
    • GCC 9.0+
    • Clang 10.0+
    • MSVC 19.28+

Installation Methods

CMake

Building from Source

  1. Clone the repository:
git clone https://github.com/your-repo/lazy-orm-cpp.git
cd lazy-orm-cpp
  1. Create a build directory:
mkdir build
cd build
  1. Configure with CMake:
cmake ..
  1. Build the library:
cmake --build .
  1. Install (optional):
cmake --install .

Using in Your CMake Project

Add LazyOrm-CPP to your CMake project using add_subdirectory:

cmake_minimum_required(VERSION 3.15)
project(MyProject)

# Add LazyOrm-CPP
add_subdirectory(path/to/lazy-orm-cpp)

# Link to your target
add_executable(my_app main.cpp)
target_link_libraries(my_app PRIVATE lazyorm)

Or use CMake's find_package after installation:

find_package(lazyorm REQUIRED)
add_executable(my_app main.cpp)
target_link_libraries(my_app PRIVATE lazyorm)

Build Options

The following CMake options are available:

Option Default Description
tests OFF Build test suite

To build tests:

cmake -Dtests=ON ..
cmake --build .

Including Headers

After installation, include LazyOrm-CPP headers in your code:

#include "LazyOrm.h"
#include "MariadbLazy.h"
#include "PostgreLazy.h"
#include "SqliteLazy.h"

Database Drivers

LazyOrm-CPP is a query builder and does not include database drivers. Query builder of LazyOrm-CPP supprots:

  • MariaDB/MySQL`
  • PostgreSQL
  • SQLite

Installation Paths

By default, LazyOrm-CPP installs to:

  • Headers: /usr/local/include/LazyOrm/
  • Library: /usr/local/lib/
  • CMake config: /usr/local/lib/cmake/lazyorm/

To customize installation paths:

cmake -DCMAKE_INSTALL_PREFIX=/custom/path ..

Verifying Installation

To verify your installation, compile a simple test program:

#include <iostream>
#include "LazyOrm.h"

int main() {
    LazyOrm::LazyOrm lazyOrm;
    std::cout << "LazyOrm-CPP installed successfully!" << std::endl;
    return 0;
}

Compile:

g++ -std=c++20 test.cpp -o test -I/usr/local/include -L/usr/local/lib -llazyorm

Troubleshooting

CMake Version Error

If you encounter a CMake version error, upgrade your CMake:

# Ubuntu/Debian
sudo apt-get install --only-upgrade cmake

# macOS with Homebrew
brew upgrade cmake

C++20 Support

Ensure your compiler supports C++20:

g++ --version  # Should be 9.0+
clang++ --version  # Should be 10.0+

Linking Errors

If you encounter linking errors, verify the library path is in your linker search path:

export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH

Or add the path to /etc/ld.so.conf.d/ and run sudo ldconfig.