本文介绍了编译时,Scons VariantDir() 重复了 CPPPATH 和 LIBPATH?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时删除!!

这是我的简单案例.我得到的源文件结构如下:

.├── S构造└── src├── SConscript├── 静态库│ ├── classInStaticLib.cpp│ ├── classInStaticLib.h│ └── SConscript└── test.cpp

S构造:

VariantDir('build', 'src', duplicate=0)SConscript('构建/SConscript')

src/SConscript:

导入操作系统lib = '静态库'SConscript(os.path.join(lib, 'SConscript'))程序('测试','test.cpp',CPPPATH = lib,LIBS = 库,LIBPATH = 库 )

src/staticLib/SConscript:

Library('staticLib', 'classInStaticLib.cpp')

运行 scons 后,我在 shell 中得到以下信息:

g++ -o build/staticLib/classInStaticLib.o -c src/staticLib/classInStaticLib.cppar rc build/staticLib/libstaticLib.a build/staticLib/classInStaticLib.oranlib 构建/staticLib/libstaticLib.ag++ -o build/test.o -c -Ibuild/staticLib -Isrc/staticLib src/test.cppg++ -o build/test build/test.o -Lbuild/staticLib -Lsrc/staticLib -lstaticLib

scons 完成,没有错误.但请注意,第 4 行有-Ibuild/staticLib"和-Isrc/staticLib",第 5 行有-Lbuild/staticLib"和-Lsrc/staticLib".应该只有一个.

为什么会这样?

解决方案

根据我在 SCons-users 邮件列表上得到的回复,这是使用 VariantDir() 的正常和预期"效果.

参见 four.pairlist.net/pipermail/scons-users/2014-April/002440.html

Pawel 说:您可能生成了源文件/标头(例如使用 SWIG 或通过 SConf)并且它们转到变体目录,其他直接从源目录中获取,因此 -Ibuild/staticLib -Isrc/staticLib 是正确的在我看来."

Here's my simple case. I got a source file structure as following:

.
├── SConstruct
└── src
    ├── SConscript
    ├── staticLib
    │   ├── classInStaticLib.cpp
    │   ├── classInStaticLib.h
    │   └── SConscript
    └── test.cpp

SConstruct:

VariantDir('build', 'src', duplicate=0)
SConscript('build/SConscript')

src/SConscript:

import os
lib = 'staticLib'
SConscript(os.path.join(lib, 'SConscript'))
Program( 'test',
         'test.cpp',
         CPPPATH = lib,
         LIBS = lib,
         LIBPATH = lib )

src/staticLib/SConscript:

Library('staticLib', 'classInStaticLib.cpp')

After I run scons, I got following in shell:

g++ -o build/staticLib/classInStaticLib.o -c src/staticLib/classInStaticLib.cpp
ar rc build/staticLib/libstaticLib.a build/staticLib/classInStaticLib.o
ranlib build/staticLib/libstaticLib.a
g++ -o build/test.o -c -Ibuild/staticLib -Isrc/staticLib src/test.cpp
g++ -o build/test build/test.o -Lbuild/staticLib -Lsrc/staticLib -lstaticLib

scons completed with no error. But please attention that there're both "-Ibuild/staticLib" and "-Isrc/staticLib" in 4th line, and both "-Lbuild/staticLib" and "-Lsrc/staticLib" in 5th line. There should be only one.

Why this happens ?

解决方案

This is a "normal and intended" effect of using VariantDir() according to a response I got about this on the SCons-users mailing list.

See four.pairlist.net/pipermail/scons-users/2014-April/002440.html

Pawel said: "You may have source files/headers generated (with SWIG for example or by SConf) and they go to variant dir, others are taken directly from source dir, so -Ibuild/staticLib -Isrc/staticLib is correct in my opinion."

这篇关于编译时,Scons VariantDir() 重复了 CPPPATH 和 LIBPATH?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

1403页,肝出来的..

09-07 16:50