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
This is wrong because the C++ standard library being used might not be libstdc++; the default C++ standard library on macOS has been libc++ since OS X 10.9. Because this mistake is so common the linker seems to silently transform -lstdc++ to -lc++ to correct the problem, but it would be better not to make the mistake in the first place.
Usually, when you're linking stuff that came from C++ code, I've seen projects use the C++ compiler (not the C compiler) as the linker; that way, you don't have to specify to link with a C++ standard library. Make sure to use the CXXFLAGS environment variable when you do so in case the user has specified a -stdlib flag there that differs from what the default C++ standard library is.
The text was updated successfully, but these errors were encountered:
CXXFLAGS is not used for linking, though, as that would add compile-time flags to the linker command line. To use an alternative stdlib, the -stdlib option should be added to both, CXXFLAGS and LDFLAGS.
The build system uses the C compiler as the linker and adds the flag
-lstdc++
, for example:This is wrong because the C++ standard library being used might not be libstdc++; the default C++ standard library on macOS has been libc++ since OS X 10.9. Because this mistake is so common the linker seems to silently transform
-lstdc++
to-lc++
to correct the problem, but it would be better not to make the mistake in the first place.Usually, when you're linking stuff that came from C++ code, I've seen projects use the C++ compiler (not the C compiler) as the linker; that way, you don't have to specify to link with a C++ standard library. Make sure to use the
CXXFLAGS
environment variable when you do so in case the user has specified a-stdlib
flag there that differs from what the default C++ standard library is.The text was updated successfully, but these errors were encountered: