mfontanini / cppkafka

Modern C++ Apache Kafka client library (wrapper for librdkafka)
BSD 2-Clause "Simplified" License
589 stars 207 forks source link

Failed to find valid rdkafka version #226

Open nitinpatharia opened 4 years ago

nitinpatharia commented 4 years ago

I am using Cmake GUI to build the code on window and given the path in path variable as DBOOST_INCLUDEDIR="C:\packages\boost.1.70.0.0\lib\native\include" \ -DRDKAFKA_LIBRARY="C:\packages\librdkafka.redist.1.2.0\build\native\lib\win\x86\win-x86-Release\v120\librdkafka.lib" \ -DRDKAFKA_INCLUDE_DIR="C:\packages\librdkafka.redist.1.2.0\build\native\include"

when in configure from camke UI i receive error like

Build will generate a shared library. Use CPPKAFKA_BUILD_SHARED=0 to perform a static build RdKafkaConfig.cmake not found. Attempting to find module instead... CMake Error at cmake/FindRdKafka.cmake:71 (message): Failed to find valid rdkafka version Call Stack (most recent call first): CMakeLists.txt:129 (find_package)

Configuring incomplete, errors occurred! See also "C:/project/1/build1/CMakeFiles/CMakeOutput.log".

what is wrong i am doing .......Please help

MLIOSBond commented 4 years ago

I have managed to build it under Windows! So, my solution:

Let's assume, that you've downloaded 'librdkafka' project from github into the following directory: D:/builds-github/librdkafka/librdkafka-master (Your CMakeLists.txt will be here: librdkafka-master/CMakeLists.txt)

  1. Find the src folder (there are *.h and *.c files. Also there is one .png file in it)
  2. Create folder librdkafka under librdkafka-master. In my example: D:/builds-github/librdkafka/librdkafka-master/librdkafka
  3. Copy the content of src directory into librdkafka directory. So, the file rdkafka.h will be here now: D:/builds-github/librdkafka/librdkafka-master/librdkafka/rdkafka.h

I think, the problem is in cmake/FindRdKafka.cmake file at line 20: NAMES librdkafka/rdkafka.h

Lines 19 to 22:

find_path(RdKafka_INCLUDE_DIR
    NAMES librdkafka/rdkafka.h
    HINTS ${RdKafka_ROOT}/include
)

And if you are building this library under Windows, disable Tests and Examples. They require pthread.lib and rt.lib. I have no idea where to get them. And then in Visual Studio remove these libraries in Project properties (Linker settings)

P.S. I've attached a screenshot of my cmake-gui settings There is 'RdKafka_ROOT' variable on it, which I've created by adding a new entry, but it isn't neccessary to do that, I think. You might not need it. github-cppkafka-issue-226