将文件添加到 /usr/local/include 目录中。

huangapple go评论79阅读模式
英文:

Adding files to /usr/local/include

问题

我最近在Linux机器上安装了openjtalk,并且我想要在Go中使用它。openjtalk的源文件有几个子文件夹,其中包含不同的源代码,我猜这些文件夹会被编译器找到,因为有make文件。

我应该将这些子文件夹都复制到/usr/local/include目录下吗?这样做是解决包含依赖的“正确”方式吗?根据我的测试,如果我复制这些文件,Go似乎可以找到它们,但我不确定这是否是正确的Linux做法。

英文:

I recently installed openjtalk on a linux machine, and I want to be able to wrap it in Go. The source files for openjtalk have several subfolders with different sources, which I assume are found by the compiler because of the make files.

Should I copy each of those sub-folders into /usr/local/include? Is that a "correct" way of fixing include dependencies. From what I tested, Go seems to find the included files if I copy them, but I'm not sure if this is the correct, linux way of doing things.

答案1

得分: 1

通常不建议更改外部库的位置。一些库会自动将自己放在编译器的包含路径中,但对于那些没有自动添加的库,将它们的路径添加到编译器的包含路径中是一个更好的选择。

例如,在gcc中,你可以使用gcc -I/your/header/directory来包含你的目录。通常人们会将这些信息放在Makefile中。这样,你可以将外部库的源代码放在你的代码库中,并告诉编译器在那里查找头文件。这样,在设置新的工作环境时,你只需要从代码库中拉取即可。

英文:

It's usually not a good idea to change locations of external libraries. Some libraries automatically put themselves in include paths of compilers but for those that don't, adding their paths to the compilers' include paths is always a better idea.

For example, in gcc, you can gcc -I/your/header/directory to include your directory. Usually people put those info in the Makefile. This way, you can put external libraries' source code in your repository and just tell compiler to also look for the headers there. This way, when setting up a new working environment, all you have to do is pull from the repository.

huangapple
  • 本文由 发表于 2015年4月4日 01:21:43
  • 转载请务必保留本文链接:https://go.coder-hub.com/29436836.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定