简体   繁体   English

用C编译程序

[英]Compiling program in C

this is my first question here.这是我在这里的第一个问题。 I have been compiling a Debian package in C ( emacs ).我一直在用 C ( emacs ) 编译一个 Debian 包。 It is also my first compilation, so I don't understand much about it (until now).这也是我第一次编译,所以我对它了解不多(直到现在)。

I have the following structure:我有以下结构:

  • A folder with all the files needed for the compilation (the result of extracting the tar.gz source code package) in /home/user/emacs ./home/user/emacs包含编译所需的所有文件(提取 tar.gz 源代码包的结果)的文件夹。
  • A folder in which I've installed the program by using make install in /opt/emacs (because I specified that path while doing the ./configure , in the --prefix argument).我通过在/opt/emacs使用make install程序的文件夹(因为我在执行./configure时在--prefix参数中指定了该路径)。

As you all know, Linux uses a $PATH variable where all the paths that Linux should use to search for binaries are specified.众所周知,Linux 使用$PATH变量,其中指定了 Linux 用于搜索二进制文件的所有路径。 By default, /opt/emacs/bin is obviusly not contemplated in that variable, and it is not an option for me to include it.默认情况下, /opt/emacs/bin显然没有考虑在该变量中,并且我不能选择包含它。 The possible solution that I've heard about is to create a softlink in /usr/local/bin folder, which aims to that /opt/emacs/bin/* files.我听说过的可能解决方案是在/usr/local/bin文件夹中创建一个软链接,其目标是/opt/emacs/bin/*文件。

Here comes my question.我的问题来了。 That /opt/emacs also has a lib/ subdirectory. /opt/emacs也有一个lib/子目录。 Would it be needed to also create a softlink for those libraries in /usr/local/lib for emacs to correctly work, or with the binary softlink is enough?是否还需要为/usr/local/lib那些库创建软链接以使 emacs 正常工作,或者使用二进制软链接就足够了?

Thank you so much.非常感谢。

Not sure if emacs only needs the binary symlink or the library directory as well.不确定 emacs 是否只需要二进制符号链接或库目录。 Try running it.尝试运行它。 If it needed the libraries and cannot find them, it will fall over rather quickly.如果它需要库而找不到它们,它会很快崩溃。

Let's assume that the libraries are needed.让我们假设需要这些库。 You have several options for installing them (choose at most one):您有多种安装选项(最多选择一个):

  • copy or link libraries to a library directory that's known to the system (eg /usr/local/lib), run ldconfig afterwards.将库复制或链接到系统已知的库目录(例如 /usr/local/lib),然后运行ldconfig On second thoughts, don't do this one, it's the worst option.再三考虑,不要这样做,这是最糟糕的选择。
  • edit /etc/ld.so.conf to add the emacs library directory there, run ldconfig编辑/etc/ld.so.conf以在那里添加 emacs 库目录,运行ldconfig
  • launch emacs through eg a shellscript that sets LD_LIBRARY_PATH to its lib directory and then runs it通过例如将LD_LIBRARY_PATH设置为其 lib 目录的 shellscript 启动 emacs,然后运行它

For more in-depth details see https://tldp.org/HOWTO/Program-Library-HOWTO/shared-libraries.html有关更深入的详细信息,请参阅https://tldp.org/HOWTO/Program-Library-HOWTO/shared-libraries.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM