Repository navigation
[BUG] Failure to compile when using libc++ rather than libstdc++ #663
Description
Describe the bug
ncmpcpp fails to compile when CXXFLAGS include -stdlib=libc++ with both clang and gcc.
To Reproduce
Steps to reproduce the behavior:
-
on a gentoo system with an llvm profile:
emerge ncmpcpp
-
on any system:
git clone https://github.com/ncmpcpp/ncmpcpp.gitcd ncmpcppautoreconf./configure CXX=clang++ LD=ld.lld(or CXX=g++, LD=ld.bfd)sed -i 's/^CXXFLAGS = /CXXFLAGS = -stdlib=libc++ /' Makefile src/Makefile
For some reason (at least on my system), setting CXXFLAGS in the cmdline of ./configure results in configure failing to find boost libs, even when--with-boost=$BOOST_PATH. No idea what is going on with that, and it wasn't particularly related to the problem. Accordingly I just ran the Makefiles configure generates through sed.make -j$(nproc)
Expected behavior
ncmpcpp compiles.
Screenshots/Logs
attached are the outputs of make(1) compiling against libc++ with gcc and clang.
Desktop (please complete the following information):
- OS: gentoo on default/linux/amd64/23.0/split-usr/musl/llvm profile
- Terminal: N/A
- Version: HEAD, 0.10.1
I reproduced the same issue on another gentoo system, this one using a normal glibc/gcc profile. Because the issue is compiler/STL specific, I of course had libc++ installed on the reproducing system and was using that with clang, but that I reproduced this on a more normal system demonstrates that the issue isn't caused from some weirdness arising from musl or something like that.
Additional context
For some reason, the following patch makes ncmpcpp compile properly with libc++ with clang. It still fails to build with gcc (due to all the -Wtemplate-body errors), but all the weird type errors about iterators and LocaleBasedSorting are no longer present.
diff --git a/src/screens/sel_items_adder.cpp b/src/screens/sel_items_adder.cpp
index e48eeac6..469aba0a 100644
--- a/src/screens/sel_items_adder.cpp
+++ b/src/screens/sel_items_adder.cpp
@@ -253,7 +253,7 @@ void SelectedItemsAdder::populatePlaylistSelector(BaseScreen *old_screen)
std::bind(&Self::addToExistingPlaylist, this, it->path())
));
};
- std::sort(m_playlist_selector.beginV()+begin, m_playlist_selector.endV(),
+ std::stable_sort(m_playlist_selector.beginV()+begin, m_playlist_selector.endV(),
LocaleBasedSorting(std::locale(), Config.ignore_leading_the));
if (begin < m_playlist_selector.size())
m_playlist_selector.addSeparator();I am not a C++ programmer (I just like messing with, finding novel ways to break computers), so I am not really sure what is going on here. I'm not convinced that this is a bug with ncmpcpp (it seems more likely that this is a bug in libc++? Why on earth would std::stable_sort() accept iterators that std::sort() doesn't? I don't know, I'm not a C++ programmer), so I don't expect this to be fixed here and will be submitting this to gentoo's bugtracker when I can get to it also. That in mind, this is the only program I have had issue with thus far when building things against libc++ instead of libstdc++, so I'm curious for any insight anyone here may have.
Activity
namtsui commentedon Aug 27, 2026
I am seeing this in openbsd when compiling ncmpcpp against a test update to libcxx22 (19.1.7 --> 22.1.6)
namtsui commentedon Aug 27, 2026
Patching /usr/include/c++/v1/__algorithm/sift_down.h as a crude hack, to be more similar to 19.1.7, worked. I had a theory that there was something wrong with the brackets operator because there were errors such as:
I'll keep poking around at LocaleBasedSorting in src/utility/comparators.h or maybe boost::iterators::transform_iterator. Maybe they have some relationship with the brackets operator.
build log:
build_log.txt
/usr/include/c++/v1/__algorithm/sift_down.h:
Work around build failure with libc++ >= 22