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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to