gccmakefilecompiler-errorsg++ubuntu-22.04

Issue with building Unikey on Ubuntu 22.04


I'm trying to install Unikey (a program for typing Vietnamese) on Ubuntu 22.04 by following the instructions on the Unikey Linux page. While running ./configure was successful, I encountered an error during the make step.

The output of ./configure is extensive, but it completed without any errors. However, running make resulted in the following errors. It appears that there are issues related to "narrowing conversion" in data.cpp:

make  all-recursive
make[1]: Entering directory '/home/username/Downloads/x-unikey-1.0.4'
Making all in src
make[2]: Entering directory '/home/username/Downloads/x-unikey-1.0.4/src'
Making all in byteio
make[3]: Entering directory '/home/username/Downloads/x-unikey-1.0.4/src/byteio'
if /bin/bash ../../libtool --mode=compile g++ -DHAVE_CONFIG_H -I. -I. -I../..  -Wall   -g -O2 -MT byteio.lo -MD -MP -MF ".deps/byteio.Tpo" \
  -c -o byteio.lo `test -f 'byteio.cpp' || echo './'`byteio.cpp; \
then mv -f ".deps/byteio.Tpo" ".deps/byteio.Plo"; \
else rm -f ".deps/byteio.Tpo"; exit 1; \
fi
mkdir .libs
 g++ -DHAVE_CONFIG_H -I. -I. -I../.. -Wall -g -O2 -MT byteio.lo -MD -MP -MF .deps/byteio.Tpo -c byteio.cpp  -fPIC -DPIC -o .libs/byteio.o
 g++ -DHAVE_CONFIG_H -I. -I. -I../.. -Wall -g -O2 -MT byteio.lo -MD -MP -MF .deps/byteio.Tpo -c byteio.cpp -o byteio.o >/dev/null 2>&1
if /bin/bash ../../libtool --mode=compile g++ -DHAVE_CONFIG_H -I. -I. -I../..  -Wall   -g -O2 -MT prehdr.lo -MD -MP -MF ".deps/prehdr.Tpo" \
  -c -o prehdr.lo `test -f 'prehdr.cpp' || echo './'`prehdr.cpp; \
then mv -f ".deps/prehdr.Tpo" ".deps/prehdr.Plo"; \
else rm -f ".deps/prehdr.Tpo"; exit 1; \
fi
 g++ -DHAVE_CONFIG_H -I. -I. -I../.. -Wall -g -O2 -MT prehdr.lo -MD -MP -MF .deps/prehdr.Tpo -c prehdr.cpp  -fPIC -DPIC -o .libs/prehdr.o
 g++ -DHAVE_CONFIG_H -I. -I. -I../.. -Wall -g -O2 -MT prehdr.lo -MD -MP -MF .deps/prehdr.Tpo -c prehdr.cpp -o prehdr.o >/dev/null 2>&1
/bin/bash ../../libtool --mode=link g++  -g -O2   -o libbyteio.la   byteio.lo prehdr.lo  
ar cru .libs/libbyteio.a .libs/byteio.o .libs/prehdr.o
ar: `u' modifier ignored since `D' is the default (see `U')
ranlib .libs/libbyteio.a
creating libbyteio.la
(cd .libs && rm -f libbyteio.la && ln -s ../libbyteio.la libbyteio.la)
make[3]: Leaving directory '/home/username/Downloads/x-unikey-1.0.4/src/byteio'
Making all in vnconv
make[3]: Entering directory '/home/username/Downloads/x-unikey-1.0.4/src/vnconv'
if /bin/bash ../../libtool --mode=compile g++ -DHAVE_CONFIG_H -I. -I. -I../..  -Wall -I../byteio   -g -O2 -MT charset.lo -MD -MP -MF ".deps/charset.Tpo" \
  -c -o charset.lo `test -f 'charset.cpp' || echo './'`charset.cpp; \
then mv -f ".deps/charset.Tpo" ".deps/charset.Plo"; \
else rm -f ".deps/charset.Tpo"; exit 1; \
fi
mkdir .libs
 g++ -DHAVE_CONFIG_H -I. -I. -I../.. -Wall -I../byteio -g -O2 -MT charset.lo -MD -MP -MF .deps/charset.Tpo -c charset.cpp  -fPIC -DPIC -o .libs/charset.o
charset.cpp:694:9: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
  694 |         "://",
      |         ^~~~~
charset.cpp:695:9: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
  695 |         "/",
      |         ^~~
charset.cpp:696:9: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
  696 |         "@",
      |         ^~~
charset.cpp:697:9: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
  697 |         "mailto:",
      |         ^~~~~~~~~
charset.cpp:698:9: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
  698 |         "email:",
      |         ^~~~~~~~
charset.cpp:699:9: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
  699 |         "news:",
      |         ^~~~~~~
charset.cpp:700:9: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
  700 |         "www",
      |         ^~~~~
charset.cpp:701:9: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
  701 |         "ftp"
      |         ^~~~~
 g++ -DHAVE_CONFIG_H -I. -I. -I../.. -Wall -I../byteio -g -O2 -MT charset.lo -MD -MP -MF .deps/charset.Tpo -c charset.cpp -o charset.o >/dev/null 2>&1
if /bin/bash ../../libtool --mode=compile g++ -DHAVE_CONFIG_H -I. -I. -I../..  -Wall -I../byteio   -g -O2 -MT convert.lo -MD -MP -MF ".deps/convert.Tpo" \
  -c -o convert.lo `test -f 'convert.cpp' || echo './'`convert.cpp; \
then mv -f ".deps/convert.Tpo" ".deps/convert.Plo"; \
else rm -f ".deps/convert.Tpo"; exit 1; \
fi
 g++ -DHAVE_CONFIG_H -I. -I. -I../.. -Wall -I../byteio -g -O2 -MT convert.lo -MD -MP -MF .deps/convert.Tpo -c convert.cpp  -fPIC -DPIC -o .libs/convert.o
convert.cpp: In function 'int vnFileStreamConvert(int, int, FILE*, FILE*)':
convert.cpp:216:13: warning: unused variable 'ret' [-Wunused-variable]
  216 |         int ret = 0;
      |             ^~~
convert.cpp: At global scope:
convert.cpp:239:2: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
  239 | {"No error",
      |  ^~~~~~~~~~
convert.cpp:240:2: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
  240 |  "Unknown error",
      |  ^~~~~~~~~~~~~~~
convert.cpp:241:2: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
  241 |  "Invalid charset",
      |  ^~~~~~~~~~~~~~~~~
convert.cpp:242:2: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
  242 |  "Error opening input file",
      |  ^~~~~~~~~~~~~~~~~~~~~~~~~~
convert.cpp:243:2: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
  243 |  "Error opening output file",
      |  ^~~~~~~~~~~~~~~~~~~~~~~~~~~
convert.cpp:244:2: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
  244 |  "Error writing to output stream",
      |  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
convert.cpp:245:2: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
  245 |  "Not enough memory",
      |  ^~~~~~~~~~~~~~~~~~~
convert.cpp: In function 'int VnFileConvert(int, int, const char*, const char*)':
convert.cpp:185:31: warning: ignoring return value of 'int system(const char*)' declared with attribute 'warn_unused_result' [-Wunused-result]
  185 |                         system(cmd);
      |                         ~~~~~~^~~~~
 g++ -DHAVE_CONFIG_H -I. -I. -I../.. -Wall -I../byteio -g -O2 -MT convert.lo -MD -MP -MF .deps/convert.Tpo -c convert.cpp -o convert.o >/dev/null 2>&1
if /bin/bash ../../libtool --mode=compile g++ -DHAVE_CONFIG_H -I. -I. -I../..  -Wall -I../byteio   -g -O2 -MT data.lo -MD -MP -MF ".deps/data.Tpo" \
  -c -o data.lo `test -f 'data.cpp' || echo './'`data.cpp; \
then mv -f ".deps/data.Tpo" ".deps/data.Plo"; \
else rm -f ".deps/data.Tpo"; exit 1; \
fi
 g++ -DHAVE_CONFIG_H -I. -I. -I../.. -Wall -I../byteio -g -O2 -MT data.lo -MD -MP -MF .deps/data.Tpo -c data.cpp  -fPIC -DPIC -o .libs/data.o
data.cpp:63:10: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
   63 |         {"BKHCM1",              CONV_CHARSET_BKHCM1},
      |          ^~~~~~~~
data.cpp:64:10: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
   64 |         {"BKHCM2",              CONV_CHARSET_BKHCM2},
      |          ^~~~~~~~
data.cpp:65:10: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
   65 |         {"ISC",                 CONV_CHARSET_ISC},
      |          ^~~~~
data.cpp:66:10: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
   66 |         {"NCR-DEC",             CONV_CHARSET_UNIREF},
      |          ^~~~~~~~~
data.cpp:67:10: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
   67 |         {"NCR-HEX",             CONV_CHARSET_UNIREF_HEX},
      |          ^~~~~~~~~
data.cpp:68:10: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
   68 |         {"TCVN3",               CONV_CHARSET_TCVN3},
      |          ^~~~~~~
data.cpp:69:10: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
   69 |         {"UNI-COMP",    CONV_CHARSET_UNIDECOMPOSED},
      |          ^~~~~~~~~~
data.cpp:70:10: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
   70 |         {"UNICODE",             CONV_CHARSET_UNICODE},
      |          ^~~~~~~~~
data.cpp:71:10: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
   71 |         {"UTF-8",               CONV_CHARSET_UNIUTF8},
      |          ^~~~~~~
data.cpp:72:10: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
   72 |         {"UTF8",                CONV_CHARSET_UNIUTF8},
      |          ^~~~~~
data.cpp:73:10: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
   73 |         {"UVIQR",       CONV_CHARSET_UTF8VIQR},
      |          ^~~~~~~
data.cpp:74:10: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
   74 |         {"VIETWARE-F",  CONV_CHARSET_VIETWAREF},
      |          ^~~~~~~~~~~~
data.cpp:75:10: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
   75 |         {"VIETWARE-X",  CONV_CHARSET_VIETWAREX},
      |          ^~~~~~~~~~~~
data.cpp:76:10: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
   76 |         {"VIQR",                CONV_CHARSET_VIQR},
      |          ^~~~~~
data.cpp:77:10: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
   77 |         {"VISCII",              CONV_CHARSET_VISCII},
      |          ^~~~~~~~
data.cpp:78:10: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
   78 |         {"VNI-MAC",             CONV_CHARSET_VNIMAC},
      |          ^~~~~~~~~
data.cpp:79:10: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
   79 |         {"VNI-WIN",             CONV_CHARSET_VNIWIN},
      |          ^~~~~~~~~
data.cpp:80:10: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
   80 |         {"VPS",                 CONV_CHARSET_VPS},
      |          ^~~~~
data.cpp:81:10: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
   81 |         {"WINCP-1258",  CONV_CHARSET_WINCP1258}
      |          ^~~~~~~~~~~~
data.cpp:243:1: error: narrowing conversion of ''\37777777670'' from 'char' to 'unsigned char' [-Wnarrowing]
  243 | };
      | ^
data.cpp:243:1: error: narrowing conversion of ''\37777777670'' from 'char' to 'unsigned char' [-Wnarrowing]
data.cpp:243:1: error: narrowing conversion of ''\37777777665'' from 'char' to 'unsigned char' [-Wnarrowing]
data.cpp:243:1: error: narrowing conversion of ''\37777777665'' from 'char' to 'unsigned char' [-Wnarrowing]
data.cpp:243:1: error: narrowing conversion of ''\37777777666'' from 'char' to 'unsigned char' [-Wnarrowing]
data.cpp:243:1: error: narrowing conversion of ''\37777777666'' from 'char' to 'unsigned char' [-Wnarrowing]
..............................
data.cpp:243:1: error: narrowing conversion of ''\37777777773'' from 'char' to 'unsigned char' [-Wnarrowing]
data.cpp:243:1: error: narrowing conversion of ''\37777777662'' from 'char' to 'unsigned char' [-Wnarrowing]
data.cpp:243:1: error: narrowing conversion of ''\37777777774'' from 'char' to 'unsigned char' [-Wnarrowing]
data.cpp:243:1: error: narrowing conversion of ''\37777777664'' from 'char' to 'unsigned char' [-Wnarrowing]
data.cpp:243:1: error: narrowing conversion of ''\37777777776'' from 'char' to 'unsigned char' [-Wnarrowing]
make[3]: *** [Makefile:282: data.lo] Error 1
make[3]: Leaving directory '/home/username/Downloads/x-unikey-1.0.4/src/vnconv'
make[2]: *** [Makefile:213: all-recursive] Error 1
make[2]: Leaving directory '/home/username/Downloads/x-unikey-1.0.4/src'
make[1]: *** [Makefile:243: all-recursive] Error 1
make[1]: Leaving directory '/home/username/Downloads/x-unikey-1.0.4'
make: *** [Makefile:189: all] Error 2

After some searching, I found this solution: make CXXFLAGS="-Wno-narrowing", but another error occurred:

make  all-recursive
make[1]: Entering directory '/home/username/Downloads/x-unikey-1.0.4'
Making all in src
make[2]: Entering directory '/home/username/Downloads/x-unikey-1.0.4/src'
Making all in byteio
make[3]: Entering directory '/home/username/Downloads/x-unikey-1.0.4/src/byteio'
make[3]: Nothing to be done for 'all'.
make[3]: Leaving directory '/home/username/Downloads/x-unikey-1.0.4/src/byteio'
Making all in vnconv
make[3]: Entering directory '/home/username/Downloads/x-unikey-1.0.4/src/vnconv'
if /bin/bash ../../libtool --mode=compile g++ -DHAVE_CONFIG_H -I. -I. -I../..  -Wall -I../byteio   -Wno-narrowing -MT data.lo -MD -MP -MF ".deps/data.Tpo" \
  -c -o data.lo `test -f 'data.cpp' || echo './'`data.cpp; \
then mv -f ".deps/data.Tpo" ".deps/data.Plo"; \
else rm -f ".deps/data.Tpo"; exit 1; \
fi
 g++ -DHAVE_CONFIG_H -I. -I. -I../.. -Wall -I../byteio -Wno-narrowing -MT data.lo -MD -MP -MF .deps/data.Tpo -c data.cpp  -fPIC -DPIC -o .libs/data.o
data.cpp:63:10: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
   63 |         {"BKHCM1",              CONV_CHARSET_BKHCM1},
      |          ^~~~~~~~
data.cpp:64:10: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
   64 |         {"BKHCM2",              CONV_CHARSET_BKHCM2},
      |          ^~~~~~~~
data.cpp:65:10: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
   65 |         {"ISC",                 CONV_CHARSET_ISC},
      |          ^~~~~
data.cpp:66:10: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
   66 |         {"NCR-DEC",             CONV_CHARSET_UNIREF},
      |          ^~~~~~~~~
data.cpp:67:10: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
   67 |         {"NCR-HEX",             CONV_CHARSET_UNIREF_HEX},
      |          ^~~~~~~~~
data.cpp:68:10: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
   68 |         {"TCVN3",               CONV_CHARSET_TCVN3},
      |          ^~~~~~~
data.cpp:69:10: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
   69 |         {"UNI-COMP",    CONV_CHARSET_UNIDECOMPOSED},
      |          ^~~~~~~~~~
data.cpp:70:10: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
   70 |         {"UNICODE",             CONV_CHARSET_UNICODE},
      |          ^~~~~~~~~
data.cpp:71:10: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
   71 |         {"UTF-8",               CONV_CHARSET_UNIUTF8},
      |          ^~~~~~~
data.cpp:72:10: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
   72 |         {"UTF8",                CONV_CHARSET_UNIUTF8},
      |          ^~~~~~
data.cpp:73:10: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
   73 |         {"UVIQR",       CONV_CHARSET_UTF8VIQR},
      |          ^~~~~~~
data.cpp:74:10: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
   74 |         {"VIETWARE-F",  CONV_CHARSET_VIETWAREF},
      |          ^~~~~~~~~~~~
data.cpp:75:10: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
   75 |         {"VIETWARE-X",  CONV_CHARSET_VIETWAREX},
      |          ^~~~~~~~~~~~
data.cpp:76:10: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
   76 |         {"VIQR",                CONV_CHARSET_VIQR},
      |          ^~~~~~
data.cpp:77:10: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
   77 |         {"VISCII",              CONV_CHARSET_VISCII},
      |          ^~~~~~~~
data.cpp:78:10: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
   78 |         {"VNI-MAC",             CONV_CHARSET_VNIMAC},
      |          ^~~~~~~~~
data.cpp:79:10: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
   79 |         {"VNI-WIN",             CONV_CHARSET_VNIWIN},
      |          ^~~~~~~~~
data.cpp:80:10: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
   80 |         {"VPS",                 CONV_CHARSET_VPS},
      |          ^~~~~
data.cpp:81:10: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
   81 |         {"WINCP-1258",  CONV_CHARSET_WINCP1258}
      |          ^~~~~~~~~~~~
 g++ -DHAVE_CONFIG_H -I. -I. -I../.. -Wall -I../byteio -Wno-narrowing -MT data.lo -MD -MP -MF .deps/data.Tpo -c data.cpp -o data.o >/dev/null 2>&1
if /bin/bash ../../libtool --mode=compile g++ -DHAVE_CONFIG_H -I. -I. -I../..  -Wall -I../byteio   -Wno-narrowing -MT error.lo -MD -MP -MF ".deps/error.Tpo" \
  -c -o error.lo `test -f 'error.cpp' || echo './'`error.cpp; \
then mv -f ".deps/error.Tpo" ".deps/error.Plo"; \
else rm -f ".deps/error.Tpo"; exit 1; \
fi
 g++ -DHAVE_CONFIG_H -I. -I. -I../.. -Wall -I../byteio -Wno-narrowing -MT error.lo -MD -MP -MF .deps/error.Tpo -c error.cpp  -fPIC -DPIC -o .libs/error.o
 g++ -DHAVE_CONFIG_H -I. -I. -I../.. -Wall -I../byteio -Wno-narrowing -MT error.lo -MD -MP -MF .deps/error.Tpo -c error.cpp -o error.o >/dev/null 2>&1
if /bin/bash ../../libtool --mode=compile g++ -DHAVE_CONFIG_H -I. -I. -I../..  -Wall -I../byteio   -Wno-narrowing -MT pattern.lo -MD -MP -MF ".deps/pattern.Tpo" \
  -c -o pattern.lo `test -f 'pattern.cpp' || echo './'`pattern.cpp; \
then mv -f ".deps/pattern.Tpo" ".deps/pattern.Plo"; \
else rm -f ".deps/pattern.Tpo"; exit 1; \
fi
 g++ -DHAVE_CONFIG_H -I. -I. -I../.. -Wall -I../byteio -Wno-narrowing -MT pattern.lo -MD -MP -MF .deps/pattern.Tpo -c pattern.cpp  -fPIC -DPIC -o .libs/pattern.o
 g++ -DHAVE_CONFIG_H -I. -I. -I../.. -Wall -I../byteio -Wno-narrowing -MT pattern.lo -MD -MP -MF .deps/pattern.Tpo -c pattern.cpp -o pattern.o >/dev/null 2>&1
if /bin/bash ../../libtool --mode=compile g++ -DHAVE_CONFIG_H -I. -I. -I../..  -Wall -I../byteio   -Wno-narrowing -MT stdafx.lo -MD -MP -MF ".deps/stdafx.Tpo" \
  -c -o stdafx.lo `test -f 'stdafx.cpp' || echo './'`stdafx.cpp; \
then mv -f ".deps/stdafx.Tpo" ".deps/stdafx.Plo"; \
else rm -f ".deps/stdafx.Tpo"; exit 1; \
fi
 g++ -DHAVE_CONFIG_H -I. -I. -I../.. -Wall -I../byteio -Wno-narrowing -MT stdafx.lo -MD -MP -MF .deps/stdafx.Tpo -c stdafx.cpp  -fPIC -DPIC -o .libs/stdafx.o
 g++ -DHAVE_CONFIG_H -I. -I. -I../.. -Wall -I../byteio -Wno-narrowing -MT stdafx.lo -MD -MP -MF .deps/stdafx.Tpo -c stdafx.cpp -o stdafx.o >/dev/null 2>&1
/bin/bash ../../libtool --mode=link g++  -Wno-narrowing   -o libvnconv.la   charset.lo convert.lo data.lo error.lo pattern.lo stdafx.lo ../byteio/libbyteio.la 
rm -fr .libs/libvnconv.lax
mkdir .libs/libvnconv.lax
rm -fr .libs/libvnconv.lax/libbyteio.a
mkdir .libs/libvnconv.lax/libbyteio.a
(cd .libs/libvnconv.lax/libbyteio.a && ar x /home/username/Downloads/x-unikey-1.0.4/src/vnconv/../byteio/.libs/libbyteio.a)
ar cru .libs/libvnconv.a .libs/charset.o .libs/convert.o .libs/data.o .libs/error.o .libs/pattern.o .libs/stdafx.o .libs/libvnconv.lax/libbyteio.a/byteio.o .libs/libvnconv.lax/libbyteio.a/prehdr.o 
ar: `u' modifier ignored since `D' is the default (see `U')
ranlib .libs/libvnconv.a
rm -fr .libs/libvnconv.lax
creating libvnconv.la
(cd .libs && rm -f libvnconv.la && ln -s ../libvnconv.la libvnconv.la)
make[3]: Leaving directory '/home/username/Downloads/x-unikey-1.0.4/src/vnconv'
Making all in ukengine
make[3]: Entering directory '/home/username/Downloads/x-unikey-1.0.4/src/ukengine'
if /bin/bash ../../libtool --mode=compile g++ -DHAVE_CONFIG_H -I. -I. -I../..  -Wall -I../vnconv -I../byteio   -Wno-narrowing -MT ukengine.lo -MD -MP -MF ".deps/ukengine.Tpo" \
  -c -o ukengine.lo `test -f 'ukengine.cpp' || echo './'`ukengine.cpp; \
then mv -f ".deps/ukengine.Tpo" ".deps/ukengine.Plo"; \
else rm -f ".deps/ukengine.Tpo"; exit 1; \
fi
mkdir .libs
 g++ -DHAVE_CONFIG_H -I. -I. -I../.. -Wall -I../vnconv -I../byteio -Wno-narrowing -MT ukengine.lo -MD -MP -MF .deps/ukengine.Tpo -c ukengine.cpp  -fPIC -DPIC -o .libs/ukengine.o
ukengine.cpp: In member function 'int UkEngine::processHookWithUO(UkKeyEvent&)':
ukengine.cpp:637:10: warning: variable 'toneRemoved' set but not used [-Wunused-but-set-variable]
  637 |     bool toneRemoved = false;
      |          ^~~~~~~~~~~
 g++ -DHAVE_CONFIG_H -I. -I. -I../.. -Wall -I../vnconv -I../byteio -Wno-narrowing -MT ukengine.lo -MD -MP -MF .deps/ukengine.Tpo -c ukengine.cpp -o ukengine.o >/dev/null 2>&1
if /bin/bash ../../libtool --mode=compile g++ -DHAVE_CONFIG_H -I. -I. -I../..  -Wall -I../vnconv -I../byteio   -Wno-narrowing -MT mactab.lo -MD -MP -MF ".deps/mactab.Tpo" \
  -c -o mactab.lo `test -f 'mactab.cpp' || echo './'`mactab.cpp; \
then mv -f ".deps/mactab.Tpo" ".deps/mactab.Plo"; \
else rm -f ".deps/mactab.Tpo"; exit 1; \
fi
 g++ -DHAVE_CONFIG_H -I. -I. -I../.. -Wall -I../vnconv -I../byteio -Wno-narrowing -MT mactab.lo -MD -MP -MF .deps/mactab.Tpo -c mactab.cpp  -fPIC -DPIC -o .libs/mactab.o
mactab.cpp: In member function 'int CMacroTable::addItem(const char*, int)':
mactab.cpp:290:22: error: invalid conversion from 'const char*' to 'char*' [-fpermissive]
  290 |   char * pos = strchr(item, ':');
      |                ~~~~~~^~~~~~~~~~~
      |                      |
      |                      const char*
mactab.cpp: In member function 'int CMacroTable::writeToFile(const char*)':
mactab.cpp:227:29: warning: 'sprintf' may write a terminating nul past the end of the destination [-Wformat-overflow=]
  227 |       sprintf(line, "%s:%s\n", key, text);
      |                             ^
mactab.cpp:227:14: note: 'sprintf' output between 3 and 3121 bytes into a destination of size 3120
  227 |       sprintf(line, "%s:%s\n", key, text);
      |       ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
make[3]: *** [Makefile:282: mactab.lo] Error 1
make[3]: Leaving directory '/home/username/Downloads/x-unikey-1.0.4/src/ukengine'
make[2]: *** [Makefile:213: all-recursive] Error 1
make[2]: Leaving directory '/home/username/Downloads/x-unikey-1.0.4/src'
make[1]: *** [Makefile:243: all-recursive] Error 1
make[1]: Leaving directory '/home/username/Downloads/x-unikey-1.0.4'
make: *** [Makefile:189: all] Error 2

From what I understand, it seems I have to modify the source code to resolve these issues. However, I would prefer not to do this if possible. I suspect the problem might be related to the GCC or G++ version. Here is the output from gcc --version and g++ --version:

gcc (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0
Copyright (C) 2021 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
g++ (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0
Copyright (C) 2021 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

I followed the instructions on the Unikey Linux page and ran ./configure, which completed without errors. During the make step, I encountered "narrowing conversion" errors. I then tried using the command make CXXFLAGS="-Wno-narrowing", but it resulted in additional errors. I expected the compilation to complete successfully without modifying the source code, but the process failed due to conversion and compatibility issues.


Solution

  • I suspect the problem might be related to the GCC or G++ version.

    Your compiler is recent; the code is very old. The Sourceforge version v1.0.4 tarball that you got via the Unikey Linux page hails from 2006, in the GCC 4.x era. Compilation snags with GCC 11.x are not surprising.

    I have:

    $ gcc --version
    gcc (Ubuntu 13.2.0-23ubuntu4) 13.2.0
    

    and likewise for g++. With this same tarball I was able to get a build without errors - though with numerous warnings - using the following ./configure options:

    $ CXXFLAGS='-Wno-narrowing -fpermissive -include cstdio -include cstring' ./configure
    

    This represents more bandaging than I'd be happy to apply in ./configure options: I would fix the code.

    However, that isn't necessary if I source the package instead from GitHub: hardwarelayer/x-unikey-1.0.4-centos7-build, committed Sept. 2016. The version number, AUTHORS file and ChangeLog are the same as Sourceforge, but the GitHub package has the following small source code diff v. the Sourceforge package:

    $ diff -r x-unikey-1.0.4-sourceforge/src x-unikey-1.0.4-centos7-build/src
    diff -r x-unikey-1.0.4-sourceforge/src/ukengine/mactab.cpp x-unikey-1.0.4-centos7-build/src/ukengine/mactab.cpp
    290c290
    <   char * pos = strchr(item, ':');
    ---
    >   char * pos = strchr((char*) item, ':');
    diff -r x-unikey-1.0.4-sourceforge/src/ukengine/usrkeymap.cpp x-unikey-1.0.4-centos7-build/src/ukengine/usrkeymap.cpp
    25a26,27
    > #include <cstring>
    > #include <stdio.h>
    265c267
    < }
    \ No newline at end of file
    ---
    > }
    

    which expresses fixes (albeit not the ideal ones) for the issues suppressed by

    -fpermissive -include cstdio -include cstring
    

    And indeed the GitHub package builds without errors (though with numerous warnings) using:

    $ CXXFLAGS=-Wno-narrowing ./configure
    

    I expect you can settle for that if you don't want to touch the code - at least as long as bugs do not transpire.