Search code examples
rcppasio

Linking problem with R package AsioHeaders


I am using Asio in a Rcpp package, and am therefore using the package AsioHeaders.

I have added BH and AsioHeaders in the "LinkingTo" part of the DESCRIPTION file of my package. I have also added comments

// [[Rcpp::depends(BH)]]
// [[Rcpp::depends(AsioHeaders)]]

in my code. So normally, the linking should be fine when compiling the package.

And it is when I compile it on Linux. But when trying to compile it on Windows, I get linking errors that are solved by linking -lws2_32 and -lwsock32.

I am thus wondering, whether I should edit the Makevars file so that these are linked on Windows but ignored on Linux, or if I have done something wrong using AsioHeaders?


Solution

  • AsioHeaders maintainer here. Quick questions:

    1. Which version of AsioHeaders? It just updated at CRAN. Is this a change from the new version (which would suprise me ...)?

    2. Make sure you are not accidentally using Asio functionality from Boost which will require linking. See the three packages using AsioHeaders.

    If your package is truly header-only then LinkingTo: is all you need. R will find the header directories for you. In particular, you do not need link instructions in src/Makevars* because, well, header-only.

    Also, you probably meant // forward slashes for your C++ comments above...