updated makelists for modern compilation

This commit is contained in:
danielsuss 2025-06-12 16:04:55 +01:00
parent f0daa312d0
commit f7ad724570
6 changed files with 270 additions and 3 deletions

View File

@ -15,7 +15,7 @@
# You should have received a copy of the GNU General Public License # You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>. # along with this program. If not, see <http://www.gnu.org/licenses/>.
cmake_minimum_required (VERSION 3.4) cmake_minimum_required (VERSION 3.5)
project (barrier C CXX) project (barrier C CXX)
option (BARRIER_BUILD_GUI "Build the GUI" ON) option (BARRIER_BUILD_GUI "Build the GUI" ON)

265
COMPILATION_GUIDE.md Normal file
View File

@ -0,0 +1,265 @@
# Barrier Linux Compilation Guide
## Exact Steps Performed (What We Actually Did)
This section documents the exact sequence of commands and fixes applied to successfully build Barrier on WSL2/Ubuntu.
### 1. Fixed CMake Version Requirements
Updated minimum CMake version from 3.4 to 3.5 in three files:
**File 1:** `CMakeLists.txt` (line 18)
```cmake
# Changed from:
cmake_minimum_required (VERSION 3.4)
# To:
cmake_minimum_required (VERSION 3.5)
```
**File 2:** `cmake/Version.cmake` (line 1)
```cmake
# Changed from:
cmake_minimum_required (VERSION 3.4)
# To:
cmake_minimum_required (VERSION 3.5)
```
**File 3:** `src/gui/CMakeLists.txt` (line 1)
```cmake
# Changed from:
cmake_minimum_required (VERSION 3.4)
# To:
cmake_minimum_required (VERSION 3.5)
```
### 2. Installed Dependencies
```bash
sudo apt install -y libcurl4-openssl-dev qtbase5-dev qttools5-dev-tools libssl-dev libx11-dev libxtst-dev libxinerama-dev libxss-dev libxi-dev libxrandr-dev libavahi-compat-libdnssd-dev
```
### 3. Fixed Missing Headers
**File 1:** `src/lib/base/String.h`
Added missing header after line 25:
```cpp
#include <stdarg.h>
#include <vector>
#include <cstdint> // ADDED THIS LINE
```
**File 2:** `src/lib/net/FingerprintData.h`
Added missing header after line 22:
```cpp
#include <string>
#include <vector>
#include <cstdint> // ADDED THIS LINE
```
### 4. Build
```bash
cd "/mnt/c/D Drive/CAPTAIN/CodeProjects/barrier"
./clean_build.sh
```
### 5. Verify Build Output
```bash
ls -la "/mnt/c/D Drive/CAPTAIN/CodeProjects/barrier/build/bin/"
```
**Files created:**
- `barriers` (12,709,936 bytes) - Server executable
- `barrierc` (10,165,752 bytes) - Client executable
- `integtests` (20,092,176 bytes) - Integration tests
- `unittests` (15,227,792 bytes) - Unit tests
### 6. Test Functionality
```bash
cd "/mnt/c/D Drive/CAPTAIN/CodeProjects/barrier/build/bin"
./barrierc <server-ip>
```
**Result:** ✅ Successfully connected to server
---
## General Compilation Guide
### Prerequisites
#### System Requirements
- Ubuntu/Debian-based Linux distribution
- CMake 4.0+ (installed via snap)
- GCC 13.3.0
- Git
#### Required Dependencies
Install the following packages:
```bash
sudo apt update
sudo apt install -y \
libcurl4-openssl-dev \
qtbase5-dev \
qttools5-dev-tools \
libssl-dev \
libx11-dev \
libxtst-dev \
libxinerama-dev \
libxss-dev \
libxi-dev \
libxrandr-dev \
libavahi-compat-libdnssd-dev
```
**Note on Package Names:**
- Use `qtbase5-dev` instead of the deprecated `qt5-default`
- Use `libavahi-compat-libdnssd-dev` instead of `avahi-compat-libdns_sd-dev`
### Source Code Fixes Required
The original Barrier source code requires several fixes to compile with modern toolchains:
#### 1. CMake Minimum Version Updates
**Files to modify:**
- `CMakeLists.txt` (line 18)
- `cmake/Version.cmake` (line 1)
- `src/gui/CMakeLists.txt` (line 1)
**Change:**
```cmake
# FROM:
cmake_minimum_required (VERSION 3.4)
# TO:
cmake_minimum_required (VERSION 3.5)
```
**Reason:** CMake 4.0+ no longer supports compatibility with CMake < 3.5
#### 2. Missing C++ Headers
**File:** `src/lib/base/String.h`
**Add after existing includes:**
```cpp
#include <stdarg.h>
#include <vector>
#include <cstdint> // ADD THIS LINE
```
**File:** `src/lib/net/FingerprintData.h`
**Add after existing includes:**
```cpp
#include <string>
#include <vector>
#include <cstdint> // ADD THIS LINE
```
**Reason:** Modern C++ compilers require explicit inclusion of `<cstdint>` for `std::uint8_t` types
### Compilation Process
#### 1. Clone and Navigate
```bash
git clone <barrier-repo-url>
cd barrier
```
#### 2. Initialize Submodules
```bash
git submodule update --init --recursive
```
#### 3. Apply Source Code Fixes
Apply all the fixes mentioned in the "Source Code Fixes Required" section above.
#### 4. Build
```bash
./clean_build.sh
```
**Alternative manual build:**
```bash
mkdir build && cd build
cmake -DCMAKE_BUILD_TYPE=Debug ..
make
```
### Build Output
#### Successful Build Results
- **Location:** `build/bin/`
- **Core executables:**
- `barriers` (~12.7MB) - Server component
- `barrierc` (~10.2MB) - Client component
- `barrier` - GUI application (if Qt build completes)
- `integtests` - Integration tests
- `unittests` - Unit tests
#### Expected Warnings
- OpenSSL deprecation warnings (non-critical)
- CMake compatibility warnings (non-critical)
- Clock skew warnings in WSL (non-critical)
### Usage
#### Server Mode
```bash
cd build/bin
./barriers
```
#### Client Mode
```bash
cd build/bin
./barrierc <server-ip-address>
```
#### GUI Mode (if available)
```bash
cd build/bin
./barrier
```
### Troubleshooting
#### Common Issues
1. **Missing Qt5**: Install `qtbase5-dev` instead of `qt5-default`
2. **Missing Avahi**: Use `libavahi-compat-libdnssd-dev` package name
3. **uint8_t errors**: Add `#include <cstdint>` to header files
4. **CMake version errors**: Update minimum version requirements to 3.5
5. **CURL not found**: Install `libcurl4-openssl-dev`
#### Build Environment Notes
- **WSL Users**: No GUI display available by default
- **X11 Required**: For actual mouse/keyboard sharing functionality
- **Network**: Ensure firewall allows Barrier traffic (default port 24800)
### Platform-Specific Notes
#### Windows Build (Alternative)
If building on Windows instead of Linux:
- Requires Visual Studio 2019/2022
- Requires Qt 5.11.1 at `C:\Qt\5.11.1\msvc2017_64`
- Requires Bonjour SDK at `C:\Program Files\Bonjour SDK`
- Use `clean_build.bat` instead of `clean_build.sh`
#### Linux Desktop Environment
For full functionality, Barrier requires:
- X11 or Wayland display server
- Desktop environment (GNOME, KDE, etc.)
- Proper graphics drivers
### Version Information
- **Barrier Version:** 2.4.0
- **Build System:** CMake + Make
- **Compiler:** GCC 13.3.0
- **Target Platform:** Linux x86_64
### Summary of Changes Made
1. Updated CMake minimum version requirements (3 files)
2. Added missing `#include <cstdint>` headers (2 files)
3. Installed correct Linux development packages
4. Used appropriate package names for Ubuntu 24.04+
This guide should enable successful compilation of Barrier on modern Linux systems.

View File

@ -1,4 +1,4 @@
cmake_minimum_required (VERSION 3.4) cmake_minimum_required (VERSION 3.5)
set (BARRIER_VERSION_MAJOR 2) set (BARRIER_VERSION_MAJOR 2)
set (BARRIER_VERSION_MINOR 4) set (BARRIER_VERSION_MINOR 4)

View File

@ -1,4 +1,4 @@
cmake_minimum_required (VERSION 3.4) cmake_minimum_required (VERSION 3.5)
find_package (Qt5 REQUIRED COMPONENTS Core Widgets Network) find_package (Qt5 REQUIRED COMPONENTS Core Widgets Network)
set (CMAKE_AUTOMOC ON) set (CMAKE_AUTOMOC ON)

View File

@ -23,6 +23,7 @@
#include <stdarg.h> #include <stdarg.h>
#include <vector> #include <vector>
#include <cstdint>
// use standard C++ string class for our string class // use standard C++ string class for our string class
typedef std::string String; typedef std::string String;

View File

@ -20,6 +20,7 @@
#include <string> #include <string>
#include <vector> #include <vector>
#include <cstdint>
namespace barrier { namespace barrier {