链接错误与Lua?

ieg*_*god 2 c++ linker lua

我有一个简单的测试应用程序,我正在尝试用Lua(在Linux上)用C++构建.构建线看起来像这样:

g++ -o"LuaTest" ./src/LuaTest.o -l/home/diego/lua-5.1.4/src/liblua.a
Run Code Online (Sandbox Code Playgroud)

并且它吐出了这个错误:

/usr/bin/ld: cannot find -l/home/diego/lua-5.1.4/src/liblua.a
Run Code Online (Sandbox Code Playgroud)

这将是一切都很好,除了我正盯着liblua.a正好在那个文件夹中.我在Windows下使用MinGW和Lua的Windows二进制文件尝试了类似的配置,令人震惊的是我得到了完全相同的结果,只是它抱怨lua51.lib或lua5.1.lib或我尝试的任何文件.

我在这里错过了什么?

如果重要的是这里的应用程序:

extern "C"
{
#include "lua.h"
#include "lualib.h"
#include "lauxlib.h"
}

int main()
{
    return 0; //this really should compile -_-
}
Run Code Online (Sandbox Code Playgroud)

int*_*jay 6

遗漏了-l.它应该只是:

g++ -o"LuaTest" ./src/LuaTest.o /home/diego/lua-5.1.4/src/liblua.a
Run Code Online (Sandbox Code Playgroud)

-l开关告诉g ++自动添加文件名lib.a部分文件,并在标准库目录中查找 - 这里你不需要.