共享对象(动态库)内的 printfs 未打印
我有一个共享对象,我在 Windows 主机上使用 Real View 开发人员套件工具链接命令创建一个共享对象 -
armlink -o mylib.so <“此处给出的我的 *.o 文件”>
然后我使用 gcc 工具将应用程序与 Linux 上的 mylib.so 共享库链接起来。
我在 mylib.so 的函数内部有 printf 语句,但是当我运行最终的可执行文件时,我在控制台上没有得到任何 printf 输出。(在调用 printfs 的地方都包含 stdio.h )
那么共享库是否存在任何已知问题这会导致 printf 或任何系统函数/系统调用/运行时库函数无法正常工作?
或者这与我在基于 Windows 的编译器工具链上创建共享库但将此共享库与 linux-gcc 编译器工具上的应用程序链接的特殊设置有关?
谢谢。
-广告
I have a shared object which i create on windows using Real View developer suite tool linked command on windows host-
armlink -o mylib.so <"my *.o files given here">
Then i link an application with this mylib.so shared library on linux using gcc tools.
I have printf statements inside functions in this mylib.so, but when I run the final executable, i do not get any printf outputs on console.(stdio.h is inlcuded wherever printfs are called)
So is there any known issue with shared libraries which cause printf or any system functions/system calls/run time library functions not to work correctly?
Or is that got to do with my peculiar setup of making a shared library on windows based compiler tool chain but linking this shared library with an application on linux-gcc compiler tools?
Thank you.
-AD
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
由于您的目标是arm,并且我假设这是C,因此在Windows上编译一些文件然后在Linux上链接应该不是问题。 不过你验证过这一点吗? 我建议在 Windows 上制作一个 hello.so,从 hello.c: 链接,
然后从 linux: 上的 main.c 链接 main:
作为最小编译器链测试。
如果您从最终可执行文件中定义的代码(即不是来自共享库的代码)调用 printf ,您会从中得到任何输出吗?
是否
返回两个事件?
中是否有对 printf 的引用
?
Since your target is arm, and I assume this is C it should not be a problem to compile some files on windows and then link on linux. Have you verified this however? I would suggest making a hello.so on windows, linked from hello.c:
and then link main from main.c on linux:
as a minimum compiler chain test.
If you call printf from code in defined in your final executable (i.e. not code from your shared library) do you get any output from that?
Does
return two occurenses?
Are there any references to printf in
?