How to generate a .so file from multiple source files

断了今生、忘了曾经 提交于 2020-08-05 09:35:28

问题


I have been trying from the past few days for generating a shared library. I have header files, source files and asm files as well. I have tried to follow quiet a number of similar questions but I was not able to locate one that specifies the steps needed to generate a .so file from multiple source, header and asm files. I have been facing many issues for generating the .so file. If someone could help me with the step by step procedure for generating a .so file, I would be very grateful. Also, a few tips for making the correct make file would be helpful.


回答1:


Say u have 2 programs foo1.c and foo2.c

Step1: create .o of both

     gcc -Wall -fPIC -c foo1.c

     gcc -Wall -fPIC -c foo2.c

Step2: create .so from above object files

   gcc -shared -o libfoo.so foo1.o foo2.o


来源:https://stackoverflow.com/questions/24526515/how-to-generate-a-so-file-from-multiple-source-files

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!