[PATCH] link -lintl at the end

Philippe Baril Lecavalier <[email protected]> Wed, 23 Apr 2025 07:34:26 -0400
Newsgroups gmane.editors.nano.devel
Message-ID <CABu4Xf6v=0vMpHc6L5=KCXpu0R6OvDaB4cSwW_VCcSjw4Ptx3A@mail.gmail.com>
Greetings,

I recently packaged nano for Cygwin, bumping from 4.9 to 8.0. It was orphaned.

Not the latest out yet, as I had trouble building recent versions:

    /usr/lib/gcc/x86_64-pc-cygwin/12/../../../../x86_64-pc-cygwin/bin/ld:
../lib/libgnu.a(libgnu_a-regex.o): in function `rpl_regerror':
    /usr/src/debug/nano-8.3-1/lib/regcomp.c:511:(.text+0xe044):
undefined reference to `libintl_dgettext'
    /usr/lib/gcc/x86_64-pc-cygwin/12/../../../../x86_64-pc-cygwin/bin/ld:
../lib/libgnu.a(libgnu_a-regex.o): in function
`rpl_re_compile_pattern':
    /usr/src/debug/nano-8.3-1/lib/regcomp.c:221:(.text+0xd91f):
undefined reference to `libintl_dgettext'
    collect2: error: ld returned 1 exit status
    make[2]: *** [Makefile:2248: nano.exe] Error 1
    make[2]: Leaving directory '/home/pbari/updates/nano-8.3-1.x86_64/build/src'
    make[1]: *** [Makefile:2239: all-recursive] Error 1
    make[1]: Leaving directory '/home/pbari/updates/nano-8.3-1.x86_64/build'
    make: *** [Makefile:2180: all] Error 2
    *** ERROR: make failed

Could not find any relevant difference between versions in makefiles.

Then I just tried this (enclosed patch). And now I can build 8.3 and
8.4 on Cygwin.

This:
https://www.gnu.org/software/gettext/FAQ.html#integrating_undefined

    "To find the cause of the error, a little analysis is needed. Does
the program's final link command contains the option “-lintl”?"

No, it wasn't.

Somehow the same thing wasn't a problem before. I noticed recently
that a simple program works just fine on say Gentoo without `-lintl`.
Cygwin needs `-lintl` at the end.

Regards,

Philippe Baril Lecavalier
nano-8.4-lintl.patch (application/octet-stream, 480 B)
diff --git a/src/Makefile.am b/src/Makefile.am
index b050e655..38e5931e 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -42,8 +42,8 @@ nano_SOURCES = \
 		utils.c \
 		winio.c
 
-nano_LDADD = @LIBINTL@ $(top_builddir)/lib/libgnu.a \
-		$(GETRANDOM_LIB) $(CLOCK_TIME_LIB) $(LIBTHREAD)
+nano_LDADD = $(top_builddir)/lib/libgnu.a \
+		$(GETRANDOM_LIB) $(CLOCK_TIME_LIB) $(LIBTHREAD) @LIBINTL@
 
 install-exec-hook:
 	cd $(DESTDIR)$(bindir) && rm -f rnano && $(LN_S) nano rnano