Code::Blocks

User forums => Help => Topic started by: ztrain on January 21, 2010, 02:58:43 am

Title: linker dependencies help!
Post by: ztrain 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 `[email protected]'|
||=== 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.
Title: Re: linker dependencies help!
Post by: MortenMacFly 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.
Title: Re: linker dependencies help!
Post by: ztrain 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
Title: Re: linker dependencies help!
Post by: MortenMacFly 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.
Title: Re: linker dependencies help!
Post by: ztrain 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
Title: Re: linker dependencies help!
Post by: oBFusCATed 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.