Never mind, I figured out the issue. I am using CMake to build my dependencies. I did this to build liblua.a as well. But when I created the CMakeLists.txt file I just included every header and source file without paying enough attention to lua's Makefile (that's what I get for being in a hurry). So I included lua.c which defines main. Once I pulled that out of liblua it started working as expected.
gtest and lua incompatibility?
-
22-06-2023 - |
Вопрос
I regularly use gtest for automated testing of C/C++ code. I have started exploring adding Lua in some software for extensibility. The problem is that when I include both gtest and lua I end up not getting a running gtest program, but instead get a lua command prompt.
I am using Lua 5.1.5, and haven't tried it with 5.2 yet.
Here is a simple example:
#include "gtest/gtest.h"
extern "C" {
#include "lua.h"
}
using namespace std;
class lua_test : public ::testing::Test {
protected:
lua_test(){}
virtual ~lua_test(){}
virtual void SetUp()
{
}
virtual void TearDown()
{
}
};
TEST_F(lua_test, my_test)
{
}
I am suspecting that the issue is some conflict with defining main or something like that. Can anyone shed light on this?
I will continue to dig deeper and update if I figure it out.
Решение
Не связан с StackOverflow