Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Linker error with base units for "numerical_value_in()" #566

Open
sa2thoms opened this issue Apr 21, 2024 · 4 comments
Open

Linker error with base units for "numerical_value_in()" #566

sa2thoms opened this issue Apr 21, 2024 · 4 comments

Comments

@sa2thoms
Copy link

sa2thoms commented Apr 21, 2024

I made a simple test program to try out the library (I am using Apple Clang 15). I am consuming the library using plain Cmake. I found an interesting problem where I can use the "numerical_value_in()" function for any combination of units except for the base units. For example:

speed.numerical_value_in(Mm/Ms) // works fine (megameters per megasecond)

speed.numerical_value_in(km/s) // works fine (kilometers per second)

speed.numerical_value_in(m/h) // works fine (meters per hour)

speed.numerical_value_in(m/s) // linker error!

This is the specific linker error I see:
[build] "auto mp_units::detail::expr_divide<mp_units::derived_unit, mp_units::one, mp_units::detail::type_list_of_unit_less, mp_units::si::metre, mp_units::si::second>(mp_units::si::metre, mp_units::si::second)", referenced from:
[build] auto mp_units::operator/<mp_units::si::metre, mp_units::si::second>(mp_units::si::metre, mp_units::si::second) in main.cpp.o
[build] ld: symbol(s) not found for architecture arm64
[build] clang: error: linker command failed with exit code 1 (use -v to see invocation)

@mpusz
Copy link
Owner

mpusz commented Apr 22, 2024

Interesting, can you repro your specific case in the Compiler Explorer (https://godbolt.org)?

@sa2thoms
Copy link
Author

Interesting, can you repro your specific case in the Compiler Explorer (https://godbolt.org)?

I cannot, at least not with clang 17 or clang 16. I guess compiler explorer can't use Apple Clang. I put my code in a public github repo though, so if you want to see exactly what I did it's here: https://github.com/sa2thoms/mp-units-sandbox/blob/main/src/main.cpp

@mpusz
Copy link
Owner

mpusz commented Apr 22, 2024

I do not have access to Apple, so I can't check if there is no repro with other compilers. Apple Clang 15 is a poor compiler, and I hope a new one will be released soon with better support.

@sa2thoms
Copy link
Author

Okay, maybe I can just blame it on Apple then. I can always use something else. For my real (work) applications though, we are using MSVC for debugging and testing purposes sometimes, so that may pose a barrier to using this library for now, if we can't build in MSVC.

And of course we are compiling on Clang with localization disabled, so that needs to be solved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants