提问人:Martian 提问时间:8/26/2020 最后编辑:JabberwockyMartian 更新时间:8/26/2020 访问量:304
将 lua 嵌入到 c++ 中,但得到未解析的外部问题:floor、freopen 和 strcoll
Embedding lua into c++ but getting unresolved externals : floor, freopen & strcoll
问:
我正在将 lua 嵌入到 c++ vs2019 解决方案中,它会导致链接到基本 c 库的错误
( 和 )。__imp_freopen
__imp_floor
__imp_strcoll
lua 在它自己的项目中编译为静态 C 库并链接到主项目,但是在使用时,我得到了 、 和 的未解析外部符号。luaL_newstate();
freopen(...)
floor(...)
strcmp(...)
我最好的猜测是这个错误来自我的构建系统(premake5),因为当我使用 vs2019 手动添加项目时,没有链接错误,但由于我经常跨操作系统处理这个项目,因此没有正确地进行预制工作会带来很多问题。 我将不胜感激关于如何缩小问题范围的任何想法。
Lua 的预制件:
project "lua"
kind "StaticLib"
language "C"
targetdir ("bin/" .. outputdir .. "/%{prj.name}")
objdir ("bin-int/" .. outputdir .. "/%{prj.name}")
files
{
"src/**.c",
"src/**.h",
"src/lua.hpp"
}
excludes
{
"src/lua.c",
"src/luac.c"
}
filter "configurations:Debug"
runtime "Debug"
symbols "on"
filter "configurations:Release"
runtime "Release"
optimize "on"
解决方案的相关预制件:
workspace "solution"
architecture "x86_64"
startproject "test"
configurations
{
"Debug",
"Release"
}
flags
{
"MultiProcessorCompile"
}
outputdir = "%{cfg.buildcfg}-%{cfg.system}-%{cfg.architecture}"
IncludeDir = {}
IncludeDir["GLFW"] = "engine/vendor/GLFW/include"
IncludeDir["Glad"] = "engine/vendor/Glad/include"
IncludeDir["ImGui"] = "engine/vendor/imgui"
IncludeDir["glm"] = "engine/vendor/glm"
IncludeDir["stb_image"] = "engine/vendor/stb_image"
IncludeDir["lua"] = "engine/vendor/lua"
group "dependencies"
include "engine/vendor/GLFW"
include "engine/vendor/Glad"
include "engine/vendor/imgui"
include "engine/vendor/lua"
group ""
project "engine"
location "engine"
kind "StaticLib"
language "C++"
cppdialect "C++17"
staticruntime "on"
targetdir ("bin/" .. outputdir .. "/%{prj.name}")
objdir ("bin-int/" .. outputdir .. "/%{prj.name}")
pchheader "pch.h"
pchsource "engine/src/pch.cpp"
files
{
"%{prj.name}/src/**.h",
"%{prj.name}/src/**.cpp",
"%{prj.name}/vendor/stb_image/**.h",
"%{prj.name}/vendor/stb_image/**.cpp",
"%{prj.name}/vendor/glm/glm/**.hpp",
"%{prj.name}/vendor/glm/glm/**.inl"
}
defines
{
"_CRT_SECURE_NO_WARNINGS",
"GLFW_INCLUDE_NONE"
}
includedirs
{
"%{prj.name}/src",
"%{prj.name}/vendor/spdlog/include",
"%{IncludeDir.GLFW}",
"%{IncludeDir.Glad}",
"%{IncludeDir.ImGui}",
"%{IncludeDir.glm}",
"%{IncludeDir.stb_image}",
"%{IncludeDir.lua}"
}
links
{
"GLFW",
"Glad",
"ImGui",
"opengl32.lib",
"lua"
}
filter "configurations:Debug"
runtime "Debug"
optimize "off"
symbols "on"
filter "configurations:Release"
runtime "Release"
optimize "on"
project "test"
location "test"
kind "ConsoleApp"
language "C++"
cppdialect "C++17"
staticruntime "on"
targetdir ("bin/" .. outputdir .. "/%{prj.name}")
objdir ("bin-int/" .. outputdir .. "/%{prj.name}")
files
{
"%{prj.name}/src/**.h",
"%{prj.name}/src/**.cpp",
"%{prj.name}/*.cpp"
}
includedirs
{
"engine/vendor/spdlog/include",
"engine/src",
"engine/vendor",
"%{IncludeDir.GLFW}",
"%{IncludeDir.Glad}",
"%{IncludeDir.ImGui}",
"%{IncludeDir.glm}"
}
links
{
"engine"
}
filter "configurations:Debug"
runtime "Debug"
symbols "on"
filter "configurations:Release"
runtime "Release"
optimize "on"
lua.hpp 仅lua_script.cpp包含在class lua_script {...};
答: 暂无答案
评论