C++ GUI Tutorial: undefined reference to TextOut - c++

So after a bit of searching for Win32 GUI tutorials (I decided a tutorial on making GUIs might make me more active in making C++ applications and therefore stronger at programming in C++ in general,) I came across a rohitab tutorial. There are two parts that I have been able to find. Part 1 worked fine, and I'm now working on Part 2, however, I'm getting this error in Code::Blocks:
C:\Users\John\Documents\Windows GUIs\first_gui.cpp||In function 'C:\Users\John\Documents\Windows GUIs\first_gui.o:first_gui.cpp:(.text+0x281)||undefined reference to '_TextOutA#20'|
My code can be found here (broken link).
I would greatly appreciate any help.

Did you link your app against GDI32.LIB?

Looks like a linker error, are you linking to gdi32.lib?

You should download a WINDOWS SDK package, this include all libraries that you will need to create programs with GDI (including gdi32);
Then in codeblocks/compiler/linkersettings choose folder where SDK's lib files are stored.
That's is it!!.

Related

How to create a portable executable with allegro 4.4.2

So I am creating a C++ program using the allegro version 4.4.2 library and I need to be able to produce an executable package which I can submit to a course instructor and have run on his computer without issues. I am developing the program using DevC++. If I am understanding this correctly so far, I need to link to a static library for allegro and then the executable should include the library info and thus the library itself is not necessary to have included in the executable package. I have also seen some recommendations regarding third party tools that produce executable packages, but these seem to be more general (not necessarily allegro compatible?) and I am hoping to avoid downloading more third party software.
I have tried linking to the static library liballegro-4.4.2-monolith-static-mt.a but for some reason when I do this I get a whole slew of undefined reference compile time errors. I have read that it is necessary to have #define ALLEGRO_STATICLINK included in the project, I have this statement at the top of my main source file but I am not sure if I am meant to define this somewhere in the project options instead?
Any guidance or link to resources which will help me solve my problem would be extremely appreciated! I am just getting into the meat of programming with C++ beginning to learn object oriented programming methods, I still occasionally struggle with the basics so thank you in advance for your help!
Backstory (if interested/relevant?): I am taking a Game AI programming course for which we need to create some example programs to demonstrate AI algorithms. The course specifies Java but I am most familiar with C++ and the course instructor says this is fine but I must be able to submit an executable to him which he can just run on his computer without issues. To best achieve what the course asks I feel the allegro library (which I already have installed) will be of great help, mostly for drawing graphics to the screen and such.
So I just ended up using a dynamically linked version of my program and including the appropriate .dll files which turned out to be a lot less work than I thought it would be.
Basically I just had to ensure the allegro-4.4.2-md.dll from the bin folder was included in the folder with the executable. I then sent off the package (the .exe compiled file and the needed supporting files such as bitmaps sound files etc) to a few friends and had them try to run it. They then gave me the warnings from their computers along the lines of "Test.exe cannot be run ****.dll cannot be found".
I searched the exact names of the dll files they were receiving warnings for in the folder with my game and voila it now seems to execute on whatever PC it is sent to.

Using a UWP library in a C++ console app

I understand that this isn't a really common use case, but my team has built a C++ UWP static library and I'd like to link it into an existing C++ console app. However, I can't find anywhere that says that this is possible, or even anyone that's asked this question. If I try naively adding a reference, it just says that "the two platforms are incompatible" (I'd imagine one is targeting UWP and the other just targets Windows).
Does anyone know if this is possible? Would save me a pretty big rewrite.
Thanks!
If your library is not portable is not possible.
If you have access code to the code of the UWP library try to port al the code to portable library and try it again.
Best Regards

Can't configure OpenCV with Qt properly?

I'm trying to configure OpenCV (3.1) with Qt Creator on Windows 32 and 64 bit for a long time to create a GUI application but I just can't seem to solve this configuration part. I've tried and read a lot of tutorials there are on the internet (https://zahidhasan.wordpress.com/2014/08/19/qt-5-3-1-64-bit-mingw-windows/ for example) but with no success.
When I try to run my program, I'm getting these errors:
enter image description here
To use a library, you have to reference its headers (and that is what you have done correctly with your #include directives).
But you also have to point the linker to the location and names of libraries to link. That is currently missing in your configuration, because you get undefined reference errors from linker.
Hard to tell anything more without knowing more details on your setup so far.
Depending on your environment and the build of OpenCV you need, you need to configure your project to use static libraries or DLLs (I assume we speak about Windows here).
As you use imread(), you will surely need the opencv_highgui*.* library, but this will surely not suffice.
See e.g. this OpenCV documentation for a complete list of OpenCV libraries.

How to make your own SDK from code files?

I have programmed a game with lots of C++ code and it started to take more time then ever to compile my code.
So I thought maybe I can split the game's rendering code as it's own binary SDK.
I have used many SDKs and APIs before, But I don't know how to make my own SDK and how does it all hold up together.
Does any one know a good online tutorial or book about how to make a SDK. thanks.
You need to read about creating libraries. You then compile your game's rendering code as it's own library file.
Here is an example of how do create and use a static library using Visual C++ : http://msdn.microsoft.com/en-us/library/ms235627.aspx
PS: As for increasing compilation times, consider using pre-compiled headers on your platform.

cross compiling c++ to iphone arm

I've scanned over the (outdated) article that is the first hit on google about ARM cross-compiling. I've also seen the article about compiling OpenCV to the iPhone and the general cross compiling instructions there. My question is can I call the apparently already configured gcc/g++ in the iPhone developer package (which I already have installed) like in the latter article? A lot of the OpenCV stuff seems superfluous to my needs.
If I can, what would the calls look like? Should I create a Makefile to make things easier?
Also, I need -lncurses library. Can I call them like normal, or do I need to specify it's path because I'm not calling the default gcc/g++?
If you're using the official SDK, compiling C++ for the iPhone is as simple as including cpp files in your project and hitting "build". Of course you can still go in and tweak the compiler switches - well, most of them.
As for ncurses, I'm not sure why you'd want to use that - but the only limitation you should have is that you can't link against dynamic libraries - so you'd have to linked the object code in.
A script that you can use as a basis for crosscompiling your libraries for iOs development.
Unfortunately the [n]curses package is not going to do you any good for the iPhone.
[n]curses is designed to be used with a terminal window. This is just not available for the iPhone you will need to learn how to use Coco to develop a GUI interface.