Author Topic: How do I compile a fltk application in CB?  (Read 7277 times)

fireblade

  • Guest
How do I compile a fltk application in CB?
« on: December 22, 2007, 01:36:49 am »
I added the include directory and the lib directory in the Settings/compiler/directories area.  I also had to add the libs by name in the Settings/compiler/linker section.  Without adding the libs by name, CB errored out earlier. However the compile still fails with the log information below:

Project   : Console application
Compiler  : GNU GCC Compiler (called directly)
Directory : C:\MinGW\1.0\fltk\sliderinput\
--------------------------------------------------------------------------------
Switching to target: default
Linking executable: sliderinput.exe
C:\MinGW\1.0\art\lib\libfltk2.a(run.o):run.cxx:(.text+0x42c): undefined reference to `WSAAsyncSelect@16'
C:\MinGW\1.0\art\lib\libfltk2.a(run.o):run.cxx:(.text+0x4f2): undefined reference to `WSAAsyncSelect@16'
C:\MinGW\1.0\art\lib\libfltk2.a(run.o):run.cxx:(.text+0x19de): undefined reference to `OleInitialize@4'
C:\MinGW\1.0\art\lib\libfltk2.a(run.o):run.cxx:(.text+0x1ba3): undefined reference to `RegisterDragDrop@8'
C:\MinGW\1.0\art\lib\libfltk2.a(run.o):run.cxx:(.text$_ZN12FlDropTarget14QueryInterfaceERK5_GUIDPPv+0x19): undefined reference to `IID_IUnknown'
C:\MinGW\1.0\art\lib\libfltk2.a(run.o):run.cxx:(.text$_ZN12FlDropTarget14QueryInterfaceERK5_GUIDPPv+0x2a): undefined reference to `IID_IDropTarget'
C:\MinGW\1.0\art\lib\libfltk2.a(run.o):run.cxx:(.text$_ZN12FlDropTarget4DropEP11IDataObjectm8tagPOINTPm+0x122): undefined reference to `ReleaseStgMedium@4'
C:\MinGW\1.0\art\lib\libfltk2.a(run.o):run.cxx:(.text$_ZN12FlDropTarget4DropEP11IDataObjectm8tagPOINTPm+0x2af): undefined reference to `ReleaseStgMedium@4'
C:\MinGW\1.0\art\lib\libfltk2.a(dnd.o):dnd.cxx:(.text+0x7a): undefined reference to `DoDragDrop@16'
C:\MinGW\1.0\art\lib\libfltk2.a(dnd.o):dnd.cxx:(.text$_ZN12FLDropSource14QueryInterfaceERK5_GUIDPPv+0x19): undefined reference to `IID_IUnknown'
C:\MinGW\1.0\art\lib\libfltk2.a(dnd.o):dnd.cxx:(.text$_ZN12FLDropSource14QueryInterfaceERK5_GUIDPPv+0x2a): undefined reference to `IID_IDropSource'
C:\MinGW\1.0\art\lib\libfltk2.a(dnd.o):dnd.cxx:(.text$_ZN12FLDataObject14QueryInterfaceERK5_GUIDPPv+0x19): undefined reference to `IID_IUnknown'
C:\MinGW\1.0\art\lib\libfltk2.a(dnd.o):dnd.cxx:(.text$_ZN12FLDataObject14QueryInterfaceERK5_GUIDPPv+0x2a): undefined reference to `IID_IDataObject'
collect2: ld returned 1 exit status
Process terminated with status 1 (0 minutes, 11 seconds)
0 errors, 0 warnings
 



Offline codeur

  • Multiple posting newcomer
  • *
  • Posts: 113
    • Code::Blocks EDU-Portable
Re: How do I compile a fltk application in CB?
« Reply #1 on: December 22, 2007, 08:24:28 am »
I have no experience with FLTK2 (I use version 1), but the linker error messages indicate that some library must be added to the list of libraries you have provided to the linker (the FLTK2 library calls some functions that are not found in the libraries you have listed).
This is not Code::Blocks related. Just search in the FLTK2 documentation what librairies are required to link a FLTK application and add the missing one to the linker list.

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9723
Re: How do I compile a fltk application in CB?
« Reply #2 on: December 22, 2007, 01:32:47 pm »
However the compile still fails with the log information below:
Search MSDN for the undefined reference. For e.g. WSAAsyncSelect it will tell you that you need to link against the Windsock library and so on...
With regards, Morten.
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

fireblade

  • Guest
Re: How do I compile a fltk application in CB?
« Reply #3 on: December 23, 2007, 02:25:40 am »
Thanks all.  I had to add the MinGW libraries to the compiler path.  Why do I have to add the libraries explicitly although I add the path in the directories/linker section of the compiler configuration???

Art

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9723
Re: How do I compile a fltk application in CB?
« Reply #4 on: December 23, 2007, 06:27:09 am »
Why do I have to add the libraries explicitly although I add the path in the directories/linker section of the compiler configuration???
Because that's how a linker works. A linker cannot automatically decide what library is required and the application needs to link against. There a several very good reasons for that. So you have to tell the linker what libraries you need with your application. You may be spoiled by the MS Dev Tool (aka Visual Studio) where you often don't need to setup the basic libraries. But in fact MS does that for you in a "nice" way: It just links against all most important libs. (Before you ask: No, we don't implement such stupidity.) If you use a MS wizard to create an application and choose some more features the list of libs grows.
But in fact: As soon as you use a 3rd party library even in MS you have to add this manually to your project's linker settings.
With regards, Morten.
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ