Description
Spent about 2 days trying to debug an issue with linking to OpenGL which is being called from C++ code connected via cxx and a couple other system libraries. This issues turned out to be because the cargo:rustc-link-lib
was putting the link too early in the linking command and needed to be at the end of the cc
call.
This was not an issue on Windows because (as far as I can tell anyway) msvc
does not care about the ordering as much, but is on Linux.
While this is a very niche issue for rust as a whole, I am sure it is significantly more common among users of cxx
. From what I can tell, this is an issue with cases where your C/C++ code connected via cxx
needs to link to system libraries.
This is not a bug with cxx, however, I think it would be helpful if a reference to rustflags
(specifically with -C link-arg=
for linking) in the docs, and also a reference to the nightly cargo feature extra-link-arg
which allows for adding these in the build.rs
script.