Change linker order in CodeBlocks

别等时光非礼了梦想. 提交于 2020-02-02 06:26:46

问题


I have a project in DialogBlocks 5.03 that compiles fine with mingw32, but using CodeBlocks 13.12 show this error:

F:\wxWidgets-3.0.0\lib\gcc_lib/libwxmsw30u_core.a(corelib_msw_listctrl.o):listctrl.cpp:(.text+0x1019): undefined reference to `ImageList_GetImageCount@4'
F:\wxWidgets-3.0.0\lib\gcc_lib/libwxmsw30u_core.a(corelib_msw_listctrl.o):listctrl.cpp:(.text+0x1063): undefined reference to `ImageList_Draw@24'
F:\wxWidgets-3.0.0\lib\gcc_lib/libwxmsw30u_core.a(corelib_msw_listctrl.o):listctrl.cpp:(.text+0x108c): undefined reference to `ImageList_GetIconSize@12'

I have detected that is the linker order of the libraries, in DialogBlocks this is the library order:

-Wl,--subsystem,windows -mwindows -static-libgcc -static-libstdc++ -lwxmsw30u_xrc -lwxmsw30u_richtext -lwxmsw30u_aui -lwxmsw30u_html -lwxmsw30u_stc -lwxmsw30u_propgrid -lwxmsw30u_ribbon -lwxmsw30u_adv -lwxmsw30u_core -lwxbase30u -lwxbase30u_net -lwxbase30u_xml -lwxtiff -lwxjpeg -lwxpng -lwxzlib -lwxregexu -lwxexpat -lkernel32 -luser32 -lgdi32 -lcomdlg32 -lwinspool -lwinmm -lshell32 -lcomctl32 -lole32 -loleaut32 -luuid -lrpcrt4 -ladvapi32 -lwsock32

And it compiles successfully

In CodeBlocks this is the compiler library order:

-mthreads -s -static-libgcc -static-libstdc++ -Wl,--subsystem,windows -lkernel32 -luser32 -lgdi32 -lwinspool -lcomdlg32 -ladvapi32 -lshell32 -lole32 -loleaut32 -luuid -lcomctl32 -lwsock32 -lodbc32 -lwxscintilla -lwxmsw30u_xrc -lwxmsw30u_richtext -lwxmsw30u_aui -lwxmsw30u_html -lwxmsw30u_stc -lwxmsw30u_propgrid -lwxmsw30u_ribbon -lwxmsw30u_adv -lwxmsw30u_core -lwxbase30u -lwxbase30u_net -lwxbase30u_xml -lwxtiff -lwxjpeg -lwxpng -lwxzlib -lwxregexu -lwxexpat -mwindows

If I compile the CodeBlocks project from command line using the DialogBlocks linker options, it compiles successfully

So in the CodeBlocks menu: Project -> Build Options -> Linker Settings, I add the libraries in the order that I want but CodeBlocks adds the parameters in its own order, even repeating the libraries

How I change the order?


回答1:


Thanks to Sandro I found the answer

I have CodeBlocks 13.12, to change the linker params you must go to the menu:

Settings -> Compiler -> Tab: Other settings -> Click button: Advanced options... -> It shows a message box warning, click: Yes -> In the Command ComboBox select: Link object files to execute, and change this:

$linker $libdirs -o $exe_output $link_objects $link_resobjects $link_options $libs -mwindows

to:

$linker $libdirs -o $exe_output $link_objects $link_resobjects $link_options

Click button: OK

Then go to menu:

Project -> Build options... -> Tab: Linker settings -> In: Other linker options, I added my own ordered libs



来源:https://stackoverflow.com/questions/22749643/change-linker-order-in-codeblocks

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!