I'm trying to port a api from windows to linux. So far I've done the work on file.cpp and file.h but I still have a library .lib specified to windows that is needed in order for the api to work. how can I build a file.a usable on linux from this library?
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
Static libraries in Linux (or all POSIX systems, like Mac OSX) are actually archives containing all object files. These archives are created with the ar
command:
ar crv some_library.a some_object_file.o
The above command creates the "archive" (i.e. static library) some_library.a
from the object file some_object_file.o
. This library can now be used when linking other programs.