I am trying to build QPid Messageing API C++ from here.
I downloaded all the required dependencies including Boost. However, I’m getting ‘No Uuid API found’ error. uuid/uuid.h is present in usr/include. Then why is Cmake not able to find it?
This is the part of code throwing the error:
CHECK_SYMBOL_EXISTS(uuid_generate "uuid/uuid.h" UUID_GENERATE_IN_LIBC)
if (UUID_GENERATE_IN_LIBC)
set(uuid_SRC "")
set(uuid_LIB "")
message(STATUS "uuid_generate exists in LIBC")
else (UUID_GENERATE_IN_LIBC)
message(STATUS "uuid_generate does not exists in LIBC")
CHECK_LIBRARY_EXISTS (uuid uuid_generate "" UUID_GENERATE_IN_UUID)
if (UUID_GENERATE_IN_UUID)
set(uuid_SRC "")
set(uuid_LIB uuid)
message(STATUS "uuid_generate exists in boost uuid")
else (UUID_GENERATE_IN_UUID)
message(STATUS "uuid_generate does not exists in boost uuid")
CHECK_SYMBOL_EXISTS(uuid_create "uuid.h" UUID_CREATE_IN_LIBC)
if (UUID_CREATE_IN_LIBC)
set(uuid_SRC qpid/sys/FreeBSD/uuid.cpp)
set(uuid_LIB "")
message(STATUS "uuid_create exists in LIBC")
else (UUID_CREATE_IN_LIBC)
message(STATUS "uuid_create does not exists in LIBC")
CHECK_SYMBOL_EXISTS(UuidToString "rpc.h" WIN_UUID)
if (WIN_UUID)
set(uuid_SRC qpid/sys/windows/uuid.cpp)
set(uuid_LIB rpcrt4)
else (WIN_UUID)
message(FATAL_ERROR "No Uuid API found")
endif (WIN_UUID)
endif (UUID_CREATE_IN_LIBC)
endif (UUID_GENERATE_IN_UUID)
endif (UUID_GENERATE_IN_LIBC)
I added message(STATUS "uuid_generate exists in LIBC")
, message(STATUS "uuid_generate exists in boost uuid")
, message(STATUS "uuid_create exists in LIBC")
for debugging.
This is the output I get:
–uuid_generate does not exists in LIBC
— uuid_generate does not exists in boost uuid
— uuid_create does not exists in LIBC
CMake Error at src/CMakeLists.txt:344 (message):
No Uuid API found
This snippet is from CMakeError.log:
/root/qpid-cpp-1.39.0/build/CMakeFiles/CMakeTmp/CheckSymbolExists.c:2:10: fatal error: uuid/uuid.h: No such file or directory
2 | #include <uuid/uuid.h>
| ^~~~~~~~~~~~~
compilation terminated.
gmake[1]: *** [CMakeFiles/cmTC_e8f4a.dir/build.make:78: CMakeFiles/cmTC_e8f4a.dir/CheckSymbolExists.c.o] Error 1
gmake[1]: Leaving directory ‘/root/qpid-cpp-1.39.0/build/CMakeFiles/CMakeTmp’
gmake: *** [Makefile:127: cmTC_e8f4a/fast] Error 2
File /root/qpid-cpp-1.39.0/build/CMakeFiles/CMakeTmp/CheckSymbolExists.c:
/* */
`
#include <uuid/uuid.h>
int main(int argc, char** argv)
{
(void)argv;
#ifndef uuid_generate
return ((int*)(&uuid_generate))[argc];
#else
(void)argc;
return 0;
#endif
}
`**
These are some of the debug statements I used in the CMakeLists.txt file to make sure uuid library is present:
message(STATUS "boost dir: ${Boost_INCLUDE_DIR}")
message(STATUS "boost lib: ${Boost_LIBRARY_DIRS}")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -luuid")
message(STATUS "CMAKE_C_FLAGS: ${CMAKE_C_FLAGS}")
find_package(PkgConfig REQUIRED)
pkg_check_modules(UUID REQUIRED uuid)
include_directories(${UUID_INCLUDE_DIRS})
link_directories(${UUID_LIBRARY_DIRS})
message(STATUS "uuid dir : ${UUID_INCLUDE_DIRS}")
message(STATUS "uuid lib: ${UUID_LIBRARY_DIRS}")
find_library(UUID_LIBRARY uuid)
link_libraries(uuid)
if(UUID_LIBRARY)
message(STATUS "UUID library found")
else()
message(FATAL_ERROR "UUID library not found")
endif()
This is the output:
boost dir: /usr/include
— boost lib: /usr/lib/x86_64-linux-gnu
— CMAKE_C_FLAGS: -luuid
— uuid dir : /usr/include/uuid
— uuid lib: /usr/lib/x86_64-linux-gnu
— UUID library found
Then why is CHECK_SYMBOL_EXSISTS unable to find uuid_generate?
2