On 2013-3-14 14:34, xunxun wrote:
> 我查了下gcc源码,在开启NLS时,libiberty只有三个地方依赖libintl
> regex.c obstack.c getopt.c
>
> 以cb的情况,exchndl极有可能是调用了obstack的函数,能不能重构绕过这里?
情况很复杂,这个是我之前和CB开发者的一份测试报告。
Now, I download the TDM-4.7.1-sjlj installer, and after installation, I try to build enchndl under C::B use this compiler suite.
First try:
[code]
-------------- Build: exchndl in Code::Blocks wx2.8.x (compiler: GNU GCC Compiler)---------------
[100.0%] g++.exe -shared -Wl,--dll -Lbase\tinyxml -LE:\code\cb\wx\wxWidgets-2.8.12\lib\gcc_dll -Lbase\exchndl\lib .objs\base\exchndl\exchndl.o -o devel\exchndl.dll -lwxmsw28u -lbfd -liberty -lz
e:/code/gcc/tdm471sjlj/bin/../lib/gcc/mingw32/4.7.1/../../../../mingw32/bin/ld.exe: cannot find -lz
collect2.exe: error: ld returned 1 exit status
Process terminated with status 1 (0 minute(s), 0 second(s))
1 error(s), 0 warning(s) (0 minute(s), 0 second(s))
[/code]
Second try: I change the "z" to "intl", and still give another kind of error
[code]
-------------- Build: exchndl in Code::Blocks wx2.8.x (compiler: GNU GCC Compiler)---------------
[100.0%] g++.exe -shared -Wl,--dll -Lbase\tinyxml -LE:\code\cb\wx\wxWidgets-2.8.12\lib\gcc_dll -Lbase\exchndl\lib .objs\base\exchndl\exchndl.o -o devel\exchndl.dll -lwxmsw28u -lbfd -liberty -lintl
e:/code/gcc/tdm471sjlj/bin/../lib/gcc/mingw32/4.7.1/../../../../mingw32/bin/ld.exe: cannot find -lintl
collect2.exe: error: ld returned 1 exit status
Process terminated with status 1 (0 minute(s), 0 second(s))
1 error(s), 0 warning(s) (0 minute(s), 0 second(s))
[/code]
So, No libz nor libintl was installed with TDM-4.7.1-sjlj.
Next, I found that TDM-4.7.1-sjlj use MinGW's official binutils packages, and the binutils-bin package already contains "libbfd and libiberty", which means we should use those "standard libraries supplied by MinGW" instead of the one build from my own GDB. (Basically, if you build GDB from it's root, it will build bfd again, so this indicates that I should use "make install -C gdb" instead of "make install", because the former one just install GDB binaries, but the later command install all the libraries include the new built libbfd and libiberty, thus overwrite the old-MinGW's)
Let's see where I can find libintl or libz:
For libintl, I think MinGW official site has one, under the folder:
http://sourceforge.net/projects/mingw/files/MinGW/Base/gettext/
Maybe, it is libintl-0.18.1.1-2-mingw32-dll-8.tar.lzma\libintl-0.18.1.1-2-mingw32-dll-8.tar\bin\libintl-8.dll and its import library is in gettext-0.18.1.1-2-mingw32-dev.tar.lzma
For libz, it is:
http://sourceforge.net/projects/mingw/files/MinGW/Extension/zlib/zlib-1.2.7-1/.
Now, I tried again:
I unzip the libz to TDM-GCC-4.7.1-sjlj, and try to build exchndl, now, it report the error:
[code]
-------------- Build: exchndl in Code::Blocks wx2.8.x (compiler: GNU GCC Compiler)---------------
[100.0%] g++.exe -shared -Wl,--dll -Lbase\tinyxml -LE:\code\cb\wx\wxWidgets-2.8.12\lib\gcc_dll -Lbase\exchndl\lib .objs\base\exchndl\exchndl.o -o devel\exchndl.dll -lwxmsw28u -lbfd -liberty -lz
e:/code/gcc/tdm471sjlj/bin/../lib/gcc/mingw32/4.7.1/../../../libbfd.a(section.o): In function `bfd_get_unique_section_name':
C:/MinGW/msys/1.0/src/binutils/binutils-2.22-1/src/binutils-2.22/bfd/section.c:965: undefined reference to `libintl_sprintf'
e:/code/gcc/tdm471sjlj/bin/../lib/gcc/mingw32/4.7.1/../../../libbfd.a(bfd.o): In function `bfd_errmsg':
.....
[/code]
Look, if we use the official libbfd, it need the libintl, I guess that MinGW's bfd was build without the "--disable-nls" option.
Next try: unzip the gettext dev package to TDM4.7.1sjlj, now its OK, change the linker option to "intl"
[code]
-------------- Build: exchndl in Code::Blocks wx2.8.x (compiler: GNU GCC Compiler)---------------
[100.0%] g++.exe -shared -Wl,--dll -Lbase\tinyxml -LE:\code\cb\wx\wxWidgets-2.8.12\lib\gcc_dll -Lbase\exchndl\lib .objs\base\exchndl\exchndl.o -o devel\exchndl.dll -lwxmsw28u -lbfd -liberty -lintl
Output size is 4.42 MB
Process terminated with status 0 (0 minute(s), 1 second(s))
0 error(s), 0 warning(s) (0 minute(s), 1 second(s))
[/code]
Now, the third try: (remove the libz from TDM-4.7.1sjlj, still I can succefully build exchndl.dll.
So, here comes the conclusion: If we stick on using the libbfd supplied from MinGW(in binutils-bin package), we must link against libintl.
If we use a libbfd which build with the option "--disable-nls", then we only need to link against libz.
So, do you guys think we should revert the commit of rev8855, at least change back to libintl.