I need some guidance on creating a shared library using CMake. My C++ project is already configured in Visual Studio, with the target set to generate a DLL library. I now need to create a shared library using the same C++ project.
I’ve set up most of the configuration, but I’m unsure how to properly add or link the external dependencies required for compilation and achieving the desired output. Any advice or examples would be greatly appreciated.
Thanks for your reply. I have created a script named “CMakeLists.txt” in the same directory as the other project files. In this script, I added links to external dependencies to the best of my knowledge. However, when I attempt to build the code to generate a .so file, I encounter the following error originating from the C++ header file see (attached screenshots below).
Text is better to be shared as text, not as pictures of text
I have created a script named CMakeLists.txt
Like I said, it would be useful to take a look at its contents to see what you have done so far.
From the error message it seems that at least one headers path is missing from the project.
if (GSL_LIB AND GSL_CBLAS_LIB)
target_link_libraries(TUBSsalt_permd PRIVATE ${GSL_LIB} ${GSL_CBLAS_LIB})
else()
message(FATAL_ERROR “GSL or GSL CBLAS library not found.”)
endif()
That would look much better if you put it into a code block.
Okay, from what I see in the GSL package (is that the one?), it does not contain the conmodel.h file. So apparently this header is from a different package/library, which you don’t seem to be linking to. Do you even have this file on your disk, where is it located?
What is the path to that “external dependencies folder”, who put it there? And what Visual Studio has to do with this, will the file disappear if you don’t open your project in Visual Studio?
It’s there because of the configuration of the project in Visual Studio using GSL and all other required dependencies. The aim of configuration was to create a dll library using VS code.
You don’t seem to be understanding me. The error on your screenshot of a text says that compiler couldn’t find that file, which means that it isn’t added to the project include paths. So what is the path to that conmodel.h file on your disk (and as a bonus question, who put it there)?