如何在linux中编译程序(compile a program in linux)

源代码是人类可读的计算机程序。但是,机器无法执行源代码。代码必须先编译成机器代码,然后才能使用。在Linux上,“make”构建系统是最常见的一个,该操作指南适用于几乎所有的Linux源代码包。...

步骤

  1. 1从Internet或其他媒体下载程序或驱动程序的源代码。它很可能以“tarball”的形式出现,文件扩展名为。焦油焦油bz2,或。焦油广州。有时是一个。但是,将使用zip文件。
  2. Image titled Compile a Program in Linux Step 1
  3. 2将下载的代码解包-用于。zip文件使用“解压你的文件”,例如。tgz或。焦油gz使用“tar-zxvf yourfile”;对于bz2使用“tar-jxvf yourfile”;或者以图形方式提取文件。
  4. Image titled Compile a Program in Linux Step 2
  5. 3在终端中,进入新提取的目录。要做到这一点,请键入cd,后跟空格,然后键入目录名。(请记住,Linux中的目录名区分大小写)。
  6. Image titled Compile a Program in Linux Step 3
  7. 4运行“/configure”命令自动配置源代码。“--prefix=”等参数可用于控制安装位置。这将检查您是否拥有正确的库和版本。
  8. Image titled Compile a Program in Linux Step 4
  9. 5配置完成后,运行“make”进行实际编译(这可能需要几秒钟到数小时)。程序的可执行文件将在源代码目录内的bin目录中创建。
  10. Image titled Compile a Program in Linux Step 5
  11. 6要安装程序,请运行“make install”。
  12. Image titled Compile a Program in Linux Step 6
  13. 7您已经编译并安装了程序源代码。
  14. Image titled Compile a Program in Linux Step 7
  • 在多核处理器上,您可以使用make-j3以多线程方式编译,将3替换为您想要使用的线程数。
  • 如果构建因任何原因失败,在尝试再次构建之前,应运行“make clean”删除原始构建尝试留下的所有文件。这些文件可能会使您的第二次尝试失败,因为它们存在。
  • 除非指定前缀,否则代码将自动安装在/usr中。
  • 你可能需要成为超级用户。
  • 您还可以将这些命令串在一起。例如/配置&amp&make&amp&进行安装。
  • 如果构建失败,您将获得一行、一个文件和错误类型的输出。如果你愿意,你可以试着解决这个问题。大多数故障都来自于所安装软件的故障依赖项,即软件包所依赖的程序或库。
  • 发表于 2022-03-16 17:43
  • 阅读 ( 48 )
  • 分类:IT

你可能感兴趣的文章

40多个最常用的linux终端命令

... whatis -- Displays brief descripti*** of command line programs. Think of it like a simplified version of man when you aren't sure what a command does but don't need the full manual on how to use it. ...

  • 发布于 2021-03-15 21:40
  • 阅读 ( 269 )

如何向任何人解释linux(让他们明白)

... Linux is a bit like Windows. It's a big computer program that lets you run other, **aller computer programs like Google Chrome and Office. In fact, it looks a lot like Windows, too. What makes Linux so special is that compared to Windows, it's safer and more reliable.There ...

  • 发布于 2021-03-17 08:58
  • 阅读 ( 177 )

linux下如何使用which命令

...在shell中的,因此Bash不必费劲地查找这些命令。 但是Bash如何定位其他命令、程序和外部独立二进制文件呢?Bash使用路径,实际上是一组路径,每个路径指向一个目录。然后,它在每个目录中搜索与您试图运行的命令或程序匹配...

  • 发布于 2021-04-02 20:07
  • 阅读 ( 182 )

如何在windows和linux上禁用libreoffice的启动启动屏幕

...LibreOffice启动中心的快捷方式。但是,您可以通过转到C:\Program Files(x86)\LibreOffice 5\Program目录,右键单击程序的.exe文件(例如swriter.exe文件, scalc.exe文件,或simpress.exe文件),并将发送到>桌面(创建快捷方式)。 将显示...

  • 发布于 2021-04-08 12:20
  • 阅读 ( 145 )

如何在linux上创建和使用符号链接(又称symlinks)

... 例如,假设您有一个程序需要将其文件存储在/home/user/.program中。但是您希望将这些文件存储在另一个分区上,该分区挂载在/mnt/partition。您可以将.program目录移动到/mnt/partition/.program,然后在/home/user/.program处创建指向/mnt/partition/...

  • 发布于 2021-04-08 12:26
  • 阅读 ( 164 )

如何在linux上安全地运行不受信任的可执行文件?

...is day and age, even your robot vacuum can spread malware. And what if the program already infected your microwave through the computer’s speakers using high-frequency data tran**itting?! But let’s take off that tinfoil hat and jump back to reality for a bit. No Virtualization – Quick to Use F...

  • 发布于 2021-04-08 13:43
  • 阅读 ( 170 )

什么是windows中(linux)bin目录的等价物?

...Windows is also in PATH for all Windows users (and, even if it is not, the program loader in Windows will search there anyhow). You can easily create your own equivalent of /bin on Windows. To make it system-wide, place it somewhere like the root of the file system (such as C:\bin or under an alread...

  • 发布于 2021-04-10 04:59
  • 阅读 ( 112 )

为什么我在windows和linux上得到不同的cpu规格信息?

...ccounts for the difference in reported speed. In fact, many CPU monitoring programs let you observe the changes in speed in real time as you run and/or close programs. 有什么要补充的解释吗?在评论中发出声音。想从其他精通技术的Stack Exchange用户那里了解更多答案...

  • 发布于 2021-04-11 02:44
  • 阅读 ( 161 )

一个linux操作系统究竟是如何“基于”另一个linux操作系统的?

...f software which works with the hardware and exports a certain Application Programming Interface (API), and binary conventi*** on how to precisely use it (Application Binary Interface, ABI) available to the “user-space” applicati***. Debian, RedHat and others are operating systems — complete...

  • 发布于 2021-04-11 15:10
  • 阅读 ( 207 )

为什么linux系统有时可以恢复windows无法恢复的数据?

..., on a faulty disk you will see lots of error messages. It depends on what programs are actuallly accessing the disk what will happen next. If it’s software geared towards recovery, it may try to reread the same sector a limited number of times, it may skip it, etc. Usually the best bet is to get ...

  • 发布于 2021-04-11 18:56
  • 阅读 ( 193 )
kadpxomxlu
kadpxomxlu

0 篇文章

相关推荐