When --enable-fvisibility is passed to configure, all of the symbols in
libncurses++.so are made local. This prevents applications from properly
linking against it. It also prevents applications from using the default
main() function ncurses provides for the NCursesApplication interface.
This patch was generated using snapshot v6_6_20260314 as the base version.
Code configured using
../configure --enable-fvisibility --with-cxx --with-cxx-binding \
--with-cxx-shared --with-shared
GCC version: gcc (Gentoo 15.2.1_p20260214 p5) 15.2.1 20260214
uname: Linux obsidian 6.19.6-gentoo #1 SMP PREEMPT \
Mon Mar 9 19:05:47 EDT 2026 x86_64 AMD Ryzen 9 7950X 16-Core \
Processor AuthenticAMD GNU/Linux
Signed-off-by: Nicholas Vinson <[email protected]>
---
c++/Makefile.in | 1 +
c++/cursesw.h | 5 ++---
c++/etip.h.in | 2 +-
include/ncurses_dll.h.in | 9 +++++++--
4 files changed, 11 insertions(+), 6 deletions(-)
diff --git a/c++/Makefile.in b/c++/Makefile.in
index f03468bb5..a7d52cd04 100644
--- a/c++/Makefile.in
+++ b/c++/Makefile.in
@@ -276,6 +276,7 @@ demo$x: $(OBJS_DEMO) \
etip.h: $(srcdir)/etip.h.in $(srcdir)/edit_cfg.sh
cp $(srcdir)/etip.h.in $@
$(SHELL) $(srcdir)/edit_cfg.sh ../include/ncurses_cfg.h $@
+ $(AWK) -v val='@NCURSES_CXX_IMPEXP@'
'{gsub(/\100NCURSES_CXX_IMPEXP\100/, val)} 1' $@ > [email protected] && mv [email protected] $@
# Verify that each header-file can be compiled without including another.
check ::
diff --git a/c++/cursesw.h b/c++/cursesw.h
index 10481a222..d3fde4d6b 100644
--- a/c++/cursesw.h
+++ b/c++/cursesw.h
@@ -36,9 +36,8 @@
#include <curses.h>
-#if defined(BUILDING_NCURSES_CXX)
-# define NCURSES_CXX_IMPEXP NCURSES_EXPORT_GENERAL_EXPORT
-#else
+#if not defined(BUILDING_NCURSES_CXX)
+# undef NCURSES_CXX_IMPEXP
# define NCURSES_CXX_IMPEXP NCURSES_EXPORT_GENERAL_IMPORT
#endif
diff --git a/c++/etip.h.in b/c++/etip.h.in
index 193c29875..86c8b043e 100644
--- a/c++/etip.h.in
+++ b/c++/etip.h.in
@@ -173,7 +173,7 @@ int endwin(void); // needed for the configure check
#endif
#ifndef NCURSES_CXX_IMPEXP
-#define NCURSES_CXX_IMPEXP /* nothing */
+#define NCURSES_CXX_IMPEXP @NCURSES_CXX_IMPEXP@
#endif
// Forward Declarations
diff --git a/include/ncurses_dll.h.in b/include/ncurses_dll.h.in
index 401d47a81..fb0bc7e20 100644
--- a/include/ncurses_dll.h.in
+++ b/include/ncurses_dll.h.in
@@ -92,8 +92,13 @@
# define NCURSES_API __cdecl
#else
# define NCURSES_EXPORT_GENERAL_IMPORT
-# if (__GNUC__ >= 4) && !defined(__cplusplus)
-# define NCURSES_EXPORT_GENERAL_EXPORT __attribute__((visibility
("default")))
+# if (__GNUC__ >= 4)
+# if defined(__cplusplus)
+# define NCURSES_CXX_IMPEXP @NCURSES_CXX_IMPEXP@
+# else
+# define NCURSES_EXPORT_GENERAL_EXPORT __attribute__((visibility
("default")))
+# define NCURSES_CXX_IMPEXP
+# endif
# else
# define NCURSES_EXPORT_GENERAL_EXPORT
# endif
--
2.53.0