Default installation of dpdk using Meson,Ninja will provide libdpdk.pc.Please provide suggestion in linking dpdk library in Cmakefile dpdk version 20.11.2.
cmake
Checking for libdpdk
Found libdpdk,version 20.11.2
make Error Message:
In file included from /usr/lib/gcc/x86_64-linux-gnu/5/include/x86intrin.h:37:0,
from /usr/local/include/rte_vect.h:31,
from /usr/local/include/rte_memcpy.h:17,
from /home/sample.c:88,
/usr/lib/gcc/x86_64-linux-gnu/5/include/tmmintrin.h:185:1:
error: inlining failed in call to always_inline ‘_mm_alignr_epi8’: target specific option mismatch
libdpdk.pc
prefix=/usr/local
libdir=${prefix}/lib/x86_64-linux-gnu
includedir=${prefix}/include
Name:DPDK
Requires:libdpdk-libs
Cflags:-I{includedir}
CMakeLists.txt
find_package(PkgConfig REQUIRED)
pkg_check_modules(DPDK REQUIRED libdpdk)
include_directories(${DPDK_INCLUDE_DIR})
include_directories(${CMAKE_SOURCE_DIR}/include)
link_directories(${DPDK_LIBRARY_DIR})
set(DPDK_LIBS "-Wl,--whole-archive -l dpdk -Wl,--no-whole-archive")
add_executable(sample sample.c)
# target_include_directories(sample PUBLIC /usr/local/include)
#target_include_directories(sample PUBLIC /usr/local/lib/x86_64-linux-gnu)
target_link_libraries(sample PUBLIC ${DPDK_LIBS})
You should probably use
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mssse3")
in CMakeLists.txt.
Related
I am trying to link eigen to my project on clion, but the following error is printed:
This is my cmakelist file with all the attempts to link the library:
cmake_minimum_required(VERSION 2.8.3)
project(planner_standalone_grasp)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O0")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-diagnostics-color")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++17")
# find all cpp files in currect directory (where CMakeLists.txt is)
file(GLOB SOURCE_FILES FILES_MATCHING PATTERN "./src/*.cpp")
include_directories(src)
add_executable(${PROJECT_NAME} main.cpp ${SOURCE_FILES})
set(EXE_LIBS
ctop_common
ctop_log
ctop_util
eigen
crl
crl-algorithm
crl-loader
crl-tsplib
yaml-cpp
)
target_link_directories(${PROJECT_NAME} PUBLIC lib/comrob/lib/)
target_link_directories(${PROJECT_NAME} PUBLIC ctop/common/cmake-build-debug/)
target_link_directories(${PROJECT_NAME} PUBLIC ctop/log/cmake-build-debug/)
target_link_directories(${PROJECT_NAME} PUBLIC ctop/util/cmake-build-debug/)
set(EIGEN_DIR "/usr/local/include/Eigen/")
include_directories(${EIGEN_DIR})
find_package (Eigen3 3.3 REQUIRED NO_MODULE)
target_link_libraries (${PROJECT_NAME} Eigen3::Eigen)
target_link_directories(${PROJECT_NAME} PUBLIC lib/eigen/Eigen/)
target_link_directories(${PROJECT_NAME} PUBLIC /usr/local/include/Eigen/)
target_link_directories(${PROJECT_NAME} PUBLIC /usr/local/include/eigen3/Eigen/)
target_link_libraries(${PROJECT_NAME} ${EXE_LIBS})
All other libraries in the project are successfully linked except Eigen - This is the error message:
[6/6] Linking CXX executable planner_standalone_grasp
FAILED: planner_standalone_grasp
: && /usr/bin/c++ -O0 -fno-diagnostics-color -std=c++17 -g -rdynamic CMakeFiles/planner_standalone_grasp.dir/main.cpp.o CMakeFiles/planner_standalone_grasp.dir/src/Grasp.cpp.o CMakeFiles/planner_standalone_grasp.dir/src/WallEdge.cpp.o CMakeFiles/planner_standalone_grasp.dir/src/WallGraph.cpp.o CMakeFiles/planner_standalone_grasp.dir/src/pt2eigen.cpp.o -o planner_standalone_grasp -L/home/sim/CLionProjects/Test/lib/comrob/lib -L/home/sim/CLionProjects/Test/ctop/common/cmake-build-debug -L/home/sim/CLionProjects/Test/ctop/log/cmake-build-debug -L/home/sim/CLionProjects/Test/ctop/util/cmake-build-debug -L/home/sim/CLionProjects/Test/lib/eigen/Eigen -L/usr/local/include/Eigen -L/usr/local/include/eigen3/Eigen -Wl,-rpath,/home/sim/CLionProjects/Test/lib/comrob/lib:/home/sim/CLionProjects/Test/ctop/common/cmake-build-debug:/home/sim/CLionProjects/Test/ctop/log/cmake-build-debug:/home/sim/CLionProjects/Test/ctop/util/cmake-build-debug:/home/sim/CLionProjects/Test/lib/eigen/Eigen:/usr/local/include/Eigen:/usr/local/include/eigen3/Eigen -lctop_common -lctop_log -lctop_util -leigen -lcrl -lcrl-algorithm -lcrl-loader -lcrl-tsplib -lyaml-cpp && :
/usr/bin/ld: cannot find -leigen
collect2: error: ld returned 1 exit status
ninja: build stopped: subcommand failed.
Any help would be highly appreciated!
In my experience there is two possible causes for this issue:
there is no library named libeigen. in the provided directories (the ones in target_link_directories). Perhaps the path is wrong?
You should know that usually library files are not located in the include directories of a repository...
there is a library named as such, though it was compiled for the wrong platform... i.e. a library compiled for linux cannot be linked if you are making an executable for windows. Usually you can find the source code and compile it yourself.
Hope this helps.
I'm trying to compile freetype2 from source and link it in my own project, but I'm running into a CMake error:
CMake Error: install(EXPORT "freetype-targets" ...) includes target "freetype" which requires target "zlib" that is not in any export set.
Presumably, this means that zlib is not recognizable to the freetype2 target.
I am compiling and using zlib in this project for other things (libpng, specifically), so am I correct in assuming that I simply need to somehow make my compiled zlib available to freetype2? How would I go about doing this?
Here is the entirety of my CMakeLists.txt:
cmake_minimum_required(VERSION 3.17)
project(zgl)
set(CMAKE_CXX_STANDARD 17)
set(SKIP_INSTALL_EXPORT TRUE)
# If this is built standalone, and not part of an embedded project, define the build directory.
string(COMPARE EQUAL ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_SOURCE_DIR} IS_ROOT_PROJECT)
if(IS_ROOT_PROJECT)
if(NOT DEFINED DEPS_INSTALL_PREFIX)
set(DEPS_INSTALL_PREFIX "${CMAKE_BINARY_DIR}/build" CACHE STRING "Installation Prefix" FORCE)
endif()
get_property(CMAKE_INSTALL_PREFIX_DOCS DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY CMAKE_INSTALL_PREFIX FULL_DOCS)
set(CMAKE_INSTALL_PREFIX ${DEPS_INSTALL_PREFIX} CACHE STRING "${CMAKE_INSTALL_PREFIX_DOCS}" FORCE)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_INSTALL_PREFIX}/bin)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_INSTALL_PREFIX}/bin)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_INSTALL_PREFIX}/bin)
set(CMAKE_PDB_OUTPUT_DIRECTORY ${CMAKE_INSTALL_PREFIX}/bin)
endif()
set(THIRD_PARTY_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/third-party)
set(ZLIB_DIRECTORY ${THIRD_PARTY_DIRECTORY}/zlib)
add_subdirectory(${ZLIB_DIRECTORY})
# Explicitly set the ZLIB_BUILD_DIRECTORY for libpng (?)
get_directory_property(ZLIB_BUILD_DIRECTORY DIRECTORY ${ZLIB_DIRECTORY} DEFINITION CMAKE_CURRENT_BINARY_DIR)
option(PNG_LINK_ZLIB_STATIC "Use a static zlib library for libpng builds" OFF)
get_directory_property(zlib DIRECTORY ${ZLIB_DIRECTORY} DEFINITION zlib)
get_directory_property(zlibstatic DIRECTORY ${ZLIB_DIRECTORY} DEFINITION zlibstatic)
if (PNG_LINK_ZLIB_STATIC)
set(ZLIB_LIBRARY zlibstatic)
else()
set(ZLIB_LIBRARY zlib)
endif()
set(ZLIB_INCLUDE_DIR ${ZLIB_DIRECTORY})
set(LIBPNG_DIRECTORY "${THIRD_PARTY_DIRECTORY}/libpng")
if (WIN32)
file(TO_NATIVE_PATH ${LIBPNG_DIRECTORY}/scripts/pnglibconf.h.prebuilt PNGLIBCONF_PATH_SRC)
file(TO_NATIVE_PATH ${LIBPNG_DIRECTORY}/pnglibconf.h PNGLIBCONF_PATH_DST)
execute_process(COMMAND cmd /c copy ${PNGLIBCONF_PATH_SRC} ${PNGLIBCONF_PATH_DST})
endif(WIN32)
include_directories(${ZLIB_DIRECTORY} ${ZLIB_BUILD_DIRECTORY} ${LIBPNG_DIRECTORY} ${LIBPNG_BUILD_DIRECTORY})
add_subdirectory(${LIBPNG_DIRECTORY})
get_directory_property(LIBPNG_BUILD_DIRECTORY DIRECTORY ${LIBPNG_DIRECTORY} DEFINITION CMAKE_CURRENT_BINARY_DIR)
get_directory_property(LIBPNG_STATIC DIRECTORY ${LIBPNG_DIRECTORY} DEFINITION PNG_LIB_NAME_STATIC)
get_directory_property(LIBPNG_SHARED DIRECTORY ${LIBPNG_DIRECTORY} DEFINITION PNG_LIB_NAME)
add_executable(zgl src/main.cpp src/resources/images/Image.cpp src/Game.cpp src/Game.h src/platform/Platform.cpp src/platform/Platform.h src/platform/Window.cpp src/platform/Window.h src/components/GameComponent.cpp src/components/GameComponent.h src/input/InputEvent.h src/input/Joystick.cpp src/input/Joystick.h src/utilities/StringUtilities.cpp src/utilities/StringUtilities.h src/input/InputEvent.cpp src/Actor.cpp src/Actor.h src/Scene.cpp src/Scene.h src/math/Range.h src/components/CameraComponent.cpp src/components/CameraComponent.h src/components/GameComponentCollection.h src/FreeCamera.cpp src/FreeCamera.h src/input/InputManager.cpp src/input/InputManager.h src/math/Rectangle.h src/input/InputSubscription.cpp src/input/InputSubscription.h src/Application.cpp src/Application.h src/math/Interpolation.h src/graphics/Texture.cpp src/graphics/Texture.h src/graphics/Gpu.cpp src/graphics/Gpu.h src/graphics/ColorType.h src/graphics/TextureFormat.h src/input/InputSubscriber.cpp src/input/InputSubscriber.h src/graphics/ColorType.cpp src/resources/images/formats/ImageFormatPng.cpp src/resources/images/formats/ImageFormatPng.h src/resources/ResourceManager.cpp src/resources/ResourceManager.h src/resources/images/formats/ImageFormat.cpp src/resources/images/formats/ImageFormat.h src/resources/Resource.cpp src/resources/Resource.h src/graphics/FrameBuffer.cpp src/graphics/FrameBuffer.h src/graphics/GpuTypes.h src/graphics/GpuProgram.cpp src/graphics/GpuProgram.h src/input/joysticks/XboxController.h src/input/InputAction.cpp src/input/InputAction.h src/utilities/FlagMacros.h src/input/Pointer.cpp src/input/Pointer.h src/input/Keyboard.cpp src/input/Keyboard.h src/input/KeyboardKey.cpp src/input/KeyboardKey.h src/components/FreeCameraControllerComponent.cpp src/components/FreeCameraControllerComponent.h src/components/GameComponentRegistry.cpp src/components/GameComponentRegistry.h src/platform/Cursor.cpp src/platform/Cursor.h src/graphics/GpuBuffer.cpp src/graphics/GpuBuffer.h src/graphics/GpuIndexBuffer.h src/components/MeshComponent.cpp src/components/MeshComponent.h src/graphics/GpuVertexBuffer.h src/resources/mesh/Mesh.cpp src/resources/mesh/Mesh.h src/ActorDefinition.cpp src/ActorDefinition.h src/graphics/CameraParameters.h)
# Compiling GLEW requires CYGWIN to be installed on Windows!
#glew
set(GLEW_DIRECTORY "${THIRD_PARTY_DIRECTORY}/glew-cmake")
message("${GLEW_DIRECTORY}")
add_subdirectory(${GLEW_DIRECTORY})
include_directories(${GLEW_DIRECTORY}/include)
target_link_libraries(zgl libglew_static)
#glfw
set(GLFW_DIRECTORY "${THIRD_PARTY_DIRECTORY}/glfw")
add_subdirectory(${GLFW_DIRECTORY})
include_directories(${GLFW_DIRECTORY}/include)
#opengl
find_package(OpenGL REQUIRED)
include_directories(${OPENGL_INCLUDE_DIRS})
#freetype
set(FREETYPE_DIRECTORY "${THIRD_PARTY_DIRECTORY}/freetype2")
add_subdirectory(${FREETYPE_DIRECTORY})
include_directories(${FREETYPE_DIRECTORY}/include)
#glm
set(GLM_DIRECTORY "${THIRD_PARTY_DIRECTORY}/glm")
include_directories(${GLM_DIRECTORY})
#yaml-cpp
set(YAML_DIRECTORY "${THIRD_PARTY_DIRECTORY}/yaml-cpp")
add_subdirectory(${YAML_DIRECTORY})
set(YAML_LIBRARIES yaml-cpp)
include_directories(${YAML_DIRECTORY}/include)
#magic_enum
set(MAGIC_ENUM_DIRECTORY "${THIRD_PARTY_DIRECTORY}/magic_enum")
include_directories(${MAGIC_ENUM_DIRECTORY}/include)
#zgl
set(ZGL_SRC_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/src")
include_directories(${ZGL_SRC_DIRECTORY})
target_link_libraries(zgl ${OPENGL_LIBRARIES})
target_link_libraries(zgl ${ZLIB_LIBRARY})
target_link_libraries(zgl ${FREETYPE_LIBRARY})
target_link_libraries(zgl ${LIBPNG_STATIC})
target_link_libraries(zgl glfw ${GLFW_LIBRARIES})
target_link_libraries(zgl ${BULLET3_LIRRARIES})
target_link_libraries(zgl ${YAML_LIBRARIES})
target_include_directories(zgl PUBLIC ${ZLIB_DIRECTORY})
target_include_directories(zgl PUBLIC ${LIBPNG_DIRECTORY})
The error message
CMake Error: install(EXPORT "freetype-targets" ...) includes target "freetype" which requires target "zlib" that is not in any export set.
refers to lines
install(
TARGETS freetype
EXPORT freetype-targets
<...>)
in the freetype2's CMakeLists.txt.
These lines mark freetype target for installation and add this target to the export set, so that installation could be found via find_package.
The target freetype is linked with the target zlib because you specify
set(ZLIB_LIBRARY zlib)
And here the problem CMake points to:
while zlib target is installed, it is part of none export sets.
Because of that CMake doesn't know how to translate linkage of freetype with zlib after they are installed, so CMake is unable to generate config file for freetype installation.
For overcome the error, you may tell CMake to link freetype with ALIAS library instead:
add_library(ZLIB::ZLIB ALIAS zlib)
set(ZLIB_LIBRARY ZLIB::ZLIB)
CMake knows that ALIAS targets are never installed, and won't emit an error.
Note, that while with ALIAS target the error will be gone, find_package still won't work for the installed freetype2. But otherwise the installation will be correct and usable.
I am trying to install AirSim/Unity on MacOS Catalina. When I run Unity/build.sh I get a fatal error:
In file included from /Users/nfirbas/Documents/AirSim/Unity/AirLibWrapper/AirsimWrapper/Source/Logger.cpp:3:
/Users/nfirbas/Documents/AirSim/Unity/AirLibWrapper/AirsimWrapper/Source/Logger.h:6:11: fatal error: 'boost/filesystem.hpp' file not found
#include <boost/filesystem.hpp>
^~~~~~~~~~~~~~~~~~~~~~
1 warning and 1 error generated.
make[2]: *** [CMakeFiles/AirsimWrapper.dir/Source/Logger.cpp.o] Error 1
make[2]: *** Waiting for unfinished jobs....
I have installed boost with brew. It's my first time working with brew so I assume that I need to edit my CMakeList.txt. I tried changing it myself but I didn't get it working.
My CMakeLists.txt:
cmake_minimum_required(VERSION 3.5.0)
if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
set(MACOSX TRUE)
endif()
find_path(AIRSIM_ROOT NAMES AirSim.sln PATHS ".." "../.." "../../.." "../../../.." "../../../../.." "../../../../../..")
message(AirSim Root directory: ${AIRSIM_ROOT})
LIST(APPEND CMAKE_MODULE_PATH "${AIRSIM_ROOT}/cmake/cmake-modules")
LIST(APPEND CMAKE_MODULE_PATH "${RPC_SOURCE_DIR}/cmake")
LIST(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
INCLUDE("${AIRSIM_ROOT}/cmake/cmake-modules/CommonSetup.cmake")
INCLUDE("${CMAKE_CURRENT_SOURCE_DIR}/cmake/rpc-setup.cmake")
INCLUDE("${CMAKE_CURRENT_SOURCE_DIR}/cmake/mav-setup.cmake")
INCLUDE("${CMAKE_CURRENT_SOURCE_DIR}/cmake/airlib-setup.cmake")
INCLUDE("${CMAKE_CURRENT_SOURCE_DIR}/cmake/airsimwrapper-setup.cmake")
IncludeEigen()
project(AirsimWrapper VERSION 0)
# RPC includes & source files
BuildRpc()
# MavLink source files
BuildMavLink()
#AirLib source files
BuildAirlib()
#AirsimWrapper source files
BuildAirsimWrapper()
###################### Link source files to library ######################################
if (${APPLE})
add_library(
${PROJECT_NAME} MODULE
${RPC_LIBRARY_SOURCE_FILES}
${MAVLINK_LIBRARY_SOURCE_FILES}
${AIRLIB_LIBRARY_SOURCE_FILES}
${AIRSIMWRAPPER_LIBRARY_SOURCE_FILES}
)
set_target_properties(${PROJECT_NAME} PROPERTIES BUNDLE TRUE)
else ()
add_library(
${PROJECT_NAME} SHARED
${RPC_LIBRARY_SOURCE_FILES}
${MAVLINK_LIBRARY_SOURCE_FILES}
${AIRLIB_LIBRARY_SOURCE_FILES}
${AIRSIMWRAPPER_LIBRARY_SOURCE_FILES}
)
endif ()
target_link_libraries(${PROJECT_NAME} ${CMAKE_THREAD_LIBS_INIT} -lstdc++ -lpthread -lboost_filesystem)
##################### Build Options #############################3
# Rpc
RpcCheckMSVN()
RpcCmakePkg()
RpcMSVNConfig()
You have told your library target to link against boost_filesystem, but you did not convey in your CMake where to find the Boost header files.
The idiomatic way to find Boost using CMake is to use the configuration files that now ship with Boost (e.g. BoostConfig.cmake), as of Boost version 1.70 and greater. You can make use of these by calling find_package(Boost ...), then linking with the imported target Boost::filesystem:
# Tell CMake to locate Boost on your machine, specifically
# looking for the filesystem library.
find_package(Boost REQUIRED COMPONENTS filesystem)
...
# Link the Boost::filesystem target, which includes the Boost headers.
target_link_libraries(${PROJECT_NAME} PUBLIC
${CMAKE_THREAD_LIBS_INIT}
-lstdc++
-lpthread
Boost::filesystem
)
This will pull in the Boost headers as well, so you don't need an explicit call to target_include_directories() to specify where the Boost headers are.
Note: To ensure the headers are installed on your system, you may need to install boost-devel, in addition to your boost installation.
Here is my compiler part of my config:
IF(UNIX)
## Compiler flags
# specify the cross compiler
SET(CMAKE_C_COMPILER /home/username/projects/buildroot/output/host/usr/bin/arm-linux-gcc)
SET(CMAKE_CXX_COMPILER /home/username/projects/buildroot/output/host/usr/bin/arm-linux-g++)
if(CMAKE_COMPILER_IS_GNUCXX)
set(CMAKE_CXX_FLAGS "-O3")
set(CMAKE_EXE_LINKER_FLAGS "-lsqlite3 -lrt -lpthread")
endif()
target_link_libraries(complex
${Boost_FILESYSTEM_LIBRARY}
${Boost_SYSTEM_LIBRARY})
ENDIF(UNIX)
There are 3 problems : -lsqlite3 -lrt -lpthread
How must I to make them for my architecture and specify here? How to set (using set?) the path of compiled libraries after I will get them recompiled for my architecture somehow?
If you want to do cross-compilation with CMake you really should use a toolchain file for that. See the CMake Wiki for an introduction. In order to use third-party libraries (i.e. not included by the cross-compilation toolchain) you need to cross-compile them too.
Edit: Since you are using the buildroot toolchain, you can use the already included CMake toolchain file. Just pass -DCMAKE_TOOLCHAIN_FILE=/home/username/projects/buildroot/output/toolchainfile.cmake when invoking CMake. No need to set CMAKE_C_COMPILER and CMAKE_CXX_COMPILER in your CMakeLists.txt file. Also, setting CMAKE_CXX_FLAGS and CMAKE_EXE_LINKER_FLAGS is considered to be very bad practice.
Presumably you have built sqlite3 while building the buildroot toolchain, so you can use it just like any other library. I.e:
find_path(SQLITE3_INCLUDE_DIR sqlite3.h)
find_library(SQLITE3_LIBRARY sqlite3)
if(NOT SQLITE3_INCLUDE_DIR)
message(SEND_ERROR "Failed to find sqlite3.h")
endif()
if(NOT SQLITE3_LIBRARY)
message(SEND_ERROR "Failed to find the sqlite3 library")
endif()
find_package(Threads REQUIRED)
# ...
target_link_libraries(complex
${Boost_FILESYSTEM_LIBRARY}
${Boost_SYSTEM_LIBRARY}
${SQLITE3_LIBRARY}
${CMAKE_THREAD_LIBS_INIT}
rt)
Lastly, do not set CMAKE_CXX_FLAGS to -O3. The user should pass -DCMAKE_BUILD_TYPE=Release when configuring the project instead.
You'll have to cross-compile the dependencies as well. The path depends on where you install them.
Btw., using -lpthread is not the safe way of getting POSIX threads. You should give the option -pthread to both the compiler and the linker.
I'm trying to make it same way I made it for boost :
find_package(Boost COMPONENTS system filesystem REQUIRED)
find_package(ProtocolBuffers)
## Compiler flags
if(CMAKE_COMPILER_IS_GNUCXX)
set(CMAKE_CXX_FLAGS "-O2")
set(CMAKE_EXE_LINKER_FLAGS "-lsqlite3 -lrt -lpthread")
endif()
target_link_libraries(complex
${Boost_FILESYSTEM_LIBRARY}
${Boost_SYSTEM_LIBRARY}
${PROTOBUF_LIBRARY}
)
(googled it somewhere) but got bad output:
CMake Warning at complex/CMakeLists.txt:18 (find_package):
Could not find module FindProtocolBuffers.cmake or a configuration file for
package ProtocolBuffers.
Adjust CMAKE_MODULE_PATH to find FindProtocolBuffers.cmake or set
ProtocolBuffers_DIR to the directory containing a CMake configuration file
for ProtocolBuffers. The file will have one of the following names:
ProtocolBuffersConfig.cmake
protocolbuffers-config.cmake
How can I link it with cmake? or maybe I even can compile .proto file using cmake?
You could try CMake's FindProtobuf module:
include(FindProtobuf)
find_package(Protobuf REQUIRED)
include_directories(${PROTOBUF_INCLUDE_DIR})
...
target_link_libraries(complex
${Boost_FILESYSTEM_LIBRARY}
${Boost_SYSTEM_LIBRARY}
${PROTOBUF_LIBRARY}
)
For further info, run
cmake --help-module FindProtobuf
Spent a lot of time on this..
A. Different versions may require regeneration of cc files (obviously)
B. Different versions have different naming (PROTOBUF_LIBRARY vs. Protobuf_LIBRARIES)
Do note that the previous answer refers to view the FindProtobuf help which states the naming convention.
Also, Use '''message(STATUS "debug protobuf lib location:${PROTOBUF_LIBRARIES} '''
to debug.