-
Notifications
You must be signed in to change notification settings - Fork 720
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
在linux下静态库的问题 #10
Comments
第一个问题是makefile的写法有误,库要放在.o后面,已经修改,1.2.5就应该都对了。 zlog-chk-conf: zlog-chk-conf.o $(STLIBNAME) |
第二个问题目前还不知道为什么……有人知道吼一声! |
使用目前的版本,第二个问题貌似解决了? $ gcc -c -o test_hello.o -I../src test_hello.c |
第二个问题还是存在,你的编绎方法还是使用的动态库,用静态库就可以重现了, $gcc test_hello.c -static -I../src -L ../src/ -lzlog -pthread $valgrind a.out ............. |
http://pl.digipedia.org/usenet/thread/11632/12006/ 看起来是valgrind的问题,在静态链接的时候会报一堆pthread和malloc calloc的错,可能valgrind升级到新版会好 |
可以写一个有pthread的静态链接的小程序,然后用valgrind'跑,也能观察那些报错 |
cc -o zlog-chk-conf -O2 -fPIC -Wall -Werror -Wstrict-prototypes -g -ggdb -fPIC -lpthread zlog-chk-conf.o libzlog.a 时出错,
出现类似于zlog.c:52: undefined reference to `pthread_key_delete' 之类的错误信息, 用-pthread可以解决
但如果写一个最简单的程序链接静态库,用valgrind跑一下会产生几千个内存错误:
但链接静态库却没有这个问题,请释疑
==15205== Use of uninitialised value of size 8
==15205== at 0x464701: __strftime_internal (in ...)
==15205== by 0x463D3B: __strftime_internal (in ..)
==15205== by 0x465695: strftime_l (in ..)
==15205== by 0x421F21: zlog_spec_write_time_D (spec.c:128)
==15205== by 0x41D862: zlog_format_gen_msg (format.c:164)
==15205== by 0x41FEDF: zlog_rule_output_stderr (rule.c:421)
==15205== by 0x41B7FD: zlog_category_output (category.c:240)
==15205== by 0x41A84F: zlog (zlog.c:904)
==15205== by 0x402938: main (main.c:15)
==15205==
==15205== Use of uninitialised value of size 8
==15205== at 0x4646DD: __strftime_internal (in ..)
==15205== by 0x463D3B: __strftime_internal (in ..)
==15205== by 0x465695: strftime_l (in ..)
==15205== by 0x421F21: zlog_spec_write_time_D (spec.c:128)
==15205== by 0x41D862: zlog_format_gen_msg (format.c:164)
==15205== by 0x41FEDF: zlog_rule_output_stderr (rule.c:421)
==15205== by 0x41B7FD: zlog_category_output (category.c:240)
==15205== by 0x41A84F: zlog (zlog.c:904)
==15205== by 0x402938: main (main.c:15)
==15205==
==15205== Use of uninitialised value of size 8
==15205== at 0x425046: zlog_buf_append (buf.c:532)
==15205== by 0x41D862: zlog_format_gen_msg (format.c:164)
The text was updated successfully, but these errors were encountered: