luabind 0.8.1的编译(VC71编译)

时间:2022-06-11 17:23:00

首先是从https://sourceforge.net/projects/luabind/下载原代码

我的环境是:winxp SP3英文版本.VC2003(VC7.1.3091).BOOST 1.38

有两种方法可以用来编译luabind 0.8.1:

方法一 使用bjam系统编译:这是个批处理文件luabind081.bat:

内如如下:

rem build  luabind-0.8.1 for vc71,lua5.14,boost_138
SET TEMP=E:/temp
SET TMP=E:/temp
SET BOOST_ROOT=D:/STLDIR/boost_1_38_0
SET LUA_PATH=D:/GNU/lua-5.1.4

rem 必须使用VC7的编译环境文件
BJAM --toolset=msvc-7.1 >log.txt

rem 批处理文件结束

本方法的关键点(3点)

a.使用”Visual Studio .NET 2003 命令提示”而不是cmd.exe来执行批处理文件

b.批处理文件应该放在luabind-0.8.1目录下面,注意不要放错位置

c.编译需要用lua5.1.lib.这是通过编译lua5.14代码生成的.

方法二 使用修改后的工程文件进行编译:

如下为我使用的.vcproj文件的全内容:


    ProjectType="Visual C++"
    Version="7.10"
    Name="luabind"
    ProjectGUID="{28AAA965-843E-44FA-8D8A-6D4B717E2C4A}"
    Keyword="Win32Proj">
   
                    Name="Win32"/>
   
   
                    Name="Debug|Win32"
            OutputDirectory="$(SolutionDir)$(ConfigurationName)"
            IntermediateDirectory="Debug"
            ConfigurationType="4"
            UseOfMFC="2"
            CharacterSet="2">
                            Name="VCCLCompilerTool"
                Optimization="0"
                PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;luabind_EXPORTS;LUA_BUILD_AS_DLL"
                MinimalRebuild="TRUE"
                BasicRuntimeChecks="3"
                RuntimeLibrary="3"
                RuntimeTypeInfo="TRUE"
                UsePrecompiledHeader="0"
                WarningLevel="3"
                Detect64BitPortabilityProblems="TRUE"
                DebugInformationFormat="4"/>
                            Name="VCCustomBuildTool"/>
                            Name="VCLibrarianTool"
                OutputFile="lib/luabindD.lib"/>
                            Name="VCMIDLTool"/>
                            Name="VCPostBuildEventTool"/>
                            Name="VCPreBuildEventTool"/>
                            Name="VCPreLinkEventTool"/>
                            Name="VCResourceCompilerTool"/>
                            Name="VCWebServiceProxyGeneratorTool"/>
                            Name="VCXMLDataGeneratorTool"/>
                            Name="VCManagedWrapperGeneratorTool"/>
                            Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
       
                    Name="Release|Win32"
            OutputDirectory="$(SolutionDir)$(ConfigurationName)"
            IntermediateDirectory="Release"
            ConfigurationType="4"
            UseOfMFC="2"
            CharacterSet="2">
                            Name="VCCLCompilerTool"
                PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;luabind_EXPORTS;LUA_BUILD_AS_DLL"
                RuntimeLibrary="2"
                RuntimeTypeInfo="TRUE"
                UsePrecompiledHeader="0"
                WarningLevel="3"
                Detect64BitPortabilityProblems="TRUE"
                DebugInformationFormat="3"/>
                            Name="VCCustomBuildTool"/>
                            Name="VCLibrarianTool"
                OutputFile="lib/luabind.lib"/>
                            Name="VCMIDLTool"/>
                            Name="VCPostBuildEventTool"/>
                            Name="VCPreBuildEventTool"/>
                            Name="VCPreLinkEventTool"/>
                            Name="VCResourceCompilerTool"/>
                            Name="VCWebServiceProxyGeneratorTool"/>
                            Name="VCXMLDataGeneratorTool"/>
                            Name="VCManagedWrapperGeneratorTool"/>
                            Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
       
   
   
   
   
                    Name="源文件"
            Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx"
            UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}">
                            RelativePath="./src/class.cpp">
           
                            RelativePath="./src/class_info.cpp">
           
                            RelativePath="./src/class_registry.cpp">
           
                            RelativePath="./src/class_rep.cpp">
           
                            RelativePath="./src/create_class.cpp">
           
                            RelativePath="./src/error.cpp">
           
                            RelativePath="./src/exception_handler.cpp">
           
                            RelativePath="./src/find_best_match.cpp">
           
                            RelativePath="./src/function.cpp">
           
                            RelativePath="./src/implicit_cast.cpp">
           
                            RelativePath="./src/link_compatibility.cpp">
           
                            RelativePath="./src/object_rep.cpp">
           
                            RelativePath="./src/open.cpp">
           
                            RelativePath="./src/overload_rep.cpp">
           
                            RelativePath="./src/pcall.cpp">
           
                            RelativePath="./src/ref.cpp">
           
                            RelativePath="./src/scope.cpp">
           
                            RelativePath="./src/stack_content_by_name.cpp">
           
                            RelativePath="./src/weak_ref.cpp">
           
                            RelativePath="./src/wrapper_base.cpp">
           
       
                    Name="头文件"
            Filter="h;hpp;hxx;hm;inl;inc;xsd"
            UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}">
                            RelativePath="./luabind/adopt_policy.hpp">
           
                            RelativePath="./luabind/back_reference.hpp">
           
                            RelativePath="./luabind/back_reference_fwd.hpp">
           
                            RelativePath="./luabind/class.hpp">
           
                            RelativePath="./luabind/class_info.hpp">
           
                            RelativePath="./luabind/config.hpp">
           
                            RelativePath="./luabind/container_policy.hpp">
           
                            RelativePath="./luabind/copy_policy.hpp">
           
                            RelativePath="./luabind/dependency_policy.hpp">
           
                            RelativePath="./luabind/discard_result_policy.hpp">
           
                            RelativePath="./luabind/error.hpp">
           
                            RelativePath="./luabind/from_stack.hpp">
           
                            RelativePath="./luabind/function.hpp">
           
                            RelativePath="./luabind/get_pointer.hpp">
           
                            RelativePath="./luabind/handle.hpp">
           
                            RelativePath="./luabind/iterator_policy.hpp">
           
                            RelativePath="./luabind/lua_include.hpp">
           
                            RelativePath="./luabind/luabind.hpp">
           
                            RelativePath="./luabind/nil.hpp">
           
                            RelativePath="./luabind/object.hpp">
           
                            RelativePath="./luabind/open.hpp">
           
                            RelativePath="./luabind/operator.hpp">
           
                            RelativePath="./luabind/out_value_policy.hpp">
           
                            RelativePath="./luabind/prefix.hpp">
           
                            RelativePath="./luabind/raw_policy.hpp">
           
                            RelativePath="./luabind/return_reference_to_policy.hpp">
           
                            RelativePath="./luabind/scope.hpp">
           
                            RelativePath="./luabind/value_wrapper.hpp">
           
                            RelativePath="./luabind/weak_ref.hpp">
           
                            RelativePath="./luabind/wrapper_base.hpp">
           
                            RelativePath="./luabind/yield_policy.hpp">
           
       
                    Name="资源文件"
            Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx"
            UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}">
       
                    RelativePath="./ReadMe.txt">
       
   
   
   

使用vcproj的方式比较灵活.容易控制编译选项.注意的问题是配置好环境变量.