You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by pe...@apache.org on 2021/04/26 04:24:33 UTC
[pulsar] branch branch-2.7 updated: Fix C++ client cannot be built
on Windows(#10363)
This is an automated email from the ASF dual-hosted git repository.
penghui pushed a commit to branch branch-2.7
in repository https://gitbox.apache.org/repos/asf/pulsar.git
The following commit(s) were added to refs/heads/branch-2.7 by this push:
new dedaf9f Fix C++ client cannot be built on Windows(#10363)
dedaf9f is described below
commit dedaf9fc1d2af3dc47898bf80fbc08576a09da97
Author: Yunze Xu <xy...@gmail.com>
AuthorDate: Mon Apr 26 08:35:57 2021 +0800
Fix C++ client cannot be built on Windows(#10363)
### Motivation
C++ source code cannot be built on Windows. The build commands are:
```powershell
> cmake -B _builds -S . `
-DBUILD_PYTHON_WRAPPER=OFF -DBUILD_TESTS=OFF
> cmake --build .\_builds\
```
There're two errors. One is
> pulsar-client-cpp\lib\ReaderImpl.h(34): error C2144: syntax error: 'int' should be preceded by ';'
> ...
It's because `PULSAR_PUBLIC` is `__declspec(dllexport)` on Windows platform and it should be put before the variable type.
The other error is
> LINK : fatal error LNK1104: cannot open file 'pulsar.lib' pulsar\pulsar-client-cpp\_builds
\examples\SampleReaderCApi.vcxproj]
> ...
It looks like when files under `examples` and `perf` directories were compiled, it tried to link `pulsar.lib` and CMake target `pulsarShared`'s name has a `dll` suffix, like `pulsardll.lib` and `pulsardll.dll`. The suffix is redundant.
### Modifications
- Put `PULSAR_PUBLIC` before the variable type.
- Keep the `LIB_NAME` as the shared library's name, i.e. remove the `dll` suffix.
### Verifying this change
- [ ] Make sure that the change passes the CI checks.
This change is a trivial rework / code cleanup without any test coverage.
(cherry picked from commit 8fed161e07cde06de1d43b334a9996b87a88a622)
---
pulsar-client-cpp/lib/CMakeLists.txt | 3 ---
pulsar-client-cpp/lib/ReaderImpl.h | 6 +++---
2 files changed, 3 insertions(+), 6 deletions(-)
diff --git a/pulsar-client-cpp/lib/CMakeLists.txt b/pulsar-client-cpp/lib/CMakeLists.txt
index 1ca2bd4..c00a438 100644
--- a/pulsar-client-cpp/lib/CMakeLists.txt
+++ b/pulsar-client-cpp/lib/CMakeLists.txt
@@ -53,9 +53,6 @@ endif(MSVC)
set(LIB_NAME_SHARED ${LIB_NAME})
-if (WIN32)
- string(APPEND LIB_NAME_SHARED dll)
-endif()
add_library(pulsarShared SHARED ${PULSAR_SOURCES})
set_property(TARGET pulsarShared PROPERTY OUTPUT_NAME ${LIB_NAME_SHARED})
diff --git a/pulsar-client-cpp/lib/ReaderImpl.h b/pulsar-client-cpp/lib/ReaderImpl.h
index f1ad387..34379f5 100644
--- a/pulsar-client-cpp/lib/ReaderImpl.h
+++ b/pulsar-client-cpp/lib/ReaderImpl.h
@@ -31,9 +31,9 @@ typedef std::weak_ptr<ReaderImpl> ReaderImplWeakPtr;
namespace test {
-extern std::mutex readerConfigTestMutex PULSAR_PUBLIC;
-extern std::atomic_bool readerConfigTestEnabled PULSAR_PUBLIC;
-extern ConsumerConfiguration consumerConfigOfReader PULSAR_PUBLIC;
+extern PULSAR_PUBLIC std::mutex readerConfigTestMutex;
+extern PULSAR_PUBLIC std::atomic_bool readerConfigTestEnabled;
+extern PULSAR_PUBLIC ConsumerConfiguration consumerConfigOfReader;
} // namespace test