Как построить проект C ++ с помощью Scons 2.3 Visual Express 2012?

Я попробую:

env = Environment(ENV = {'PATH' : os.environ['PATH'], \
'INCLUDE' : 'c:\\Program Files (x86)\\Microsoft Visual Studio 11.0\\VC\\include\\', \
'LIB' : 'c:\\Program Files (x86)\\Microsoft Visual Studio 11.0\\VC\\lib\\'})

но это не работает.
сообщение об ошибке:
«cl» не является командой …

Я нашел описание в scons wiki (http://www.scons.org/wiki/PlatformSpecificNotes#Visual_C.2B-.2B-):
Если вы используете Microsoft Visual C ++, вам нужно установить «INCLUDE», «LIB» и «PATH» в своей среде, а затем импортировать их при создании объекта «Environment». Они будут использоваться для поиска инструментов MSVC ++ и установки CPPFLAGS и т. Д.

Что я делаю неправильно?

полное sconstruct (работает на ubuntu и на windows с mingw):

import os
import sys

if ARGUMENTS.get('ndk', 0):
current_dir = os.getcwd()#os.path.dirname(os.path.abspath(__file__))
os.environ["NDK_PROJECT_PATH"] = current_dir + '/android-project'
os.system("ndk-build") # use V=1 if can't compile for android
exit(0)

if ARGUMENTS.get('ant', 0):
current_dir = os.getcwd()#os.path.dirname(os.path.abspath(__file__))
android_prj_path = current_dir + '/android-project'
os.chdir(android_prj_path)
os.system("ant debug") # use V=1 if can't compile for android
exit(0)

VariantDir('obj', 'src', duplicate = 0)

if sys.platform == 'win32':
if ARGUMENTS.get('msvc', 0) == "1":
env = Environment(ENV = {'PATH' : os.environ['PATH'], \
'INCLUDE' : 'c:\\Program Files (x86)\\Microsoft Visual Studio 11.0\\VC\\include\\', \
'LIB' : 'c:\\Program Files (x86)\\Microsoft Visual Studio 11.0\\VC\\lib\\'})
else:
env = Environment(tools = ['mingw'])
env.Append(CCFLAGS = '-U__STRICT_ANSI__') # for boost::program_options on mingw 4.7
env.Append(LINKFLAGS = '-mwindows')
env.Append(LIBS = ['mingw32', 'SDL2', 'SDL2main', 'm', 'user32', 'gdi32', \
'winmm', 'imm32', 'ole32', 'oleaut32', 'version', \
'uuid', 'glew32', 'opengl32'])
else:
env = Environment()
env.Append(CCFLAGS = '-rdynamic')
env.Append(LIBS = ['SDL2', 'pthread', 'm', 'dl', 'GL'])

env.Append(CCFLAGS = '-fno-strict-aliasing') # for angelscript compile see doc
cur_dir = os.getcwd()
env.Append(CCFLAGS = '-I ' + cur_dir) # for boost find in include path
env.Append(CCFLAGS = '-g -std=c++0x -Wall -Wfatal-errors') #-msse2 -pg
env.Append(LINKFLAGS=[]) # -pg

src = Glob('obj/*.cpp')
src += Glob('obj/scene2d/*.cpp')
src += Glob('obj/pugixml/*.cpp')
src += Glob('obj/debug_support/*.cpp')
src += Glob('obj/angelscript/*.cpp')
src += Glob('obj/scriptarray/*.cpp')
src += Glob('obj/scriptstdstring/*.cpp')
src += Glob('obj/scriptbuilder/*.cpp')
src += Glob('obj/boost_libs_src/program_options/src/*.cpp')
src += Glob('obj/boost_libs_src/smart_ptr/src/*.cpp')
src += Glob('obj/boost_libs_src/system/src/*.cpp')
src += Glob('obj/boost_libs_src/filesystem/src/*.cpp')
src += Glob('obj/libwebp/*/*.c')
src += Glob('obj/zlib/*.c')
src += Glob('obj/libpng/*.c')

env.Program(target = 'start', source = src)

5

Решение

Лучший способ использовать scons и MSVC:

env = Environment( MSVC_USE_SCRIPT = "c:\\Program Files (x86)\\Microsoft Visual Studio 11.0\\VC\\bin\\vcvars32.bat")
7

Другие решения

Полный сценарий, который работает для меня

import os
import sys

current_dir = os.getcwd()#os.path.dirname(os.path.abspath(__file__))

if ARGUMENTS.get('ndk', 0):
os.environ["NDK_PROJECT_PATH"] = current_dir + '/android-project'
os.system("ndk-build") # use V=1 if can't compile for android
Exit(0)

if ARGUMENTS.get('ant', 0):
android_prj_path = current_dir + '/android-project'
os.chdir(android_prj_path)
os.system("ant debug") # use V=1 if can't compile for android
Exit(0)

VariantDir('obj', 'src', duplicate = 0)

if sys.platform == 'win32':
if ARGUMENTS.get('msvc', 0) == "1":
#os.system('"C:\\Program Files (x86)\\Microsoft Visual Studio 11.0\\VC\\bin\\vcvars32"')
env = Environment(ENV = {'PATH' : os.environ['PATH'], \
'INCLUDE' : 'c:\\Program Files (x86)\\Microsoft Visual Studio 11.0\\VC\\include\\;c:\\Program Files (x86)\\Windows Kits\\8.0\\Include\um\\;c:\\Program Files (x86)\\Windows Kits\\8.0\\Include\\shared\\', \
'LIB' : 'c:\\Program Files (x86)\\Microsoft Visual Studio 11.0\\VC\\lib\\;c:\\Program Files (x86)\\Windows Kits\\8.0\\Lib\\win8\\um\\x86\\'})
env.Append(CCFLAGS = '-I ' + current_dir + '/dep/msvc/include') # for SDL2 on windows
env.Append(CCFLAGS = '/Od /EHsc -DBOOST_ALL_NO_LIB')
env.Append(LINKFLAGS = '/LIBPATH:' + current_dir + '/dep/msvc/lib/')
env.Append(LINKFLAGS = '/SUBSYSTEM:WINDOWS')
env.Append(LIBS = ['user32', 'gdi32', \
'winmm', 'imm32', 'ole32', 'oleaut32', 'version', \
'uuid', 'glew32s', 'opengl32'])
else:
env = Environment(tools = ['mingw'])
env.Append(CCFLAGS = '-U__STRICT_ANSI__') # for boost::program_options on mingw 4.7
env.Append(LINKFLAGS = '-mwindows')
env.Append(LIBS = ['mingw32', 'SDL2', 'SDL2main', 'm', 'user32', 'gdi32', \
'winmm', 'imm32', 'ole32', 'oleaut32', 'version', \
'uuid', 'glew32', 'opengl32'])
else:
env = Environment()
env.Append(LIBS = ['SDL2', 'pthread', 'm', 'dl', 'GL'])

if ARGUMENTS.get('msvc', 0) != "1":
env.Append(CCFLAGS = '-fno-strict-aliasing') # for angelscript compile see doc
env.Append(CCFLAGS = '-std=c++0x -Wall -Wfatal-errors')

env.Append(CCFLAGS = '-I ' + current_dir) # for boost find in include path

if ARGUMENTS.get('release', 0) == "1":
if sys.platform != 'win32':
env.Append(CCFLAGS = '-DNO_OPENGL_CHECK -DSDL_ASSERT_LEVEL=1 -O2 -msse2') #-DNO_OPENGL_CHECK -DSDL_ASSERT_LEVEL=1 -O3 -msse2
else:
env.Append(CCFLAGS = '/MD')
env.Append(LIBS = ['SDLmain', 'SDL', 'msvcrt'])
else:
if sys.platform != 'win32':
env.Append(LINKFLAGS=['-rdynamic']) # $(sdl2-config --static-libs)
env.Append(CCFLAGS = '-g')
else:
env.Append(CCFLAGS = '/MDd /Gm- /Zi -D_DEBUG /Od ')
env.Append(LINKFLAGS=['/INCREMENTAL'])
env['PDB'] = ['start.pdb']
env['CCPDBFLAGS'] = ['${(PDB and "/Zi /Fd%s" % File(PDB)) or ""}']
env.Append(LIBS = ['SDLmain_d', 'SDL_d', 'MSVCRTD', 'libcmt'])

src = Glob('obj/*.cpp')
src += Glob('obj/scene2d/*.cpp')
src += Glob('obj/pugixml/*.cpp')
src += Glob('obj/debug_support/*.cpp')
src += Glob('obj/angelscript/*.cpp')
src += Glob('obj/scriptarray/*.cpp')
src += Glob('obj/scriptstdstring/*.cpp')
src += Glob('obj/scriptbuilder/*.cpp')
src += Glob('obj/scripthelper/*.cpp')
src += Glob('obj/boost_libs_src/program_options/src/*.cpp')
src += Glob('obj/boost_libs_src/smart_ptr/src/*.cpp')
src += Glob('obj/boost_libs_src/system/src/*.cpp')
src += Glob('obj/boost_libs_src/filesystem/src/*.cpp')
src += Glob('obj/libwebp/*/*.c')
src += Glob('obj/zlib/*.c')
src += Glob('obj/libpng/*.c')

prog = env.Program(target = 'start', source = src)
1

По вопросам рекламы [email protected]