GDB和python头文件冲突而无法通过编译的解决方法

77 views
Skip to first unread message

asmwarrior

unread,
Mar 13, 2013, 8:52:51 PM3/13/13
to Code::Blocks中国开发组
GDB使能intl库后,会和python的头文件冲突,目前GDB的开发者已经要解决这个问题了。

http://sourceware.org/ml/gdb-patches/2013-03/msg00592.html

另外,和MinGW相关的几个问题都在这里:
http://sourceware.org/ml/gdb-patches/2013-03/msg00585.html

开发者Eli使用的是官方的MinGW,而且默认应该是使能了nls(也就是intl库)

xunxun

unread,
Mar 13, 2013, 9:30:55 PM3/13/13
to chi...@googlegroups.com, asmwarrior
总觉得GDB启用NLS后怪怪的

不过这样fix也好,我可以在下个版本中附带intl库了,原来就是由于种种的自动
启用导致构建出问题

--
Best Regards,
xunxun

asmwarrior

unread,
Mar 14, 2013, 2:26:04 AM3/14/13
to xunxun, Code::Blocks中国开发组
On 2013-3-14 14:02, xunxun wrote:
exchndl现在可以编译?我怎么记得这个都是跳过去的?另外这个库不是依赖libz,libbfd,libiberty吗,这几个库和intl库有啥关系?
这个本来就可以编译的,这个库确实以来你说的几个库(bfd库和iberty库是必须的)。具体的:

在这个commit
Revision: 8855
Author: ollydbg
Date: 2013-2-25 13:00:49
Message:
* exchndl: link libz instread of libiberty, thus implement the Feature Request #5517. Check winnt.h for both MinGW and MinGW-W64. Workaround a #error in bfd.h.
-------------------------------
M : /trunk/src/CodeBlocks.cbp

M : /trunk/src/CodeBlocks_wx29.cbp

M : /trunk/src/base/exchndl/exchndl.c

M : /trunk/src/base/exchndl/include/coff/internal.h

请注意,Log message上面我写错了,应该是: "link libz instead of libintl".


commit之前,你需要链接MinGW官方的libintl。

在这个commit之后,你需要链接 libz(是你自己用disable-nls编译出来的libz,不是MinGW官方的libz)。

这个在Codeblocks开发者之间有一个讨论,原因就是MinGW官方的iberty库是依赖intl的。

总而言之:要么所有库都依赖intl,要么就都不依赖,否则相当麻烦。

xunxun

unread,
Mar 14, 2013, 2:34:16 AM3/14/13
to chi...@googlegroups.com, asmwarrior
--

我查了下gcc源码,在开启NLS时,libiberty只有三个地方依赖libintl
regex.c obstack.c getopt.c

以cb的情况,exchndl极有可能是调用了obstack的函数,能不能重构绕过这里?
 
 


-- 
Best Regards,
xunxun

xunxun

unread,
Mar 14, 2013, 2:35:48 AM3/14/13
to chi...@googlegroups.com, asmwarrior
于 2013/3/14 星期四 14:26, asmwarrior 写道:
--

另外,libz无所谓启用/禁用NLS与否,都是一样的,它本身没有任何的NLS代码
 
 


-- 
Best Regards,
xunxun

asmwarrior

unread,
Mar 14, 2013, 2:43:12 AM3/14/13
to xunxun, Code::Blocks中国开发组
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.


xunxun

unread,
Mar 14, 2013, 4:27:29 AM3/14/13
to chi...@googlegroups.com, asmwarrior
我觉得这个很容易解决,cb在版本库中自带zlib即可解决,zlib是C语言写的,各
个编译版都可以兼容



--
Best Regards,
xunxun

asmwarrior

unread,
Mar 14, 2013, 4:55:28 AM3/14/13
to xunxun, chi...@googlegroups.com
On 2013-3-14 16:27, xunxun wrote:
> 我觉得这个很容易解决,cb在版本库中自带zlib即可解决,zlib是C语言写的,各 个编译版都可以兼容
你没看出来?这个要看你使用的libbfd是否依赖intl。如果是的话,那么你就得加intl,如果不是,你就不需要加intl(但是貌似要加libz)
这里面还有是静态链接还是动态链接的情况。如果是静态链接,那就啥都不管了,动态链接的话,这个依赖关系就复杂点。

xunxun

unread,
Mar 14, 2013, 5:08:03 AM3/14/13
to asmwarrior, chi...@googlegroups.com
我知道的,现在其他用工程管理的开源软件似乎都是这样做的,附带一个第三方
库,然后告诉用户我是使用什么编译器编译的,不管这些细节问题

--
Best Regards,
xunxun

Reply all
Reply to author
Forward
0 new messages