SCons - 非标准位置的标头/库

发布于 2024-10-11 23:11:52 字数 716 浏览 11 评论 0原文

我正在尝试使用 SCons 编译一个程序,该程序需要一组我已安装在非标准位置的依赖项。

我已将依赖项安装在 /home/dja/ocr 中。现在我正在尝试编译主程序,但不知道如何告诉 SCons 在哪里查找库和标头。

我已经尝试过(除其他外):

scons prefix=/home/dja/ocr

scons includepath=/home/dja/ocr/include libpath=/home/dja/ocr/lib

env LIBPATH=/home/dja/ocr/lib INCLUDEPATH=/home/dja/ocr/include scons

...etc...

结果总是相同的:

scons: Reading SConscript files ...  
Currently supported OS version: Ubuntu 10.04  
Checking for C++ library iulib... no  
AssertionError: :  
  File "/home/dja/ocr/src/ocropus/SConstruct", line 107:  
    assert conf.CheckLibWithHeader("iulib","iulib/iulib.h","C++");  

我无法在谷歌上找到答案。

使其正常工作的正确 SCons foo 是什么?

I'm trying to use SCons to compile a program that requires a set of dependencies which I've installed in a non-standard location.

I've installed the dependencies in /home/dja/ocr. Now I'm trying to compile the main program and can't figure out how to tell SCons where to look for the libraries and headers.

I've tried (amongst others):

scons prefix=/home/dja/ocr

scons includepath=/home/dja/ocr/include libpath=/home/dja/ocr/lib

env LIBPATH=/home/dja/ocr/lib INCLUDEPATH=/home/dja/ocr/include scons

...etc...

The results are always the same:

scons: Reading SConscript files ...  
Currently supported OS version: Ubuntu 10.04  
Checking for C++ library iulib... no  
AssertionError: :  
  File "/home/dja/ocr/src/ocropus/SConstruct", line 107:  
    assert conf.CheckLibWithHeader("iulib","iulib/iulib.h","C++");  

I haven't been able to find an answer on Google.

What is the correct SCons foo to get this to work?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

手心的海 2024-10-18 23:11:52

您需要创建一个环境并设置适当的变量:

env = Environment(
          CPPPATH=['/home/dja/ocr/include'],
          LIBPATH=['/home/dja/ocr/lib'],
          LIBS=['iulib'])
env.Program('my_executable', Glob('*.c'))

CPPPATH 指向 C 预处理器路径列表(注:3 P)。 LIBPATH 指向您的库所在的位置。最后,LIBS 是与您的程序链接的库列表。

You need to create an environment and set appropriate variables:

env = Environment(
          CPPPATH=['/home/dja/ocr/include'],
          LIBPATH=['/home/dja/ocr/lib'],
          LIBS=['iulib'])
env.Program('my_executable', Glob('*.c'))

The CPPPATH points to a list of C Pre-Processor Paths (Note: 3 P's). LIBPATH points to where your libraries reside. Finally, LIBS is a list of libraries to link with your program.

月棠 2024-10-18 23:11:52

ma​​ke及其对某些环境变量的约定或configure--with-X选项不同,SConstruct的作者需要提供用户指定覆盖的方法。默认情况下,scons 不会从环境中读取构建变量。

有多种处理用户配置的方法(请参阅我刚刚了解的 变量 ),但我不知道有哪些受到广泛尊重的约定。对于您所处位置的用户,您需要依赖作者编写构建文档或体面的 scons --help 描述,或者自己阅读 SConstruct (有时您必须使用写得不好非常规的Makefiles)。

顺便说一句,如果我对 scons 的了解已经过时,我很乐意对此进行纠正。

Unlike with make and its conventions for certain environment variables or the --with-X options to configure, the author of the SConstruct needs to provide a way for a user to specify overrides. By default, scons doesn't read build variables from the environment.

There are various ways of handling user configuration (see Variables which I just learned about), but I'm not aware of widely honored conventions. And for the user in your position, you need to rely on the author writing build documentation or a decent scons --help description, or resort to reading the SConstruct yourself (which you sometimes have to resort to with badly written unconventional Makefiles).

BTW, I would be happy to be corrected on this if my knowledge of scons is out of date.

不回头走下去 2024-10-18 23:11:52

似乎可以通过编辑 SConstruct 文件来做到这一点: http://osdir.com/ml/programming.tools.scons.user/2005-09/msg00060.html

这非常蹩脚 - 有没有更好的通用方法?

(在这种情况下,阅读 SConstruct 文件显示有一项特殊规定专门提供了依赖项的路径,因此我解决了眼前的问题,但没有解决一般问题。)

It seems it's possible to do this by editing the SConstruct file: http://osdir.com/ml/programming.tools.scons.user/2005-09/msg00060.html

This is pretty lame - is there a better general way?

(In this case, reading the SConstruct file showed there was a special provision for providing a path to the dependency specifically, so I've solved the immediate problem but not the general one.)

甜味拾荒者 2024-10-18 23:11:52

我发现将 LINKPATH="-L/blah/" 作为环境变量传递给 scons 是有效的,而传递 LDFLAGS="-L/blah/" 则无效。

I found passing LINKPATH="-L/blah/" as an environmental variable to scons worked, when passing LDFLAGS="-L/blah/" did not.

π浅易 2024-10-18 23:11:52

sudo scons --32 --libpath=/home/test/project/stage/lib/ --cpppath=/home/test/project/boost/ --prefix=/home/test/mongClient/output --dbg=on --opt=on install

其中 libpath 用于从非标准位置链接库。 cpppath 用于包含非标准位置的头文件。

sudo scons --32 --libpath=/home/test/project/stage/lib/ --cpppath=/home/test/project/boost/ --prefix=/home/test/mongClient/output --dbg=on --opt=on install

Where libpath is for linking the library from non-standard location. cpppath is for including the header files from non-standard location.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文