今天,我阅读了网络博客文章http://rachid.koucha.free.fr/tech_corner/executable_lib.html,如何制作可执行的共享库。本文指出,如果在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
是C
中定义的two.cpp
函数,我得到警告消息:找不到入口点lib_entry点。
如何解决此警告消息,以便可以直接运行入口点
lib_entry
?是否应使用C
链接将foo
函数extern "C"
的实现封装起来以解决此问题? 最佳答案
这是我的答案:
Missing include "bits/c++config.h" when cross compiling 64 bit program on 32 bit in Ubuntu
须藤apt-get install gcc-4.9-multilib g ++-4.9-multilib
关于c++ - 如何更改从多个源文件编译的g++生成的Linux共享库的入口点?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/34561791/