Author Topic: linker dependencies help!  (Read 15267 times)

Offline ztrain

  • Single posting newcomer
  • *
  • Posts: 3
linker dependencies help!
« on: January 21, 2010, 02:58:43 am »
ok, 1st off i am a new programmer (so this is probably a stupid question)... but in the c++ tutorials im watching to learn the language, they right click on their project, go to linker, then click on "additional dependencies" and type in winmm.lib (for time based stuff)... how would i do this in code::blocks??? i tried skipping this but im getting the following errors:

obj\Debug\game.o||In function `_ZN4game3runEv':|
 downloads\programing\c++\Monster Hunt\game.cpp|9|undefined reference to `_timeGetTime@0'|
||=== Build finished: 1 errors, 0 warnings ===|


and im not sure if its any help, but the tutorial is from 3d buzz, issue 3: game loop and its around 23 minutes.

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: linker dependencies help!
« Reply #1 on: January 21, 2010, 07:42:24 am »
You right click on your project then select "build options", then the linker tab and add this lib to the "link libraries". Notice that we also have a docuemtnation with further information / help here:
http://www.codeblocks.org/docs/main_codeblocks_en.html

Generally: Hopefully you know what you are doing. It's way easier to setup a project if you understand the meaning / function of a compiler and linker.
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

Offline ztrain

  • Single posting newcomer
  • *
  • Posts: 3
Re: linker dependencies help!
« Reply #2 on: January 21, 2010, 12:51:00 pm »
hi, i already tried that, all i get is an error saying that it cannot find -lwinmm.lib

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: linker dependencies help!
« Reply #3 on: January 21, 2010, 01:01:14 pm »
hi, i already tried that, all i get is an error saying that it cannot find -lwinmm.lib
That's why I've posted this:
It's way easier to setup a project if you understand the meaning / function of a compiler and linker.
"-l" is a linker option, so do *not* use it there, just add "winmm.lib".
PLEASE: Make yourself familiar with the compiler / linker you are using. Before using an(y) IDE, compile at the command line so that you know how the basics work. Otherwise you will continuously run into trouble like that. In addition we do not provide support on "What do I need to setup for my compiler/linker". This is beyond the scope of the C::B forum.
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

Offline ztrain

  • Single posting newcomer
  • *
  • Posts: 3
Re: linker dependencies help!
« Reply #4 on: January 21, 2010, 10:10:53 pm »
sorry for wasting your time, by the way, i was not using the -l in the linker, that was the error my compiler gave me, no need to reply to this, because chances are i wont see your answer... ill take all my questions to a general c++ forum and hope someone else knows what im talking about....


edit: for anyone else who needs help with this, here is he extension to the file:
C:\Program Files (x86)\CodeBlocks\MinGW\lib\libwinmm.a

all stranded library are lib<libraryname>.a
« Last Edit: January 21, 2010, 10:39:18 pm by ztrain »

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: linker dependencies help!
« Reply #5 on: January 22, 2010, 12:23:03 pm »
gcc's -l option require the name of the lib to be stripped...

example: libwinmm.a -> the correct option is -lwinmm, so you put winmm in the configuration dialog.

If you've read the gcc docs about it you would have found that.
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]