gpt4 book ai didi

c - IUP - Windows SDK 静态链接

转载 作者:可可西里 更新时间:2023-11-01 11:46:52 26 4
gpt4 key购买 nike

我想用 C 编写一个多平台的本地桌面应用程序。经过一番搜索,我找到了 IUP完美契合。不幸的是,我正在努力链接 Windows SDK。现在,我只想为 Windows 8.1 静态编译 x64 版本。当我编译 this Code::Blocks 中的示例,我收到以下错误:

g++.exe -LC:\MinGW\iup -o "bin-debug\EVE Editor.exe" obj-debug\main.o   -lgdi32 -luser32 -lkernel32 -lcomctl32 -lole32 -lfreetype6 -liup -liup_mglplot -liup_plot -liup_scintilla -liupcd -liupcontrols -liupgl -liupglcontrols -liupim -liupimglib -liupmatrixex -liupole -liuptuio -lz
C:\MinGW\iup/libiup.a(iupwin_font.o):iupwin_font.c:(.text+0x1db): undefined reference to `__imp_CreateFontW'
C:\MinGW\iup/libiup.a(iupwin_font.o):iupwin_font.c:(.text+0x224): undefined reference to `__imp_SelectObject'
C:\MinGW\iup/libiup.a(iupwin_font.o):iupwin_font.c:(.text+0x240): undefined reference to `__imp_GetTextMetricsW'
C:\MinGW\iup/libiup.a(iupwin_font.o):iupwin_font.c:(.text+0x684): undefined reference to `__imp_SelectObject'
C:\MinGW\iup/libiup.a(iupwin_font.o):iupwin_font.c:(.text+0x734): undefined reference to `__imp_GetTextExtentPoint32W'

等等等等。 Here IUP 文档说“对于 Windows,如果您将应用程序与 IUP 静态链接,则还必须链接库 ole32.lib 和 comctl32.lib(随编译器提供)。”所以我从here获得了Windows SDK并用 ole32 和 comctl32 重新编译。我得到了同样的错误。我还在同一页上查看了 Code::Blocks 指南,但它是用于动态链接的。

我以前从未链接过 Windows SDK,所以我很茫然。这是我的 Code::Blocks 项目:

<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<CodeBlocks_project_file>
<FileVersion major="1" minor="6" />
<Project>
<Option title="EVE Editor" />
<Option pch_mode="2" />
<Option compiler="gcc" />
<Build>
<Target title="Debug">
<Option output="bin-debug/EVE Editor" prefix_auto="1" extension_auto="1" />
<Option object_output="obj-debug/" />
<Option type="1" />
<Option compiler="gcc" />
<Compiler>
<Add option="-g" />
</Compiler>
</Target>
<Target title="Release">
<Option output="bin/EVE Editor" prefix_auto="1" extension_auto="1" />
<Option object_output="obj/" />
<Option type="0" />
<Option compiler="gcc" />
<Compiler>
<Add option="-O2" />
</Compiler>
<Linker>
<Add option="-s" />
</Linker>
</Target>
</Build>
<Compiler>
<Add option="-Wall" />
<Add directory="C:/MinGW/iup/include" />
</Compiler>
<ResourceCompiler>
<Add directory="C:/MinGW/iup/etc" />
</ResourceCompiler>
<Linker>
<Add library="gdi32" />
<Add library="user32" />
<Add library="kernel32" />
<Add library="comctl32" />
<Add library="ole32" />
<Add library="libfreetype6.a" />
<Add library="libiup.a" />
<Add library="libiup_mglplot.a" />
<Add library="libiup_plot.a" />
<Add library="libiup_scintilla.a" />
<Add library="libiupcd.a" />
<Add library="libiupcontrols.a" />
<Add library="libiupgl.a" />
<Add library="libiupglcontrols.a" />
<Add library="libiupim.a" />
<Add library="libiupimglib.a" />
<Add library="libiupmatrixex.a" />
<Add library="libiupole.a" />
<Add library="libiuptuio.a" />
<Add library="libz.a" />
<Add directory="C:/MinGW/iup" />
</Linker>
<Unit filename="main.c">
<Option compilerVar="CC" />
</Unit>
<Extensions>
<code_completion />
<envvars />
<debugger />
<lib_finder disable_auto="1" />
</Extensions>
</Project>
</CodeBlocks_project_file>

最佳答案

尝试更改链接完成的顺序。依赖顺序必须颠倒,我的意思是最后依赖最少的库。例如:

        <Add library="libiupcontrols.a" />   -- optional
<Add library="libiupcd.a" /> -- optional
<Add library="libcd.a" /> -- optional
<Add library="libfreetype6.a" /> -- optional
<Add library="libz.a" /> -- optional
<Add library="libiup.a" />
<Add library="gdi32" />
<Add library="user32" />
<Add library="kernel32" />
<Add library="comctl32" />
<Add library="ole32" />

而且您不需要包含所有 IUP 库,只需包含您实际使用的库即可。

关于c - IUP - Windows SDK 静态链接,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42660587/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com