Re: [Dev-C++] Adding my own Lib files to Project
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
|
From: Elizabeth B. <sog...@ya...> - 2002-08-26 18:25:00
|
Look under: Project->Project Options->Files/Directories In that dialog there is a sub-tabbed thing, and the tabs are: Library Directories, Include Directories, Resource Files, Resource Directories If the libraries you need to link in to your application reside somewhere beside the normal place ([DEV-C++_HOME]/lib or the mingw-specific area) then you need to tell the linker about that directory else it won't know where to look. You add these directories using: Project->Project Options->Files/Directories->Library Directories These are *library* files and are not the same as include files. Include files just tell the compiler (and your code) certain function definitions (the signature of the function) and say to the compiler "look, I don't have this code *now* but later on, when this program is linked into an executable, somehow, someway, a function that matches the signature in the header file will be provided". So, anyway, after you compile your code using these header files (often times referred to as "include files"), it's time to link it all together. This is where the libraries come in - libraries provide the actual code itself (not 100% accurate in that DLL's are used, but the concept is the same: the library provides the implementation of the functions defined in the header/include files). > Are you saying that the name of the directory makes a difference ? > The *** in my mail stans for projects. If by *** you are implying > Dev-Cpp, then that is what I don't want to do. I would not like to > mix my files with those that came with the compiler. My full path is > C:\Projects\Lib. Do you mean I should change Lib to include and add > the path to where please explain. Right, you don't want to mix them with the standard header files; the C:\Projects\lib is probably just an example. Let's say I want to build a project entitled "terminal_library" so I make a special directory (or folder) entitled "terminal_library_project" mkdir terminal_library_project cd terminal_library_project I then hack away and build a DLL that resides within terminal_library_project: terminal_library_project: terminal_library_a.c terminal_library_a.h terminal_library_a.o terminal_library_b.c terminal_library_b.h terminal_library_b.o terminal_library.dll terminal_library.dll.a terminal_library.a terminal_library.def Anyway, that is done so then I go over to a different folder to work on the "terminal project" itself (which uses code in the terminal_library). cd .. mkdir terminal_project cd terminal_project In the source files of terminal_project are things like this: #include "terminal_library_a.h" The problem with just stating this is that during the compile, the compiler cannot automatically determine where to find "terminal_library_a.h". In order for it to find it, I need to tell the compiler where it is located, which is where: Project->Project Options->Files/Directories->Include Directories comes into play. I add "terminal_library_project" to this list of include directories and it compiles into object code fine *but* it fails to link with those nasty error messages you mentioned earlier. Why is this? Because in the same way that the compiler needed to know where to find the include files it also needs to know where to find the library files, so I add "terminal_library_project" to the Project->Project Options->Files/Directories->Library Directories And this tells the *linker* where to find the *libraries*. Elizabeth |