我需要使用thrift创建C ++应用程序并使用SCons构建它。为了做到这一点,我已经下载并安装了所有需要的库(并确保它们都适用于x64 Windows) - boost,openssl,libevent。
我用命令构建了boost:
b2 -j4 toolset=msvc-14.1 address-model=64 architecture=x86 link=static threading=multi runtime-link=shared --build-type=complete stage --stagedir=stage/x64
接下来,我在VS2017(x64 / Release)中构建了Thrift库。
但是,当我尝试使用SCons构建项目时,我会遇到错误。 当我尝试使用SConstruct文件时(从VS2017的Developer Command Prompt运行):
import os
from os import path, listdir
gen_cpp = [path.join('gen-cpp', f) for f in listdir('gen-cpp') if
f.endswith('.cpp')]
client_source = [path.join('logic', folder, f) for folder in ['', 'parser',
'mars', 'view']
for f in listdir(path.join('logic', folder)) if
f.endswith('.cpp')]
server_source = [path.join('server', 'server.cpp')]
tests_source = [path.join('test_cases', f) for f in listdir('test_cases') if
f.endswith('.cpp')]
cpppath = ['.','c:\\Users\\Antek\\libs\\thrift-0.10.0\\thrift-
0.10.0\\lib\\cpp\\src\\','c:\\Users\\Antek\\libs\\boost_1_64_0\\boost\\']
libpath = ['C:\\Users\\Antek\\libs\\thrift-0.10.0\\thrift-
0.10.0\\lib\\cpp\\x64\\Release\\',
'c:\\Users\\Antek\\libs\\boost_1_64_0\\boost\\stage_x64\\lib\\',
'C:\\OpenSSL-Win64\\lib']
libs = ['libthrift']
env = Environment(
CPPPATH = cpppath,
LIBS = libs,
LIBPATH = libpath,
CPPFLAGS='/EHsc',
)
gen_cpp_o = env.Object(gen_cpp)
client_o = env.Object(client_source)
tests_o = env.Object(tests_source)
tests_files = gen_cpp_o + [f for f in client_o if str(f) !=
path.join('logic', 'main.obj')] + tests_o
env.Program('CoreWars', gen_cpp_o + client_o)
env.Program('Server', gen_cpp_o + server_source)
env.Program('tests', tests_files)
我明白了:
scons: Reading SConscript files ...
scons: done reading SConscript files.
scons: Building targets ...
cl /Fogen-cpp\MARS.obj /c gen-cpp\MARS.cpp /TP /nologo /EHsc /I.
/IC:\Users\Antek\libs\thrift-0.10.0\thrift-0.10.0\lib\cpp\src
/IC:\Users\Antek\libs\boost_1_64_0\boost
'cl' is not recognized as an internal or external command,
operable program or batch file.
scons: *** [gen-cpp\MARS.obj] Error 1
scons: building terminated because of errors.
当我将以下行添加到我的SConstruct时:
ENV = os.environ
我收到错误:
Libthrift.lib (TOutput.obj): MSIL .netmodule module found or module compiled
with / GL; Consolidation will start again with the / LTCG option; Add the /
LTCG option to the consolidation command line to improve the performance of
the consolidator
Fatal error C1905: Frontend and backend are not compatible (must refer to
the same processor)
LINK: fatal error LNK1257: code generation failed
Scons: *** [CoreWars.exe] Error 1257
Scons: building terminated because of errors
我已经花了太多时间在这上面,所有的想法都将受到高度赞赏。谢谢。