问题描述
所以我设法通过仅包含依赖项目录而不链接任何内容来动态链接 FreeType2。动态很酷,但我真的很想静态链接它。我测试了预编译的二进制文件(我从中获得了 dll)并构建了我自己的(我通过下载完成的,使用 cmake gui 使用默认选项构建 .sln 工作区,然后单击全部构建)。 但是无论我尝试静态链接或使用什么,它都会给我未定义的引用。
输出如下:
MAKEFLAGS=s -j9
COMPILER_PATH=c:/progra~1/mingw64/bin/../libexec/gcc/x86_64-w64-mingw32/10.2.0/;c:/progra~1/mingw64/bin/../libexec/gcc/;c:/progra~1/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../x86_64-w64-mingw32/bin/
LIBRARY_PATH=c:/progra~1/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/;c:/progra~1/mingw64/bin/../lib/gcc/;c:/progra~1/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../x86_64-w64-mingw32/lib/../lib/;c:/progra~1/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../lib/;c:/progra~1/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../x86_64-w64-mingw32/lib/;c:/progra~1/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../
COLLECT_GCC_OPTIONS='-g' '-v' '-o' 'UI.exe' '-shared-libgcc' '-mtune=generic' '-march=x86-64'
c:/progra~1/mingw64/bin/../libexec/gcc/x86_64-w64-mingw32/10.2.0/collect2.exe -plugin c:/progra~1/mingw64/bin/../libexec/gcc/x86_64-w64-mingw32/10.2.0/liblto_plugin-0.dll -plugin-opt=c:/progra~1/mingw64/bin/../libexec/gcc/x86_64-w64-mingw32/10.2.0/lto-wrapper.exe -plugin-opt=-fresolution=C:\Users\Eric\AppData\Local\Temp\ccoaWDLZ.res -plugin-opt=-pass-through=-lmingw32 -plugin-opt=-pass-through=-lgcc_s -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lmoldname -plugin-opt=-pass-through=-lmingwex -plugin-opt=-pass-through=-lmsvcrt -plugin-opt=-pass-through=-lpthread -plugin-opt=-pass-through=-ladvapi32 -plugin-opt=-pass-through=-lshell32 -plugin-opt=-pass-through=-luser32 -plugin-opt=-pass-through=-lkernel32 -plugin-opt=-pass-through=-lmingw32 -plugin-opt=-pass-through=-lgcc_s -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lmoldname -plugin-opt=-pass-through=-lmingwex -plugin-opt=-pass-through=-lmsvcrt -m i386pep -Bdynamic -o UI.exe c:/progra~1/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../x86_64-w64-mingw32/lib/../lib/crt2.o c:/progra~1/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/crtbegin.o -Lc:/progra~1/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0 -Lc:/progra~1/mingw64/bin/../lib/gcc -Lc:/progra~1/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../x86_64-w64-mingw32/lib/../lib -Lc:/progra~1/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../lib -Lc:/progra~1/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../x86_64-w64-mingw32/lib -Lc:/progra~1/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../.. @C:\Users\Eric\AppData\Local\Temp\ccmOOCrP -lmingw32 -lgcc_s -lgcc -lmoldname -lmingwex -lmsvcrt -lpthread -ladvapi32 -lshell32 -luser32 -lkernel32 -lmingw32 -lgcc_s -lgcc -lmoldname -lmingwex -lmsvcrt c:/progra~1/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/crtend.o
Warning: corrupt .drectve at end of def file
Warning: corrupt .drectve at end of def file
Warning: corrupt .drectve at end of def file
Warning: corrupt .drectve at end of def file
c:/progra~1/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: ../Dependencies/FreeType/freetype.lib(../../../objs/x64/Release Static/bdf.obj):(.xdata[$unwind$_bdf_parse_properties]+0x18): undefined reference to `__GSHandlerCheck'
c:/progra~1/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe:
-This repeats for a while-
../Dependencies/FreeType/freetype.lib(../../../objs/x64/Release Static/bdf.obj):(.xdata[$unwind$_bdf_parse_start]+0x1c): undefined reference to `__GSHandlerCheck'
c:/progra~1/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: ../Dependencies/FreeType/freetype.lib(../../../objs/x64/Release Static/bdf.obj):(.xdata[$unwind$bdf_interpret_style]+0x1c): undefined reference to `__GSHandlerCheck'
c:/progra~1/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: ../Dependencies/FreeType/freetype.lib(../../../objs/x64/Release Static/bdf.obj):(.xdata[$unwind$BDF_Face_Init]+0x14): undefined reference to `__GSHandlerCheck'
collect2.exe: error: ld returned 1 exit status
mingw32-make[3]: *** [CMakeFiles\UI.dir\build.make:269: UI.exe] Error 1
mingw32-make[2]: *** [CMakeFiles\Makefile2:94: CMakeFiles/UI.dir/all] Error 2
mingw32-make[1]: *** [CMakeFiles\Makefile2:101: CMakeFiles/UI.dir/rule] Error 2
mingw32-make: *** [makefile:136: UI] Error 2
这是我的 cmake 文件:
make_minimum_required(VERSION 3.7)
project(UI)
set(GLFW_BUILD_DOCS OFF CACHE BOOL "" FORCE)
set(GLFW_BUILD_TESTS OFF CACHE BOOL "" FORCE)
set(GLFW_BUILD_EXAMPLES OFF CACHE BOOL "" FORCE)
set(FREETYPE_LIBRARIES ${CMAKE_CURRENT_LIST_DIR}/Dependencies/FreeType/freetype.lib)
set(FREETYPE_INCLUDE_Dirs ${CMAKE_CURRENT_LIST_DIR}/Dependencies/FreeType/include)
set(CMAKE_CXX_STANDARD 20)
file(GLOB_RECURSE SOURCE_FILES "UI/*.cpp" "UI/*.h" "SandBox/*.cpp" "SandBox/*.h")
file(GLOB_RECURSE DEP_FILES "Dependencies/FreeType/src/*.c" "Dependencies/FreeType/src/*.h")
set(dir ${CMAKE_CURRENT_SOURCE_DIR})
include_directories(Dependencies)
include_directories(${PROJECT_NAME} "Dependencies/OpenGL/include")
include_directories(${PROJECT_NAME} "Dependencies/Math/include")
include_directories(${PROJECT_NAME} "Dependencies/GLFW/include")
include_directories(${PROJECT_NAME} "Dependencies/FreeType/include")
include_directories(${PROJECT_NAME})
add_executable(${PROJECT_NAME} ${SOURCE_FILES})
target_link_libraries(${PROJECT_NAME}
${CMAKE_CURRENT_LIST_DIR}/Dependencies/FreeType/freetype.lib
${CMAKE_CURRENT_LIST_DIR}/Dependencies/OpenGL/OpenGL.a
${CMAKE_CURRENT_LIST_DIR}/Dependencies/Math/Math.a
${CMAKE_CURRENT_LIST_DIR}/Dependencies/GLFW/libglfw3.a
)
如果有人有任何想法,欢迎帮助我:) 祝您有美好的一天。
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)