Re: Linker problems in MinGW
Those functions are defined in Gdi32.lib, you have to link to that.
DrawText is defined in User32.lib, which would explain why that function works for you.
Whenever you have a linker problem with a specific function, look it up in the MSDN. At the bottom of the page, all of the requirements necessary to use the function are listed, including what library you need to link to.
Kelly
Re: Linker problems in MinGW
Thank you. I downloaded Gdi32.lib and placed it in my lib folder. However, I get the same linking error, so the file wasn't found by the linker.
Next I tried playing with options for the linker, trying to include the file, and had no luck. So how do I make ld.exe see my file?
Code:
c++ -Xlinker -L C:/MinGW/lib test.cpp
C:\MinGW\bin\..\lib\gcc\mingw32\3.4.5\..\..\..\..\mingw32\bin\ld.exe: cannot open output file -Xlinker -L C:/MinGW/lib test.exe: Invalid argument
collect2: ld returned 1 exit status
Re: Linker problems in MinGW
I've never used MinGW, so I don't know how to specify which libraries to link to. I'm not sure what you mean by "downloaded Gdi32.lib." If you're going to be writing windows programs, you should download and install the Windows SDK, which will have all of the libraries you should need.
Kelly
Re: Linker problems in MinGW
Yes, I downloaded the SDK. I tried to specify the libraries to include but the linker failed to locate them. I tried using forward and backward slashes, different directory combinations, is there anything else you might be able to suggest? Or does someone know how to properly inlcude libraries in MinGW?
Re: Linker problems in MinGW
I found out how to fix my problem. MinGW already has required libraries (libgdi32.a) and the compiler automatically includes them when the switch '-mwindows' is used.
Re: Linker problems in MinGW
May be a bit late reply, but specify a library to be linked, especially the one your require
-lgdi32
it will automaticaly link libgdi32.a.
I hope it helps to next readers,
regards
Re: Linker problems in MinGW
I tried that so many times, only I typed -libgdi32 or -libgdi32.a, I can't believe I was so close. Oh well, the other way links everything for you, so I think I like that one better :)
Thank you, I probably would have never got that, and likely had other problems with libraries in the future that I can't solve without that.
Re: Linker problems in MinGW
One more thing, you might need in future.
Some library file for example libabc.a, and it is in the folder that contaions your code and is not in library folder. you will supply just the name of the file in linker tab without any -l option
just abc.a
Am glad it helped.
regards