简体   繁体   English

编译wxLua(跨平台和静态)

[英]Compiling wxLua (cross-platform & static)

I'm planning to create a new C++ project, write some C++ functions in it, embed a Lua engine with wxLua into it, make my C/C++ functions available to a Lua side and then write my main program (including the GUI) in Lua. 我打算创建一个新的C ++项目,在其中编写一些C ++函数,将带有wxLua的Lua引擎嵌入其中,使我的C / C ++函数可用于Lua端,然后在其中编写我的主程序(包括GUI) a

My IDE/compiler are Code::Blocks/GCC on Windows. 我的IDE /编译器是Windows上的Code :: Blocks / GCC。 I want to compile it for Windows, Linux and OSX. 我想针对Windows,Linux和OSX进行编译。

My issues: 我的问题:

  • compiling wxWidgets and Lua 编译wxWidgets和Lua
  • building wxLua 建筑wxLua
  • creating a cross-platform project that knows which libs to use for which OS 创建一个跨平台项目,该项目知道要在哪个OS上使用哪些库

I read a lot of documentation on wxLua and found that you should probably use wxWidgets 2.8.12 and Lua 5.2.3 (as they are the two latest stable and supported versions). 我阅读了很多有关wxLua的文档,发现您可能应该使用wxWidgets 2.8.12和Lua 5.2.3(因为它们是两个最新的稳定和受支持的版本)。

If possible, I'd like the program to be a standalone executable in the end. 如果可能的话,我希望该程序最后成为一个独立的可执行文件。
So I guess I need to compile Lua and wxWidgets as .lib libraries (Windows) and .a libraries (Linux/OSX), is that correct? 所以我想我需要将Lua和wxWidgets编译为.lib库(Windows)和.a库(Linux / OSX),对吗? How would I do that? 我该怎么做?

Once that is done, what kind of project do I need to create and how would I embed wxLua into that project? 完成后, 我需要创建哪种项目,以及如何将wxLua嵌入到该项目中? I couldn't find a lot of information on that. 我找不到很多有关此的信息。

And finally, how would I tell my IDE/project/makefile(?) which libraries to use for which OS? 最后,我如何告诉我的IDE / project / makefile(?)在哪个OS上使用哪个库?

Here are my instructions on how I compile wxwidgets/wxlua on Windows/OSX/Linux for my cross-platform project, but I use gcc/mingw-tdm and not Code::Blocks, so you may need to adapt them to your environment. 以下是有关如何为跨平台项目在Windows / OSX / Linux上编译wxwidgets / wxlua的说明,但是我使用gcc / mingw-tdm而非Code :: Blocks,因此您可能需要使它们适应您的环境。

Here is how you can build wxwidgets on Windows: 这是在Windows上构建wxwidgets的方法:

  ./configure --prefix="$INSTALL_DIR" --disable-shared --enable-unicode \
    --enable-compat28 \
    --with-libjpeg=builtin --with-libpng=builtin --with-libtiff=no --with-expat=no \
    --with-zlib=builtin --disable-richtext \
    CFLAGS="-Os -fno-keep-inline-dllexport" CXXFLAGS="-Os -fno-keep-inline-dllexport"
  make
  make install

This is how you can build wxlua on Windows: 这是在Windows上构建wxlua的方法:

  cmake -G "MSYS Makefiles" -DCMAKE_INSTALL_PREFIX="$INSTALL_DIR" -DCMAKE_BUILD_TYPE=MinSizeRel -DBUILD_SHARED_LIBS=FALSE \
    -DwxWidgets_CONFIG_EXECUTABLE="$INSTALL_DIR/bin/wx-config" \
    -DwxWidgets_COMPONENTS="stc;html;aui;adv;core;net;base" \
    -DwxLuaBind_COMPONENTS="stc;html;aui;adv;core;net;base" -DwxLua_LUA_LIBRARY_USE_BUILTIN=FALSE \
    -DwxLua_LUA_INCLUDE_DIR="$INSTALL_DIR/include" -DwxLua_LUA_LIBRARY="$INSTALL_DIR/lib/lua51.dll" .
  (cd modules/luamodule; make)
  (cd modules/luamodule; make install/strip)

You'll need to update wxlua build instructions to use Lua5.2 instead of Lua5.1 I'm using. 您需要更新wxlua构建说明以使用Lua5.2而不是我正在使用的Lua5.1。

I have working build scripts for Windows , OSX , and Linux in this repository . 此存储库中 ,我有适用于WindowsOSXLinux的构建脚本。 The scripts have been tested on the latest wxwidgets and wxlua versions (use trunks of both repositories). 该脚本已在最新的wxwidgets和wxlua版本(使用两个存储库的主干)上进行了测试。 They generate one wxlua library linked against Lua dll (on Windows), so it's not quite a static configuration you may be looking for, but having static build may prevent you from loading other Lua libraries (unless you export proper symbols and provide a proxy DLL as described here ), so I don't recommend that configuration. 它们生成一个链接到Lua dll的wxlua库(在Windows上),因此它并不是您所需要的静态配置,但是具有静态版本可能会阻止您加载其他Lua库(除非您导出适当的符号并提供代理DLL。如此处所述 ),因此我不建议您使用该配置。

Also, I'm still using Lua5.1 with wxlua and wxwidgets as this allows me to use LuaJIT as a drop-in replacement to get better performance in some cases. 另外,我仍然将Lua5.1与wxlua和wxwidgets一起使用,因为这允许我在某些情况下使用LuaJIT作为嵌入式替代品以获得更好的性能。 You won't have this option if you compile wxlua with Lua 5.2 as their ABI is different. 如果使用Lua 5.2编译wxlua,则它们将没有此选项,因为它们的ABI不同。

In terms of integration with your own C++-based toolkit, the best option is probably expose it as a Lua library and load from wxlua application as you'd load any other library as it allows you to keep your components independent of each other. 与您自己的基于C ++的工具包集成时,最好的选择可能是将其公开为Lua库,并从wxlua应用程序加载,因为您将加载其他任何库,因为它允许您使组件彼此独立。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM