使用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屋!