fatal error LNK1127: library is corrupt
Got fatal error
I had an error when I changed the project Hazel configuration type from a dynamic library to a static library. Here is my error:
4>C:\Program Files (x86)\Windows Kits\10\lib\10.0.22621.0\um\x64\opengl32.lib : fatal error LNK1127: library is corrupt
I am sure that I did the same thing following the video called Static Libraries and the ZERO Warnings Game Engine series. It`s the 26th video. I mean I coded the premake5.lua files like what this video did.
Things I need to say
- Before I got this error, I got some warnings saying:
4>g:\learning\c++\projects\hazel\hazel\vendor\spdlog\include\spdlog\fmt\bundled\format-inl.h(1210): warning C4307: “*”: Integer constant overflow
I don't know if this has anything to do with the error LNK1127.
- I updated my Windows SDK after this error, but it didn`t work. I make sure that it`s not about my OpenGL32.lib. It should be some mistakes I made in the project but I didn't know.
My trying to fix it
1, I updated my Windows SDK from 10.0.22000.0 to 10.0.22621.0. 2, I reconfirmed the project ImGui history version
master:2ead726; docking:cf5a93a
3, I re-coded 4 files 'premake5.lua' following the video.
My question
- I don't know what caused the fatal error LNK1127. I search for information in Microsoft(https://learn.microsoft.com/en-us/cpp/error-messages/tool-errors/linker-tools-error-lnk1127?view=msvc-170), but the file says: The library file is corrupt. Rebuild the library.No more information I can get. I updated my Windows SDK. I think it is 'Rebuild the library'.
- I make sure that my file 'OpenGL32.lib' was not corrupt, but the ERROR said it was corrupt.
My Configuration
- Visual Studio 2017
- Windows 10 x64 with Windows SDK 10.0.22621.0.
- C++17
Here is my 4 premake5.lua code
premake5.lua of Hazel
workspace "Hazel"
architecture "x64"
configurations{
"Debug",
"Release",
"Dist"
}
outputdir="%{cfg.buildcfg}-%{cfg.system}-%{cfg.architecture}"
IncludeDir={}
IncludeDir["GLFW"]="Hazel/vendor/GLFW/include"
IncludeDir["Glad"]="Hazel/vendor/Glad/include"
IncludeDir["ImGui"]="Hazel/vendor/imgui"
IncludeDir["glm"]="Hazel/vendor/glm"
include "Hazel/vendor/GLFW"
include "Hazel/vendor/Glad"
include "Hazel/vendor/imgui"
project "Hazel"
location "Hazel"
kind "StaticLib"
language "C++"
cppdialect "C++17"
staticruntime "on"
targetdir ("bin/" .. outputdir .. "/%{prj.name}")
objdir ("bin-int/" .. outputdir .. "/%{prj.name}")
pchheader "hzpch.h"
pchsource "Hazel/src/hzpch.cpp"
files{
"%{prj.name}/src/**.h",
"%{prj.name}/src/**.cpp",
"%{prj.name}/vendor/glm/glm/**.hpp",
"%{prj.name}/vendor/glm/glm/**.inl"
}
defines{
"_CRT_SECURE_NO_WARNINGS"
}
includedirs{
"%{prj.name}/src",
"%{prj.name}/vendor/spdlog/include",
"%{IncludeDir.GLFW}",
"%{IncludeDir.Glad}",
"%{IncludeDir.ImGui}",
"%{IncludeDir.glm}"
}
links{
"GLFW",
"Glad",
"ImGui",
"opengl32.lib"
}
filter "system:windows"
systemversion "latest"
defines{
"HZ_PLATFORM_WINDOWS",
"HZ_BUILD_DLL",
"GLFW_INCLUDE_NONE"
}
--postbuildcommands{
-- ("{COPY} %{cfg.buildtarget.relpath} \"../bin/".. outputdir .."/Sandbox/\"")
--}
filter "configurations:Debug"
defines "HZ_DEBUG"
runtime "Debug"
symbols "on"
filter "configurations:Release"
defines "HZ_RELEASE"
runtime "Release"
optimize "on"
filter "configurations:Dist"
defines "HZ_DIST"
runtime "Release"
optimize "on"
project "Sandbox"
location "Sandbox"
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",
}
includedirs{
"Hazel/vendor/spdlog/include",
"Hazel/src",
"Hazel/vendor",
"%{IncludeDir.glm}"
}
links {
"Hazel"
}
filter "system:windows"
systemversion "latest"
defines{
"HZ_PLATFORM_WINDOWS"
}
filter "configurations:Debug"
defines "HZ_DEBUG"
runtime "Debug"
symbols "on"
filter "configurations:Release"
defines "HZ_RELEASE"
runtime "Release"
optimize "on"
filter "configurations:Dist"
defines "HZ_DIST"
runtime "Release"
optimize "on"
premake5.lua of GLFW
project "GLFW"
kind "StaticLib"
language "C"
staticruntime "on"
targetdir ("bin/" .. outputdir .. "/%{prj.name}")
objdir ("bin-int/" .. outputdir .. "/%{prj.name}")
files
{
"include/GLFW/glfw3.h",
"include/GLFW/glfw3native.h",
"src/glfw_config.h",
"src/context.c",
"src/init.c",
"src/input.c",
"src/monitor.c",
"src/vulkan.c",
"src/window.c"
}
filter "system:windows"
systemversion "latest"
files
{
"src/win32_init.c",
"src/win32_joystick.c",
"src/win32_monitor.c",
"src/win32_time.c",
"src/win32_thread.c",
"src/win32_window.c",
"src/wgl_context.c",
"src/egl_context.c",
"src/osmesa_context.c"
}
defines
{
"_GLFW_WIN32",
"_CRT_SECURE_NO_WARNINGS"
}
filter "configurations:Debug"
runtime "Debug"
symbols "on"
filter "configurations:Release"
runtime "Release"
optimize "on"
premake5.lua of Glad
project "Glad"
kind "StaticLib"
language "C"
staticruntime "on"
targetdir ("bin/" .. outputdir .. "/%{prj.name}")
objdir ("bin-int/" .. outputdir .. "/%{prj.name}")
files
{
"include/glad/glad.h",
"include/KHR/khrplatform.h",
"src/glad.c"
}
includedirs{
"include"
}
filter "system:windows"
systemversion "latest"
filter "configurations:Debug"
runtime "Debug"
symbols "on"
filter "configurations:Release"
runtime "Release"
optimize "on"
premake5.lua of ImGui
project "ImGui"
kind "StaticLib"
language "C++"
cppdialect "C++17"
staticruntime "on"
targetdir ("bin/" .. outputdir .. "/%{prj.name}")
objdir ("bin-int/" .. outputdir .. "/%{prj.name}")
files
{
"imconfig.h",
"imgui.h",
"imgui.cpp",
"imgui_draw.cpp",
"imgui_internal.h",
"imgui_widgets.cpp",
"imstb_rectpack.h",
"imstb_textedit.h",
"imstb_truetype.h",
"imgui_demo.cpp"
}
filter "system:windows"
systemversion "latest"
filter "configurations:Debug"
runtime "Debug"
symbols "on"
filter "configurations:Release"
runtime "Release"
optimize "on"
Here is my Email address: [email protected] Thank you so much if anyone can help.
You could try and setting all of the premake5.lua files and change the staticruntime "on" to staticruntime "off" because in a later video we were forced to change all of the lua files in the Hazel repo to staticruntime "off" because of a single library that just wouldn't work for Cherno back then when it was staticruntime "on"
I can't find anything else without a repo to compare the code with... sorry.
Thank you so much. I'll try it.
---- Replied Message ---- | From | @.> | | Date | 05/11/2023 01:06 | | To | @.> | | Cc | @.>@.> | | Subject | Re: [TheCherno/Hazel] fatal error LNK1127: library is corrupt (Issue #623) |
You could try and setting all of the premake5.lua files and change the staticruntime "on" to staticruntime "off" because in a later video we are forced to change all of the lua files in the Hazel repo to staticruntime "off" because of a single library that just wouldn't work for Cherno back then when it was staticruntime "on" I can't find anything else without a repo to compare the code with... sorry.
— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.***>
buddy,are you fixed this problem?