This commit is contained in:
parent
ec1293113f
commit
35cb141334
24
CLAUDE.md
24
CLAUDE.md
@ -59,22 +59,17 @@ The CMakeLists.txt enforces static linking through:
|
|||||||
- `CMAKE_EXE_LINKER_FLAGS` with `-static` flag
|
- `CMAKE_EXE_LINKER_FLAGS` with `-static` flag
|
||||||
- `CMAKE_FIND_LIBRARY_SUFFIXES` set to `.a`
|
- `CMAKE_FIND_LIBRARY_SUFFIXES` set to `.a`
|
||||||
- `BUILD_SHARED_LIBS` forced to OFF
|
- `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
|
```cmake
|
||||||
# Set paths for libraries before finding Drogon
|
# Set paths for libraries before finding Drogon
|
||||||
set(CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH}
|
set(CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH} /usr/local)
|
||||||
/usr/local/jsoncpp
|
|
||||||
/usr/local/openssl-musl
|
|
||||||
/usr/local/pgsql
|
|
||||||
# ... other library paths
|
|
||||||
)
|
|
||||||
|
|
||||||
# Additional PostgreSQL libraries needed for static linking
|
# Additional PostgreSQL libraries needed for static linking
|
||||||
set(POSTGRESQL_EXTRA_LIBS
|
set(POSTGRESQL_EXTRA_LIBS
|
||||||
/usr/local/pgsql/lib/libpgcommon.a
|
/usr/local/lib/libpgcommon.a
|
||||||
/usr/local/pgsql/lib/libpgport.a
|
/usr/local/lib/libpgport.a
|
||||||
)
|
)
|
||||||
```
|
```
|
||||||
|
|
||||||
@ -109,12 +104,11 @@ The system ensures complete static linking by:
|
|||||||
### Database Support
|
### Database Support
|
||||||
|
|
||||||
Applications can use:
|
Applications can use:
|
||||||
- PostgreSQL via libpq at `/usr/local/pgsql/`
|
- PostgreSQL via libpq
|
||||||
- MySQL via client library at `/usr/local/mysql/`
|
- MySQL via MariaDB connector
|
||||||
- MariaDB via connector at `/usr/local/mariadb-connector-c/`
|
- SQLite3
|
||||||
- SQLite3 at `/usr/local/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
|
### HTTP Client Utilities
|
||||||
|
|
||||||
|
@ -41,20 +41,17 @@ This base image is designed to create statically-linked C++ executables using:
|
|||||||
10. **Drogon** (latest from git) - C++ web framework
|
10. **Drogon** (latest from git) - C++ web framework
|
||||||
|
|
||||||
### Build Characteristics
|
### 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
|
- Position Independent Code (`-fPIC`) enabled for static linking
|
||||||
- CMake configured to prefer static libraries (`.a` suffix)
|
- CMake configured to prefer static libraries (`.a` suffix)
|
||||||
- Drogon built with PostgreSQL, MySQL, and SQLite3 support enabled
|
- Drogon built with PostgreSQL, MySQL, and SQLite3 support enabled
|
||||||
|
|
||||||
### Important Paths
|
### Library Installation
|
||||||
- OpenSSL: `/usr/local/openssl-musl/`
|
All libraries are installed with:
|
||||||
- PostgreSQL: `/usr/local/pgsql/`
|
- Headers in `/usr/local/include/`
|
||||||
- MariaDB Connector: `/usr/local/mariadb-connector-c/`
|
- Static libraries in `/usr/local/lib/`
|
||||||
- SQLite3: `/usr/local/sqlite3/`
|
- CMake configs in `/usr/local/lib/cmake/`
|
||||||
- MySQL: `/usr/local/mysql/`
|
- pkg-config files in `/usr/local/lib/pkgconfig/`
|
||||||
- jsoncpp: `/usr/local/jsoncpp/`
|
|
||||||
- c-ares: `/usr/local/cares/`
|
|
||||||
- cURL: `/usr/local/curl/`
|
|
||||||
|
|
||||||
### Notes for Development
|
### Notes for Development
|
||||||
- When modifying the Dockerfile, maintain the build order as dependencies are interlinked
|
- When modifying the Dockerfile, maintain the build order as dependencies are interlinked
|
||||||
|
1
build.sh
1
build.sh
@ -11,6 +11,7 @@ rm -rf "${SCRIPT_DIR}/output"
|
|||||||
mkdir -p "${SCRIPT_DIR}/output"
|
mkdir -p "${SCRIPT_DIR}/output"
|
||||||
|
|
||||||
docker build \
|
docker build \
|
||||||
|
--no-cache \
|
||||||
-t "gitea.jde.nz/public/${PROJECT}-build:latest" \
|
-t "gitea.jde.nz/public/${PROJECT}-build:latest" \
|
||||||
-f "${SCRIPT_DIR}/Dockerfile.dropshell-build" \
|
-f "${SCRIPT_DIR}/Dockerfile.dropshell-build" \
|
||||||
--build-arg PROJECT="${PROJECT}" \
|
--build-arg PROJECT="${PROJECT}" \
|
||||||
|
@ -98,6 +98,29 @@ set(EXTRA_LIBS
|
|||||||
|
|
||||||
# Set paths for libraries before finding Drogon
|
# Set paths for libraries before finding Drogon
|
||||||
set(CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH} /usr/local)
|
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)
|
find_package(Drogon CONFIG REQUIRED)
|
||||||
target_link_libraries(${PROJECT_NAME} PRIVATE Drogon::Drogon)
|
target_link_libraries(${PROJECT_NAME} PRIVATE Drogon::Drogon)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user