linking libraries
Posted: Tue Mar 16, 2010 9:30 pm
Hello,
I am starting to use CodeLite and have apparently not the many experience in using IDEs, though I never had this sort of problems with visual studio. I included windows.h and the compiler not complained anything, but apparently the linker complained not to have found the reference to a function, that is:
./Debug/main.o: In function `WinMain@16':
C:/Users/Ilker/C++/Ilkers C++ Programme/Windows Programmierung/main.cpp:39: undefined reference to `GetStockObject@4'
I used the conveniencies of CodeLite and found out that this function is declared in wingdi.h, that is included with windows.h already. So I think that the according library was not found or searched for. You will know that the header apparently is found in "include" in the mingw directory, but apparrently it is not possible to find the appropriate library in the lib directory of mingw. So, apparently I did not understand all of regarding the including mechanism, at all, because I am very surprised on this situation, so I ask you:
1. Why is the (standard?) path to some headerfiles is well known to the compiler (linker?), but not the path to the corresponding libraries?? I thought with the delivery of headerfiles the corresponding libraries are also supported and their paths are set in the IDE.
2. How do I find out which library-name belongs to xxx.h? Is it xxx.lib or libxxx.a or something else? I found a libgdi32.a in the lib directory, is that the library to wingdi.h?, and if it is so, why does the linker not find it automatically? And is it possible to impose other name conventions for headerfiles and their libraries?
3. If I have to link the library manually, I din't find out yet, how to set paths for the linker for searching for those libraries.
thank you
I am starting to use CodeLite and have apparently not the many experience in using IDEs, though I never had this sort of problems with visual studio. I included windows.h and the compiler not complained anything, but apparently the linker complained not to have found the reference to a function, that is:
./Debug/main.o: In function `WinMain@16':
C:/Users/Ilker/C++/Ilkers C++ Programme/Windows Programmierung/main.cpp:39: undefined reference to `GetStockObject@4'
I used the conveniencies of CodeLite and found out that this function is declared in wingdi.h, that is included with windows.h already. So I think that the according library was not found or searched for. You will know that the header apparently is found in "include" in the mingw directory, but apparrently it is not possible to find the appropriate library in the lib directory of mingw. So, apparently I did not understand all of regarding the including mechanism, at all, because I am very surprised on this situation, so I ask you:
1. Why is the (standard?) path to some headerfiles is well known to the compiler (linker?), but not the path to the corresponding libraries?? I thought with the delivery of headerfiles the corresponding libraries are also supported and their paths are set in the IDE.
2. How do I find out which library-name belongs to xxx.h? Is it xxx.lib or libxxx.a or something else? I found a libgdi32.a in the lib directory, is that the library to wingdi.h?, and if it is so, why does the linker not find it automatically? And is it possible to impose other name conventions for headerfiles and their libraries?
3. If I have to link the library manually, I din't find out yet, how to set paths for the linker for searching for those libraries.
thank you