使用 gcc 链接共享库 [英] Linking a shared library using gcc
问题描述
我在 windows 目标上使用 Real View 编译器工具 (RVCT 3.2) 创建了一个共享库 (*.so).然后我尝试在 linux 系统上使用 gcc 将此 *.so 文件与我的应用程序链接.
I have a shared library (*.so) created using Real View Compiler Tools (RVCT 3.2) on windows target. Then I try to link this *.so file with my application using gcc on linux system.
将这个共享库链接到我的应用程序 linux 的 gcc 选项是什么?
What is the gcc option to link this shared library with my application linux?
我的问题是,是 -shared
选项,用作
My question is, is the -shared
option, which is used as
gcc -shared myfile.so
...,用于创建 SO 文件或链接 SO 文件?我相信它会产生类似的东西:
..., used to create the SO file or to link the SO file? I believe it creates something like:
gcc -lmyfile.so
这就够了吗?或者是否有任何其他开关告诉链接器它是一个动态库(共享对象)?
Is this enough? Or is there any other switch to tell the linker that it's a dynamic library (shared object)?
推荐答案
对我有用的是:
gcc -L. -l:myfile.so
这篇关于使用 gcc 链接共享库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!