共享对象(动态库)内的 printfs 未打印

发布于 2024-07-18 01:25:04 字数 453 浏览 5 评论 0原文

我有一个共享对象,我在 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

指尖凝香 2024-07-25 01:25:04

由于您的目标是arm,并且我假设这是C,因此在Windows上编译一些文件然后在Linux上链接应该不是问题。 不过你验证过这一点吗? 我建议在 Windows 上制作一个 hello.so,从 hello.c: 链接,

#include <stdio.h>
void hello(void) {printf("Hello\n");}

然后从 linux: 上的 main.c 链接 main:

void hello(void);
int main(int argc, char *argv[]){ hello(); return 0; }

作为最小编译器链测试。


如果您从最终可执行文件中定义的代码(即不是来自共享库的代码)调用 printf ,您会从中得到任何输出吗?


是否

strings --print-file-name -a mylib.so final_executable | grep "string from printf in shared library"

返回两个事件?


中是否有对 printf 的引用

readelf -a mylib.so
readelf -a final_executable

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:

#include <stdio.h>
void hello(void) {printf("Hello\n");}

and then link main from main.c on linux:

void hello(void);
int main(int argc, char *argv[]){ hello(); return 0; }

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

strings --print-file-name -a mylib.so final_executable | grep "string from printf in shared library"

return two occurenses?


Are there any references to printf in

readelf -a mylib.so
readelf -a final_executable

?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文