From 35cb141334e632e3a71e61149aef4093659590f6 Mon Sep 17 00:00:00 2001 From: j842 Date: Tue, 10 Jun 2025 14:10:13 +1200 Subject: [PATCH] ALL WORKING! --- CLAUDE.md | 24 +++++++++--------------- build-base/CLAUDE.md | 17 +++++++---------- build.sh | 1 + tests/ipdemo/CMakeLists.txt | 23 +++++++++++++++++++++++ 4 files changed, 40 insertions(+), 25 deletions(-) diff --git a/CLAUDE.md b/CLAUDE.md index 7d4e2d8..111bbd3 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -59,22 +59,17 @@ The CMakeLists.txt enforces static linking through: - `CMAKE_EXE_LINKER_FLAGS` with `-static` flag - `CMAKE_FIND_LIBRARY_SUFFIXES` set to `.a` - `BUILD_SHARED_LIBS` forced to OFF -- Custom library paths from the base image +- All libraries installed in standard `/usr/local` paths -Important: Projects must set CMAKE_PREFIX_PATH and explicitly link PostgreSQL libraries: +Important: Projects should set CMAKE_PREFIX_PATH and may need to explicitly link PostgreSQL libraries: ```cmake # Set paths for libraries before finding Drogon -set(CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH} - /usr/local/jsoncpp - /usr/local/openssl-musl - /usr/local/pgsql - # ... other library paths -) +set(CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH} /usr/local) # Additional PostgreSQL libraries needed for static linking set(POSTGRESQL_EXTRA_LIBS - /usr/local/pgsql/lib/libpgcommon.a - /usr/local/pgsql/lib/libpgport.a + /usr/local/lib/libpgcommon.a + /usr/local/lib/libpgport.a ) ``` @@ -109,12 +104,11 @@ The system ensures complete static linking by: ### Database Support Applications can use: -- PostgreSQL via libpq at `/usr/local/pgsql/` -- MySQL via client library at `/usr/local/mysql/` -- MariaDB via connector at `/usr/local/mariadb-connector-c/` -- SQLite3 at `/usr/local/sqlite3/` +- PostgreSQL via libpq +- MySQL via MariaDB connector +- SQLite3 -All database libraries are statically linked into the final binary. +All database libraries are installed in `/usr/local` and are statically linked into the final binary. ### HTTP Client Utilities diff --git a/build-base/CLAUDE.md b/build-base/CLAUDE.md index 4891e51..8d7ecd6 100644 --- a/build-base/CLAUDE.md +++ b/build-base/CLAUDE.md @@ -41,20 +41,17 @@ This base image is designed to create statically-linked C++ executables using: 10. **Drogon** (latest from git) - C++ web framework ### Build Characteristics -- All libraries installed in `/usr/local/` with specific prefixes +- All libraries installed in standard `/usr/local/` location - Position Independent Code (`-fPIC`) enabled for static linking - CMake configured to prefer static libraries (`.a` suffix) - Drogon built with PostgreSQL, MySQL, and SQLite3 support enabled -### Important Paths -- OpenSSL: `/usr/local/openssl-musl/` -- PostgreSQL: `/usr/local/pgsql/` -- MariaDB Connector: `/usr/local/mariadb-connector-c/` -- SQLite3: `/usr/local/sqlite3/` -- MySQL: `/usr/local/mysql/` -- jsoncpp: `/usr/local/jsoncpp/` -- c-ares: `/usr/local/cares/` -- cURL: `/usr/local/curl/` +### Library Installation +All libraries are installed with: +- Headers in `/usr/local/include/` +- Static libraries in `/usr/local/lib/` +- CMake configs in `/usr/local/lib/cmake/` +- pkg-config files in `/usr/local/lib/pkgconfig/` ### Notes for Development - When modifying the Dockerfile, maintain the build order as dependencies are interlinked diff --git a/build.sh b/build.sh index f7f2c6b..c3df523 100755 --- a/build.sh +++ b/build.sh @@ -11,6 +11,7 @@ rm -rf "${SCRIPT_DIR}/output" mkdir -p "${SCRIPT_DIR}/output" docker build \ + --no-cache \ -t "gitea.jde.nz/public/${PROJECT}-build:latest" \ -f "${SCRIPT_DIR}/Dockerfile.dropshell-build" \ --build-arg PROJECT="${PROJECT}" \ diff --git a/tests/ipdemo/CMakeLists.txt b/tests/ipdemo/CMakeLists.txt index 2943f4d..f919761 100644 --- a/tests/ipdemo/CMakeLists.txt +++ b/tests/ipdemo/CMakeLists.txt @@ -98,6 +98,29 @@ set(EXTRA_LIBS # Set paths for libraries before finding Drogon set(CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH} /usr/local) +set(OPENSSL_ROOT_DIR /usr/local) +set(OPENSSL_USE_STATIC_LIBS TRUE) + +# Find OpenSSL and create the targets that Trantor expects +find_package(OpenSSL REQUIRED) + +# Ensure the OpenSSL imported targets exist for Trantor +if(NOT TARGET OpenSSL::SSL) + add_library(OpenSSL::SSL STATIC IMPORTED) + set_target_properties(OpenSSL::SSL PROPERTIES + IMPORTED_LOCATION "${OPENSSL_SSL_LIBRARY}" + INTERFACE_INCLUDE_DIRECTORIES "${OPENSSL_INCLUDE_DIR}" + INTERFACE_LINK_LIBRARIES "OpenSSL::Crypto" + ) +endif() + +if(NOT TARGET OpenSSL::Crypto) + add_library(OpenSSL::Crypto STATIC IMPORTED) + set_target_properties(OpenSSL::Crypto PROPERTIES + IMPORTED_LOCATION "${OPENSSL_CRYPTO_LIBRARY}" + INTERFACE_INCLUDE_DIRECTORIES "${OPENSSL_INCLUDE_DIR}" + ) +endif() find_package(Drogon CONFIG REQUIRED) target_link_libraries(${PROJECT_NAME} PRIVATE Drogon::Drogon)