I don't know how to link libraries in Code::Blocks correctly. I've been trying to link the FLTK libraries for quite some time and have been getting the same undefined reference errors throughout. Long story short, I don't know how to link them correctly, or at least, I assume that is the problem.
I've placed all of my libraries and FLTK headers in C:\Code-Blocks\Libraries\lib and C:\Code-Blocks\Libraries\include, which currently consist of the lua libraries I haven't touched and FLTK of course. I opened my project (which currently consists of a "hello world") with Code::Blocks. This is my code:
#include <FL/Fl.H>
#include <FL/Fl_Window.H>
#include <FL/Fl_Box.H>
int main(int argc, char **argv)
{
Fl_Window *window = new Fl_Window(600,400);
window->end();
window->show(argc, argv);
return Fl::run();
}
As you can see, it's very simple. Now, these are my settings for the Compiler and debugger in Global Compiler Settings:
GNU CC Compiler
Nothing in compiler settings tab
Linker settings has every library dealing with FLTK included (by full path name):
libfltk_z.a
libfltk.a
libfltk_forms.a
libfltk_gl.a
libfltk_images.a
libfltk_jpeg.a
libfltk_png.a
all in the format of C:\Code-Blocks\Libraries\lib\[lib_name]
Search directories for compiler tab:
C:\MinGW\include
C:\Code-Blocks\Libraries\include
Search directories for linker tab:
C:\MinGW\lib
C:\Code-Blocks\Libraries\lib
Search directories for resource tab:
C:\MinGW\include
Toolchain executables has the default for program files for MinGW installed at C:\MinGW and nothing in additional paths
No custom variables
Other settings:
Compiler logging: task desc.
Number of parallel builds: 1
Max number of errors to log: 50
No checked options afterward
I'm using the July 21 Nightly build
Now, I keep getting tons of undefined reference errors.
The build messages are as follows:
C:\Code-Blocks\Libraries\lib\libfltk.a(Fl.o):Fl.cxx:(.text+0x279):: undefined reference to `DeleteObject@4'
C:\Code-Blocks\Libraries\lib\libfltk.a(Fl.o):Fl.cxx:(.text+0xc4d):: undefined reference to `CreateRectRgn@16'
C:\Code-Blocks\Libraries\lib\libfltk.a(Fl.o):Fl.cxx:(.text+0xc60):: undefined reference to `CombineRgn@16'
C:\Code-Blocks\Libraries\lib\libfltk.a(Fl.o):Fl.cxx:(.text+0xc66):: undefined reference to `DeleteObject@4'
C:\Code-Blocks\Libraries\lib\libfltk.a(Fl.o):Fl.cxx:(.text+0xc79):: undefined reference to `DeleteObject@4'
C:\Code-Blocks\Libraries\lib\libfltk.a(Fl.o):Fl.cxx:(.text+0xc8d):: undefined reference to `CreateRectRgn@16'
C:\Code-Blocks\Libraries\lib\libfltk.a(Fl.o):Fl.cxx:(.text+0xcfa):: undefined reference to `DeleteObject@4'
C:\Code-Blocks\Libraries\lib\libfltk.a(Fl.o):Fl.cxx:(.text+0x1209):: undefined reference to `select@20'
C:\Code-Blocks\Libraries\lib\libfltk.a(Fl.o):Fl.cxx:(.text+0x12b0):: undefined reference to `select@20'
C:\Code-Blocks\Libraries\lib\libfltk.a(Fl.o):Fl.cxx:(.text+0x12e1):: undefined reference to `__WSAFDIsSet@8'
C:\Code-Blocks\Libraries\lib\libfltk.a(Fl.o):Fl.cxx:(.text+0x12f6):: undefined reference to `__WSAFDIsSet@8'
C:\Code-Blocks\Libraries\lib\libfltk.a(Fl.o):Fl.cxx:(.text+0x130a):: undefined reference to `__WSAFDIsSet@8'
C:\Code-Blocks\Libraries\lib\libfltk.a(Fl.o):Fl.cxx:(.text+0x23b1):: undefined reference to `OleInitialize@4'
C:\Code-Blocks\Libraries\lib\libfltk.a(Fl.o):Fl.cxx:(.text+0x23c5):: undefined reference to `RegisterDragDrop@8'
C:\Code-Blocks\Libraries\lib\libfltk.a(Fl.o):Fl.cxx:(.text+0x2811):: undefined reference to `SaveDC@4'
C:\Code-Blocks\Libraries\lib\libfltk.a(Fl.o):Fl.cxx:(.text+0x2843):: undefined reference to `RestoreDC@8'
C:\Code-Blocks\Libraries\lib\libfltk.a(Fl.o):Fl.cxx:(.text+0x289a):: undefined reference to `OleUninitialize@0'
C:\Code-Blocks\Libraries\lib\libfltk.a(Fl.o):Fl.cxx:(.text+0x28d4):: undefined reference to `RestoreDC@8'
C:\Code-Blocks\Libraries\lib\libfltk.a(Fl.o):Fl.cxx:(.text+0x2961):: undefined reference to `SetTextAlign@8'
C:\Code-Blocks\Libraries\lib\libfltk.a(Fl.o):Fl.cxx:(.text+0x296e):: undefined reference to `SetBkMode@8'
C:\Code-Blocks\Libraries\lib\libfltk.a(Fl.o):Fl.cxx:(.text+0x2c5f):: undefined reference to `CreateRectRgn@16'
C:\Code-Blocks\Libraries\lib\libfltk.a(Fl.o):Fl.cxx:(.text+0x2c73):: undefined reference to `CreateRectRgn@16'
C:\Code-Blocks\Libraries\lib\libfltk.a(Fl.o):Fl.cxx:(.text+0x2cb2):: undefined reference to `CombineRgn@16'
C:\Code-Blocks\Libraries\lib\libfltk.a(Fl.o):Fl.cxx:(.text+0x2cb8):: undefined reference to `DeleteObject@4'
C:\Code-Blocks\Libraries\lib\libfltk.a(Fl.o):Fl.cxx:(.text+0x331e):: undefined reference to `UpdateColors@4'
C:\Code-Blocks\Libraries\lib\libfltk.a(Fl.o):Fl.cxx:(.text+0x353f):: undefined reference to `DeleteObject@4'
C:\Code-Blocks\Libraries\lib\libfltk.a(Fl.o):Fl.cxx:(.text+0x290):: undefined reference to `GdiFlush@0'
C:\Code-Blocks\Libraries\lib\libfltk.a(fl_dnd.o):fl_dnd.cxx:(.text+0x53):: undefined reference to `DoDragDrop@16'
C:\Code-Blocks\Libraries\lib\libfltk.a(fl_dnd.o):fl_dnd.cxx:(.text$_ZN12FLDropTarget14QueryInterfaceERK5_GUIDPPv+0x13):: undefined reference to `IID_IUnknown'
C:\Code-Blocks\Libraries\lib\libfltk.a(fl_dnd.o):fl_dnd.cxx:(.text$_ZN12FLDropTarget14QueryInterfaceERK5_GUIDPPv+0x27):: undefined reference to `IID_IDropTarget'
C:\Code-Blocks\Libraries\lib\libfltk.a(fl_dnd.o):fl_dnd.cxx:(.text$_ZN12FLDropTarget4DropEP11IDataObjectm8tagPOINTPm+0x208):: undefined reference to `ReleaseStgMedium@4'
C:\Code-Blocks\Libraries\lib\libfltk.a(fl_dnd.o):fl_dnd.cxx:(.text$_ZN12FLDropTarget9DragEnterEP11IDataObjectm8tagPOINTPm+0x205):: undefined reference to `ReleaseStgMedium@4'
C:\Code-Blocks\Libraries\lib\libfltk.a(fl_dnd.o):fl_dnd.cxx:(.text$_ZN12FLDropSource14QueryInterfaceERK5_GUIDPPv+0x13):: undefined reference to `IID_IUnknown'
C:\Code-Blocks\Libraries\lib\libfltk.a(fl_dnd.o):fl_dnd.cxx:(.text$_ZN12FLDropSource14QueryInterfaceERK5_GUIDPPv+0x27):: undefined reference to `IID_IDropSource'
C:\Code-Blocks\Libraries\lib\libfltk.a(fl_dnd.o):fl_dnd.cxx:(.text$_ZN12FLDataObject14QueryInterfaceERK5_GUIDPPv+0x13):: undefined reference to `IID_IUnknown'
C:\Code-Blocks\Libraries\lib\libfltk.a(fl_dnd.o):fl_dnd.cxx:(.text$_ZN12FLDataObject14QueryInterfaceERK5_GUIDPPv+0x27):: undefined reference to `IID_IDataObject'
C:\Code-Blocks\Libraries\lib\libfltk.a(fl_font.o):fl_font.cxx:(.text+0x61):: undefined reference to `CreateFontA@56'
C:\Code-Blocks\Libraries\lib\libfltk.a(fl_font.o):fl_font.cxx:(.text+0x83):: undefined reference to `SelectObject@8'
C:\Code-Blocks\Libraries\lib\libfltk.a(fl_font.o):fl_font.cxx:(.text+0x95):: undefined reference to `GetTextMetricsA@8'
C:\Code-Blocks\Libraries\lib\libfltk.a(fl_font.o):fl_font.cxx:(.text+0xab):: undefined reference to `GetCharWidthA@16'
C:\Code-Blocks\Libraries\lib\libfltk.a(fl_font.o):fl_font.cxx:(.text+0x12f):: undefined reference to `CreateFontA@56'
C:\Code-Blocks\Libraries\lib\libfltk.a(fl_font.o):fl_font.cxx:(.text+0x151):: undefined reference to `SelectObject@8'
C:\Code-Blocks\Libraries\lib\libfltk.a(fl_font.o):fl_font.cxx:(.text+0x163):: undefined reference to `GetTextMetricsA@8'
C:\Code-Blocks\Libraries\lib\libfltk.a(fl_font.o):fl_font.cxx:(.text+0x179):: undefined reference to `GetCharWidthA@16'
C:\Code-Blocks\Libraries\lib\libfltk.a(fl_font.o):fl_font.cxx:(.text+0x1b8):: undefined reference to `DeleteObject@4'
C:\Code-Blocks\Libraries\lib\libfltk.a(fl_font.o):fl_font.cxx:(.text+0x1da):: undefined reference to `DeleteObject@4'
C:\Code-Blocks\Libraries\lib\libfltk.a(fl_font.o):fl_font.cxx:(.text+0x312):: undefined reference to `SetTextColor@8'
C:\Code-Blocks\Libraries\lib\libfltk.a(fl_font.o):fl_font.cxx:(.text+0x32b):: undefined reference to `SelectObject@8'
C:\Code-Blocks\Libraries\lib\libfltk.a(fl_font.o):fl_font.cxx:(.text+0x342):: undefined reference to `TextOutA@20'
C:\Code-Blocks\Libraries\lib\libfltk.a(fl_font.o):fl_font.cxx:(.text+0x34e):: undefined reference to `SetTextColor@8'
:: More errors follow but not being shown.
:: Edit the max errors limit in compiler options...
:: === Build finished: 50 errors, 0 warnings ===
Any help would be greatly appreciated. I've been having this kind of trouble for quite some time now. I'm a beginner with C++ and it'd be nice if I could learn to link these libraries correctly. I've only just learned how to use MSYS and what a great tool it is. It got rid of my suspicion that because the libraries I had were compiled with a different compiler, MinGW might have a hard time referencing it.