0

I am learning CppKafka https://github.com/mfontanini/cppkafka and want to run simple script

// main.cpp
#include <cppkafka/cppkafka.h>

using namespace std;
using namespace cppkafka;

int main() {
    std::cout << "Hello world\n";
}

I was reading How to link C++ Application with cppkafka but it didn't help

My actions (my aim is to build the code with help of cmake)

1 Created CMakeLists.txt

cmake_minimum_required(VERSION 3.9.2)
project(KafkaExample)

add_executable(my_bin main.cpp)

find_package(CppKafka REQUIRED)
target_link_libraries(my_bin CppKafka::cppkafka)

2 Downloaded https://github.com/mfontanini/cppkafka to the folder on the same level with main.cpp

3 Trying to build

mkdir build
cd build
cmake ..

I have an error

% cmake ..
CMake Error at CMakeLists.txt:6 (find_package):
  By not providing "FindCppKafka.cmake" in CMAKE_MODULE_PATH this project has
  asked CMake to find a package configuration file provided by "CppKafka",
  but CMake did not find one.

  Could not find a package configuration file provided by "CppKafka" with any
  of the following names:

    CppKafkaConfig.cmake
    cppkafka-config.cmake

I was trying to build cppkafka library

cd cppkafka/build
brew install boost
cmake .. 

CMake Error at CMakeLists.txt:6 (find_package):
  By not providing "FindCppKafka.cmake" in CMAKE_MODULE_PATH this project has
  asked CMake to find a package configuration file provided by "CppKafka",
  but CMake did not find one.

  Could not find a package configuration file provided by "CppKafka" with any
  of the following names:

    CppKafkaConfig.cmake
    cppkafka-config.cmake
mascai
  • 1,373
  • 1
  • 9
  • 30
  • `find_package` requires you to have built and *installed* the library somewhere first. – Botje May 10 '23 at 11:24
  • Did you override cppkafka's CMakeLists.txt with yours or something? Line 6 in the repository is an `endif()`. – Botje May 10 '23 at 11:47
  • no, I am building cppKafka library https://github.com/mfontanini/cppkafka/blob/master/CMakeLists.txt – mascai May 10 '23 at 11:50
  • Yes, and I am telling you line 6 is an `endif` statement. The only way your error makes sense is that you overwrote cppkafka's CMakeLists.txt with yours. – Botje May 10 '23 at 11:51
  • 1
    "How to build and use CppKafka?" - Documentation for CppKafka clearly describes how to build it - https://github.com/mfontanini/cppkafka#compiling - and how to use it - https://github.com/mfontanini/cppkafka#using. Have you tried to just follow that paragraphs? None of them asks to "Downloaded https://github.com/mfontanini/cppkafka to the folder on the same level with main.cpp". – Tsyvarev May 10 '23 at 11:53
  • and what happened when you tried to do what the error message suggested? https://meta.stackoverflow.com/q/261592/11107541 – starball May 10 '23 at 16:57

0 Answers0