开发者

SCons - Headers/Libraries in a non-standard location

开发者 https://www.devze.com 2023-02-03 19:46 出处:网络
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'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开发者_如何学C=/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?


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.


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.


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.)


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


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消