Dev-C++ and linker errors

Started by
7 comments, last by GameDev.net 17 years, 7 months ago
I got a open-source library and it has about 7 header files. I extracted the folder which includes these files into Dev-Cpp\include\foo\. Now when I try to compile my program which includes all of these header files, it finds the actual files, but I get linker errors about having undefined references to namespace::class::function. I think it nags about every single function. Anyway, the library came with a .lib file, I'm guessing I have to do something with that. In the docs it says: This is only on Windows. Use this to link your applications to that are going to be using the foo.dll for developing applications against the api. See your Visual Studio 7.1 guide on linking against libs for using dll's for further information. As mentioned, I'm not using VS and I'm not really keen on changing to that either. I have always been using Dev-C++ and I have always relied on pre-built devpaks so I really have no clue about this. That being said, this might be an easy one for you. Thanks in advance for any help.
Advertisement
Sounds to me like the library should have a .dll file with it as well.

I'm at work at don't have VS to hand but if you go into Project Options -> Linker -> Additional Dependancies (I think, or something like that) there is an option you can browse from to add the .lib file to your project.

You'll also need the .dll file somewhere the exe can find it when it runs as well. This would be in the same directory as your exe, in Windows, in Windows/System32 or on the PATH somewhere.

[EDIT] Sorry - just realised you said you are not using VS. Someone else will have to advise how to add the .lib to your project with DevC++.
Ah yes, that's correct, it does have a .dll file too. I placed the .dll to the same dir where the exe would be, but that alone didn't help. I'm pretty positive something must be set in the linker/compiler options too. I'd appreciate if someone could point it out, thanks.

[Edited by - Marmis on September 20, 2006 8:14:29 AM]
You just need to add foo.lib to your project. The .dll isn't searched for until the exe is actually run but the .lib file is needed to tell the compiler that the functions are in a .dll and the name of the .dll and so on.

I've never used Dev C++ but surely there must be an Add To Project option or something like that? If not, if you can edit the command line that is sent to the linker, just add foo.lib to the end of this line (or wherever the linker you are using expects .lib file to be specified).
Yep, right click on the project name in the leftmost pane
-> Project Options
-> Parameters tab
-> Use the button below the right hand Linker pane to browse to the *.lib files

Thanks, I added the .lib for the linker, but unfortunately that didn't solve it. I'm still getting the same litany of linker errors.

Where exactly should both the .lib file and the .dll file be, or does it really matter? Currently they are both in the same dir as the exe would be.

If this is how it should work, are there any other possible reasons for the linker errors?
maybe you should add the folder with the libary and dll to your project

-> project options -> Files/directories / include files

the above might not be very corrct as my C++ is in dutch and I just translated it.
Sylvarant @www.gamedesign.be
a .lib file is a library built for visual
what you need is a .a file
in other words, you need a file that was compiled with dev-cpp and not visual

This topic is closed to new replies.

Advertisement