我正在尝试按照 Unikey Linux 页面 上的说明在 Ubuntu 22.04 上安装 Unikey(用于输入越南语的程序)。虽然运行
./configure
成功,但我在 make
步骤中遇到了错误。
./configure
的输出很广泛,但完成时没有任何错误。但是,运行make
会导致以下错误。 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
经过一番搜索,我找到了这个解决方案:
make CXXFLAGS="-Wno-narrowing"
,但是又出现了错误:
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
据我了解,似乎我必须修改源代码才能解决这些问题。但是,如果可能的话,我宁愿不这样做。我怀疑该问题可能与 GCC 或 G++ 版本有关。这是
gcc --version
和 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.
我按照 Unikey Linux 页面上的说明运行
./configure
,顺利完成。在make
步骤中,我遇到了“缩小转换”错误。然后我尝试使用命令 make CXXFLAGS="-Wno-narrowing"
,但它导致了额外的错误。我原本希望在不修改源代码的情况下编译成功,但由于转换和兼容性问题,该过程失败了。
我怀疑问题可能与GCC或G++版本有关。
您的编译器是最新的;该代码很旧。您通过 Unikey Linux 页面 获得的 Sourceforge 版本 v1.0.4 tarball 诞生于 2006 年的 GCC 4.x 时代。 GCC 11.x 的编译障碍并不奇怪。
我有:
$ gcc --version
gcc (Ubuntu 13.2.0-23ubuntu4) 13.2.0
同样适用于
g++
。使用相同的 tarball,我能够获得没有错误的构建 - 尽管有许多警告 -
使用以下 ./configure
选项:
$ CXXFLAGS='-Wno-narrowing -fpermissive -include cstdio -include cstring' ./configure
这代表着比我乐意使用的更多的绷带
./configure
选项:我会修复代码。
但是,如果我从 GitHub 获取该包,则没有必要:hardwarelayer/x-unikey-1.0.4-centos7-build, 2016 年 9 月提交。版本号、
AUTHORS
文件和 ChangeLog
与 Sourceforge 相同,但 GitHub 包与 Sourceforge 包相比有以下小的源代码差异:
$ 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
---
> }
它表达了对
抑制的问题的修复(尽管不是理想的修复)-fpermissive -include cstdio -include cstring
事实上,GitHub 包的构建没有错误(尽管有很多警告),使用:
$ CXXFLAGS=-Wno-narrowing ./configure
如果您不想接触代码,我希望您可以接受这一点 - 至少只要 因为错误不会发生。