User forums > Using Code::Blocks

Trouble compiling/linking

(1/4) > >>

Svalorzen:
Good morning everyone, I'm having some trouble getting the compilation for a particular project to work on Code::Blocks.

I recently discovered the FLTK library for GUI on Windows, and after setting it up I opened a test project to try and make it work. Unfortunately when I try to compile it I get 19 linker errors:

--- Code: ---g++.exe -LC:\Users\Svalorzen\Documents\Projects\fltk-1.3.0\lib  -o bin\Debug\test.exe obj\Debug\main.o   -mwindows -lole32 -luuid -lcomctl32  C:\Users\Svalorzen\Documents\Projects\fltk-1.3.0\lib\libfltk.a
C:\Users\Svalorzen\Documents\Projects\fltk-1.3.0\lib\libfltk.a(Fl.o):Fl.cxx:(.text+0x2bb): undefined reference to `OleUninitialize@0'
C:\Users\Svalorzen\Documents\Projects\fltk-1.3.0\lib\libfltk.a(Fl.o):Fl.cxx:(.text+0x738): undefined reference to `OleInitialize@4'
...

--- End code ---

However if I compile the project from command prompt ( or even Msys ), with this script


--- Quote ---g++ -I..\fltk-1.3.0\ -mwindows -DWIN32 -DUSE_OPENGL32 -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -o 'main' main.cpp -mwindows ..\fltk-1.3.0\lib\libfltk.a -lole32 -luuid -lcomctl32
--- End quote ---

it compiles correctly. I've attached an image with the settings of my Code::Blocks, what exactly am I doing wrong?

Thanks in advance!

stahta01:
In linking the order matters.
You put the libraries in a different order.
The libfltk.a is at the end of the command that fails to work and close to the beginning of the one that works.

Tim S.

Svalorzen:
Thanks! Unfortunately, I did not write the line that does not work. That would be Code::Blocks. I just setup the include/linking variables.

How can I change the order of the libraries?

stahta01:

--- Quote from: Svalorzen on May 10, 2012, 01:17:40 pm ---Thanks! Unfortunately, I did not write the line that does not work. That would be Code::Blocks. I just setup the include/linking variables.

How can I change the order of the libraries?

--- End quote ---

You put the libraries in Code::Blocks; that picked the order.
Re-order the libraries in Code::Blocks.

The box called "Link Libraries" should have all the libraries in it.
Order them the correct way.

Select one of the library and the up/down arrows should appear.

Tim S.

Svalorzen:
Is it the only way? Mostly because I'm not sure what libraries are those, I just pasted a script.. also it does not sound incredibly efficient.

If it is I'll do it though.

Navigation

[0] Message Index

[#] Next page

Go to full version