couchbase-cxx-client
couchbase-cxx-client copied to clipboard
Issue building couchbase-cxx-client in static
Hello,
I contact you because I am trying to build the client in static and I am facing some issues.
couchbase-cxx-client version 1.0.4 (tarball from https://github.com/couchbase/couchbase-cxx-client/releases/download/1.0.4/couchbase-cxx-client-1.0.4.tar.gz)
I am using the following cmake command
mkdir -p build
cmake -S "." -B build \
-DCMAKE_INSTALL_PREFIX=%{buildroot} \
-DCMAKE_VERBOSE_MAKEFILE:BOOL=ON \
-DBUILD_SHARED_LIBS=OFF \
-DCOUCHBASE_CXX_CLIENT_INSTALL=ON \
-DCOUCHBASE_CXX_CLIENT_BUILD_EXAMPLES=OFF \
-DCOUCHBASE_CXX_CLIENT_BUILD_TESTS=OFF \
-DCOUCHBASE_CXX_CLIENT_BUILD_TOOLS=ON \
-DCOUCHBASE_CXX_CLIENT_BUILD_STATIC=ON \
-DCOUCHBASE_CXX_CLIENT_BUILD_SHARED=OFF
And I am getting the following errors:
CMake Error: install(EXPORT "couchbase_cxx_client-targets" ...) includes target "couchbase_cxx_client_static" which requires target "project_options" that is not in any export set.
CMake Error: install(EXPORT "couchbase_cxx_client-targets" ...) includes target "couchbase_cxx_client_static" which requires target "project_warnings" that is not in any export set.
CMake Error: install(EXPORT "couchbase_cxx_client-targets" ...) includes target "couchbase_cxx_client_static" which requires target "fmt" that is not in any export set.
CMake Error: install(EXPORT "couchbase_cxx_client-targets" ...) includes target "couchbase_cxx_client_static" which requires target "spdlog" that is not in any export set.
CMake Error: install(EXPORT "couchbase_cxx_client-targets" ...) includes target "couchbase_cxx_client_static" which requires target "GSL" that is not in any export set.
CMake Error: install(EXPORT "couchbase_cxx_client-targets" ...) includes target "couchbase_cxx_client_static" which requires target "asio" that is not in any export set.
CMake Error: install(EXPORT "couchbase_cxx_client-targets" ...) includes target "couchbase_cxx_client_static" which requires target "snappy" that is not in any export set.
CMake Error: install(EXPORT "couchbase_cxx_client-targets" ...) includes target "couchbase_cxx_client_static" which requires target "jsonsl" that is not in any export set.
CMake Error: install(EXPORT "couchbase_cxx_client-targets" ...) includes target "couchbase_cxx_client_static" which requires target "couchbase_backtrace" that is not in any export set.
If I build the client in shared it works fine
cmake -S "." -B build \
${BuildTarget} -DCMAKE_INSTALL_PREFIX=%{buildroot} \
-DCMAKE_VERBOSE_MAKEFILE:BOOL=ON \
-DBUILD_SHARED_LIBS=OFF \
-DCOUCHBASE_CXX_CLIENT_INSTALL=ON \
-DCOUCHBASE_CXX_CLIENT_BUILD_EXAMPLES=OFF \
-DCOUCHBASE_CXX_CLIENT_BUILD_TESTS=OFF \
-DCOUCHBASE_CXX_CLIENT_BUILD_TOOLS=ON \
-DCOUCHBASE_CXX_CLIENT_BUILD_STATIC=OFF \
-DCOUCHBASE_CXX_CLIENT_BUILD_SHARED=ON
Maybe I am using the wrong flags to build in static but I have the feeling there is some issues in the cmake files for the static build.
What triggers the issue seems to be the usage of both -DCOUCHBASE_CXX_CLIENT_INSTALL=ON and -DCOUCHBASE_CXX_CLIENT_BUILD_STATIC=ON
Can you please confirm that the cmake command I am using is correct to build in static and install the couchbase-cxx-client?
Cheers Thomas
Note: I am sorry for creating the issue on Github but I cannot create an account on your Couchbase JIRA, there is only the option to sign in and if I sign in with my company or my personal account I have not access to your board.
Hi @Thomas-Barbier-1A, thanks for the report. You are right. At this moment it is a limitation as I have not figured out how to export library targets, but keep dependencies hidden (as we statically link dependencies, and do not export their interfaces anyway).
The "static build" right now works the best, when you use the SDK as subproject of your project. This way you can do -DCOUCHBASE_CXX_CLIENT_INSTALL=OFF and then combination of -DCOUCHBASE_CXX_CLIENT_BUILD_STATIC=ON -DCOUCHBASE_CXX_CLIENT_BUILD_SHARED=OFF would work.
This is what I'm doing right now in PHP SDK wrapper: https://github.com/couchbase/couchbase-php-client/blob/2dd0e58b5bfa485803faa287c651657f654071f5/src/CMakeLists.txt#L45-L47
Hi @avsej , thank you for your reply. Unfortunately we have a particular UseCase that prevent us to use the libcouchbase as a CMake subproject:
In our company we build the opensource stack a bit like an Linux distribution: We compile all the libraries and deliver them (in shared, static or both depending on the UseCase), then our users build and link with the pre-compiled libraries.
We don't rebuild all our dependencies for each project (no vendoring). This is the reason why we need to "install" the libraries we compiled.
In the case of couchbase-cxx-client, the reason we want to link statically instead of shared libraries, is because we want to "aggregate" the library into an internal middleware component: This way we would be able to upgrade regularly the couchbase-cxx-client even if there are non ABI compatible or non source compatible changes without impacting our users.
Is there any other way to generate the libcouchbase-cxx-client.a even if the generated cmake files contain unneeded targets?
In our particular case, we won't use the generated cmake files anyway.
Cheers