You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
target_link_libraries(main PRIVATE rust_staticlib m)
results in
/usr/bin/cc -g "main.c.o" -o main -lm librust_staticlib.a
leading to
/build/rustc-Oic09u/rustc-1.65.0+dfsg0ubuntu1/library/std/src/f64.rs:88: undefined reference to `round'
.
Expected Behavior
Using
target_link_libraries(main PRIVATE rust_staticlib m)
results in
/usr/bin/cc -g "main.c.o" -o main librust_staticlib.a -lm
leading to successful build.
Steps To Reproduce
https://github.com/hoehermann/purple-presage in I am trying to link a rust staticlib into a shared object. The staticlib seems to need some math functions, so I added m to the target_link_libraries stanza:
add_executable(main "src/c/main.c")
target_link_libraries(main PRIVATE rust_staticlib m)
Am I using corrosion wrong? Or is this a common CMake issue I have not encountered so far?
Edit: to expand a bit. The actual issue here in my opinion is that corrosion doesn't link in libm automatically for you. Unless you turned off the option, e.g. by passing NO_STD to corrosion_import_crate, I would like to know which version of corrosion this occured on.
In response to the question you asked:
As far as I know CMake doesn't guarantee a particular order for the libraries for a specific target and is free to reorder. The issue you are facing is because you are declaring libm to be a dependency of main, when it actually is a dependency of your rust static lib. As such you should do target_link_libraries(your_rust_lib INTERFACE c_lib).
Cmake is aware of the dependency in this case and will order them accordingly.
But again, for libm corrosion should do this automatically.
Current Behavior
Using
results in
leading to
.
Expected Behavior
Using
results in
leading to successful build.
Steps To Reproduce
https://github.com/hoehermann/purple-presage in I am trying to link a rust staticlib into a shared object. The staticlib seems to need some math functions, so I added
m
to thetarget_link_libraries
stanza:Am I using corrosion wrong? Or is this a common CMake issue I have not encountered so far?
This may or may not be related to #335.
I added the verbose outputs as requested. I hope it helps in spite of the libpurple stuff adding a lot of clutter.
Environment
CMake configure log with Debug log-level
CMake Build step log
The text was updated successfully, but these errors were encountered: