2013-04-10 6 views
5

Ich versuche:Wie erstellt man C++ - Projekt mit 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\\'}) 

aber es funktioniert nicht. Fehlermeldung: "cl" nicht befehlen ...

I Beschreibung in scons-Wiki (http://www.scons.org/wiki/PlatformSpecificNotes#Visual_C.2B-.2B-): Bei der Verwendung von Microsoft Visual C++, müssen Sie auf 'enthalten', 'LIB' und 'PATH' Importieren Sie sie in Ihrer Umgebung, wenn Sie Ihr Objekt 'Umgebung' erstellen. Diese werden verwendet, um die MSVC++ Tools zu finden und 'CPPFLAGS' usw. zu setzen.

Was mache ich falsch?

komplette SConstruct (es funktioniert auf ubuntu, und auf Fenster mit 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) 
+0

Es ist nicht klar, was der Fehler ist. Wird der Compiler nicht gefunden? Können Sie den Rest des SConsctruct zeigen? – Brady

+0

Wie erstellt man Umgebung auf Windows7, Scons 2.3, MSVC 2012 Express? Ich denke Fehler dort. –

Antwort

7

beste Weg für mich arbeitet scons zu verwenden und MSVC ist:

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

Voll-Skript, das

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)