c++ - 如何更改从多个源文件编译的 g++ 生成的 Linux 共享库的入口点?

标签 c++ g++ ubuntu-14.04

今天,我阅读了 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_entrytwo.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/

相关文章:

c++ - 如何将 C/C++ 代码与 C-shell-script 捆绑在一起?

c++ - 用 g++ .cpp 文件编译 gcc .o 文件

c++ - 为什么程序在堆栈展开后无法到达正确的返回指令?

c++ - 为什么这段代码没有显示 10^5 左右的 n 的输出

c++ - boost 中的矩阵求逆

c++ - llvm g++ 和 boost 函数

postgresql - 如何在 ubuntu 14.04 中安装 postgis 1.5?

从 dump.rdb 加载后删除所有键的 Redis 服务器

php - PDO 在 Froxlor 中显示为 "Not Installed"

c++ - 如何查询类似于 "net use"的内存 UNC 连接?