Linking THttpServer with CMake

I am trying to compile a standalone C++ project that links to ROOT and in particular THttpServer.

I can successfuly run the server in the ROOT terminal (new THttpServer();), but I cannot manage to build a cmake project that links to it, however I can link to other ROOT classes alright.

I can include the headers (#include <THttpServer.h>) and it compiles, but when I try to instantiate the class I get undefined reference to THttpServer::THttpServer(char const*)'`. I believe this is due to linking issues.

In my CMakeLists.txt I am doing find_package(ROOT REQUIRED) and then on the target_link_libraries I am including ${ROOT_LIBRARIES}. I think I probably need to include some additional libraries here, but I can’t find the solution online or with root-config.

Thanks!

Hi,
try adding ROOT::RHTTP to find_package and target_link_libraries, that should be it (found by looking at $ROOTSYS/net/http/CMakeLists.txt).

Cheers,
Enrico

Thanks! it works. Actually it is enough to add it to target_link_libraries. I guess this should be explained somewhere right? perhaps in HTTP Server.

Adding it to find_package should additionally make sure that it fails if it finds a ROOT installation that does not provide ROOT::RHTTP.

I think it should be explained generically for all ROOT components at Integrating ROOT into CMake projects - ROOT . PRs are welcome, or even just an issue at Issues · root-project/web · GitHub .

Cheers,
Enrico

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.