我正在研究一个非常古老的源代码(用Red Hat编译).之前它有lua-4.0.1所以我只编译了最新的lua(lua-5.1.4)并将它安装在与旧的相同的目录中.实现不是很大,所以除了一些函数名称之外没什么可改变的,我必须包含"lauxlib.h"才能让它编译.它编译没有任何问题,但它给出了这些链接错误.
/usr/local/lib/liblua.a(loadlib.o): In function `ll_load':
loadlib.o(.text+0x19): undefined reference to `dlopen'
loadlib.o(.text+0x2a): undefined reference to `dlerror'
/usr/local/lib/liblua.a(loadlib.o): In function `ll_sym':
loadlib.o(.text+0x52): undefined reference to `dlsym'
loadlib.o(.text+0x63): undefined reference to `dlerror'
/usr/local/lib/liblua.a(loadlib.o): In function `ll_unloadlib':
loadlib.o(.text+0x8): undefined reference to `dlclose'
Run Code Online (Sandbox Code Playgroud)
基本上所有路径都是正确的,但我使用与旧编译器相同的标志,我根本没有更改makefile.
-static -lpthread -lnsl -lutil -ldl -lmysqlclient -llua -llualib -lz -lcppunit
Run Code Online (Sandbox Code Playgroud)
ldl标志已经存在.
我只想知道要尝试的事情.一切都很受欢迎.这让我疯了.
我有一个看起来像这样的c ++宏
#define lua_tpushstring(L,n,f) \
(lua_pushstring(L, n), lua_pushstring(L, f))
Run Code Online (Sandbox Code Playgroud)
我想修改它,所以它像这样工作
#define lua_tpush(TYPE,L,n,f) \
(lua_pushstring(L, n), lua_pushTYPE(L, f))
lua_tpush(boolean, L, "a", true);
lua_tpush(string, L, "a", "");
Run Code Online (Sandbox Code Playgroud)
什么是简单的改变?
map<string, string> info;
info["name"] = "something";
info["id"] = "5665";
Run Code Online (Sandbox Code Playgroud)
在C++中初始化这样的地图有什么更好的方法?
编辑:我想这样做没有任何c ++库或额外的代码.像这样的东西:
info["name", "id"] = {"something", "5665"};
Run Code Online (Sandbox Code Playgroud)