I have a C++ program A where I use two libraries B and C which are basically wrappers of bigger libraries, Y and Z (included with "extern "C"). I would like to be able to run both in the same program.
It is a cmake project.
I have both wrappers B and C in different subdirectories of my project, and the libraries Y and Z that they "wrap" are in subdirectories inside each corresponding subdirectory.
No header is included other than my wrappers' headers.
The functions from B and C have different names and namespaces, and also the functions used from Y and Z are different. But unfortunately, these functions are calling other functions defined in Y and Z, that have the same name and arguments, and this results in a runtime error (function from Y calls the function from Z instead of its own).
I would like to solve this issue without having to write two different programs that communicate between each other. I already tried making B, C, Y and Z as static libraries.
- Tried the renaming option in the linked question "C function conflict". It got me into really big trouble. Maybe there is something else that needs fixing in the way the CMakefiles are built.
The .lib option didn't work. I did what is detailed in CMake documentation:
add_library(foo STATIC foo1.c) install(TARGETS foo DESTINATION lib EXPORT myproj-targets) install(EXPORT myproj-targets DESTINATION lib/myproj)
And for including them:
include(${PREFIX}/lib/myproj/myproj-targets.cmake) add_executable(myexe src1.c) target_link_libraries(myexe foo)