Repository navigation
Expand file tree
/
Copy pathinstallation.md
More file actions
179 lines (125 loc) · 3.47 KB
/
Copy pathinstallation.md
File metadata and controls
179 lines (125 loc) · 3.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
# 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:
```bash
git clone https://github.com/your-repo/lazy-orm-cpp.git
cd lazy-orm-cpp
```
2. Create a build directory:
```bash
mkdir build
cd build
```
3. Configure with CMake:
```bash
cmake ..
```
4. Build the library:
```bash
cmake --build .
```
5. Install (optional):
```bash
cmake --install .
```
#### Using an installed lazyvariant
If you installed `lazyvariant` into a custom prefix (for example `/home/mmjvox/dev-libs/install`), point CMake at its package config directory when configuring LazyOrm-CPP:
```bash
cmake -S . -B build -Dlazyvariant_DIR=/home/mmjvox/dev-libs/install/lib/cmake/lazyvariant
```
You can also add the prefix to `CMAKE_PREFIX_PATH` or set the `lazyvariant_ROOT` environment variable. When no installed package is found, the build automatically falls back to the bundled submodule (if present).
#### Using in Your CMake Project
Add LazyOrm-CPP to your CMake project using `add_subdirectory`:
```cmake
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:
```cmake
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 |
|--------|---------|-------------|
| `orm_tests` | `OFF` | Build the LazyOrm-CPP Catch2 suite |
To build tests:
```bash
cmake -Dorm_tests=ON ..
cmake --build .
```
## Including Headers
After installation, include LazyOrm-CPP headers in your code:
```cpp
#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:
```bash
cmake -DCMAKE_INSTALL_PREFIX=/custom/path ..
```
## Verifying Installation
To verify your installation, compile a simple test program:
```cpp
#include <iostream>
#include "LazyOrm.h"
int main() {
LazyOrm::LazyOrm lazyOrm;
std::cout << "LazyOrm-CPP installed successfully!" << std::endl;
return 0;
}
```
Compile:
```bash
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:
```bash
# Ubuntu/Debian
sudo apt-get install --only-upgrade cmake
# macOS with Homebrew
brew upgrade cmake
```
### C++20 Support
Ensure your compiler supports C++20:
```bash
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:
```bash
export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH
```
Or add the path to `/etc/ld.so.conf.d/` and run `sudo ldconfig`.