You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by GitBox <gi...@apache.org> on 2022/10/09 18:09:35 UTC

[GitHub] [pulsar-client-cpp] BewareMyPower opened a new pull request, #31: Link to OpenSSL statically when LINK_STATIC is ON

BewareMyPower opened a new pull request, #31:
URL: https://github.com/apache/pulsar-client-cpp/pull/31

   ### Motivation
   
   See discussions here: https://github.com/apache/pulsar-client-cpp/pull/28#issuecomment-1272588627
   
   The original purpose to not include static OpenSSL library in `libpulsarwithnossl.so` and `libpulsarwithdeps.a` is https://github.com/apache/pulsar/pull/6458. However, the ABI compatibility of OpenSSL is not good. If the Pulsar C++ library links dynamically to OpenSSL and the user only changes the OpenSSL dynamic library, some symbols might not be found.
   
   ### Modifications
   
   Use `LINK_STATIC` option to determine whether to link to OpenSSL library statically. After that, there are only 3 libraries generated when `LINK_STATIC` is ON.
   - `libpulsar.so`: the dynamic pulsar-client-cpp library.
   - `libpulsar.a`: the static pulsar-client-cpp library. When it's used, users must link to all 3rd party dependencies (OpenSSL, curl, etc.)
   - `libpulsarwithdeps.a`: the static pulsar-client-cpp library.
   
   ### Documentation
   
   <!-- DO NOT REMOVE THIS SECTION. CHECK THE PROPER BOX ONLY. -->
   
   - [x] `doc-required` 
   (Your PR needs to update docs and you will update later)
   
   - [ ] `doc-not-needed` 
   (Please explain why)
   
   - [ ] `doc` 
   (Your PR contains doc changes)
   
   - [ ] `doc-complete`
   (Docs have been already added)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [pulsar-client-cpp] BewareMyPower commented on pull request #31: Link to OpenSSL statically when LINK_STATIC is ON

Posted by GitBox <gi...@apache.org>.
BewareMyPower commented on PR #31:
URL: https://github.com/apache/pulsar-client-cpp/pull/31#issuecomment-1272600120

   After this PR, here are examples about how do I build an application with the given three libraries on macOS. Assume they are built with `LINK_STATIC=ON` option. It's a little tricky to build the static library of libcurl, see my comments here: https://github.com/apache/pulsar/issues/4967#issuecomment-1272440827
   
   Given such an application code (`example.cc`):
   
   ```c++
   #include <pulsar/Client.h>
   using namespace pulsar;
   
   int main() {
       Client client("pulsar://localhost:6650");
       client.close();
   }
   ```
   
   Assuming the headers are under `include/` directory and the libraries are under `lib/` directory, which is not a system path.
   
   ### libpulsar.so
   
   Build:
   
   ```bash
   clang++ example.cc -I include/ -L lib/ -lpulsar
   ```
   
   Run:
   
   ```bash
   # You have to add the path of `libpulsar.dylib` to a specific env variable so that symbols can be found
   DYLD_LIBRARY_PATH=$PWD/lib ./a.out
   ```
   
   ### libpulsar.a
   
   Build:
   
   ```bash
   # You have to link all 3rd party dependencies.
   # BTW, the directory followed by `-L` might be different in your actual env.
   clang++ example.cc -I include/ 
   lib/libpulsar.a \
   -lcurl -lz -lzstd \
   -L /usr/local/opt/protobuf/lib/ -lprotobuf \
   -L /usr/local/opt/openssl@3/lib/ -lssl -lcrypto \
   -L /usr/local/opt/snappy/lib/ -lsnappy
   ```
   
   Run:
   
   ```bash
   ./a.out
   ```
   
   ### libpulsarwithdeps.a
   
   Build:
   
   ```bash
   # NOTE: these -framework options are required by curl.a and only needed on macOS 
   clang++ example.cc lib/libpulsarwithdeps.a -framework SystemConfiguration -framework CoreFoundation
   ```
   
   Run:
   
   ```bash
   ./a.out
   ```


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [pulsar-client-cpp] BewareMyPower commented on pull request #31: Link to OpenSSL statically when LINK_STATIC is ON

Posted by GitBox <gi...@apache.org>.
BewareMyPower commented on PR #31:
URL: https://github.com/apache/pulsar-client-cpp/pull/31#issuecomment-1272737824

   I will fix the rpm / deb scripts soon.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [pulsar-client-cpp] merlimat merged pull request #31: Link to OpenSSL statically when LINK_STATIC is ON

Posted by GitBox <gi...@apache.org>.
merlimat merged PR #31:
URL: https://github.com/apache/pulsar-client-cpp/pull/31


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [pulsar-client-cpp] BewareMyPower commented on pull request #31: Link to OpenSSL statically when LINK_STATIC is ON

Posted by GitBox <gi...@apache.org>.
BewareMyPower commented on PR #31:
URL: https://github.com/apache/pulsar-client-cpp/pull/31#issuecomment-1272909633

   ![image](https://user-images.githubusercontent.com/18204803/194819303-88b4daad-2035-48f7-9fdb-3d89afc4206a.png)
   
   I see the "Squash and merge" button is not disabled even if some tests failed. Could you help make some workflows REQUIRED? @merlimat 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org