如何在Linux上为C库使用已编译的二进制文件?

时间:2022-09-07 08:18:09

I downloaded the libftp source from here, and compiled it using make. Now I just have a binary called "ftp" in the same directory. Do I need to move it to one of the root directories, like /usr/bin? Do I still need the source files so that I can #include the library?

我从这里下载了libftp源代码,并使用make编译它。现在我在同一目录中只有一个名为“ftp”的二进制文件。我是否需要将其移动到其中一个根目录,例如/ usr / bin?我还需要源文件,以便我可以#include库吗?

1 个解决方案

#1


1  

To use a library in your own code, first you need that library - generally named lib{name}.a or lib{name}.so. The library will be required during linking. So when you make, make sure it creates the library and not just the ftp binary.

要在自己的代码中使用库,首先需要该库 - 通常名为lib {name} .a或lib {name} .so。链接期间将需要该库。因此,当您创建时,请确保它创建库而不仅仅是ftp二进制文件。

Secondly, at compile time you will need the header files so that the #include's don't throw errors. So as far as source goes, you will at least need the header files.

其次,在编译时你需要头文件,以便#include不会抛出错误。因此,就源代码而言,您至少需要头文件。

#1


1  

To use a library in your own code, first you need that library - generally named lib{name}.a or lib{name}.so. The library will be required during linking. So when you make, make sure it creates the library and not just the ftp binary.

要在自己的代码中使用库,首先需要该库 - 通常名为lib {name} .a或lib {name} .so。链接期间将需要该库。因此,当您创建时,请确保它创建库而不仅仅是ftp二进制文件。

Secondly, at compile time you will need the header files so that the #include's don't throw errors. So as far as source goes, you will at least need the header files.

其次,在编译时你需要头文件,以便#include不会抛出错误。因此,就源代码而言,您至少需要头文件。