今天,我阅读了 web blog article , 如何制作可执行的共享库。在本文中,它指出如果在 Linux 命令提示符下键入:
gcc -shared service.c -o libservice.so -Wl,-soname,libservice.so -W1,-e lib_entry
其次是
./libservice.so, then we can directly executer the lib_entry function.
但是,当我运行类似的 g++ 命令时:
g++ -shared one.cpp two.cpp three.cpp -o libservice.so -Wl,-soname,libservice.so -W1,-e lib_entry
其中 lib_entry
是 two.cpp
中定义的 C
函数,我收到警告消息:
No entry point lib_entry point found.
如何修复此警告消息,以便我可以直接运行入口点 lib_entry
?我是否应该将 C
函数 foo
的实现包含在 extern "C"
链接中以解决此问题?
最佳答案
这是我的回答: Missing include "bits/c++config.h" when cross compiling 64 bit program on 32 bit in Ubuntu
sudo apt-get install gcc-4.9-multilib g++-4.9-multilib
关于c++ - 如何更改从多个源文件编译的 g++ 生成的 Linux 共享库的入口点?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34561791/