Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
938 views
in Technique[技术] by (71.8m points)

linker - Linking a shared library using gcc

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.

What is the gcc option to link this shared library with my application linux?

My question is, is the -shared option, which is used as

gcc -shared myfile.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)?

question from:https://stackoverflow.com/questions/726014/linking-a-shared-library-using-gcc

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

What worked for me was:

gcc -L. -l:myfile.so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...