I'm looking to use the Agui library for a game I am working on, but I have no clue how to use makefiles and the like, so I would really appreciate someone giving me specific instructions on how to install the library. I am using Windows with the MinGW compiler. Thanks in advance!
Agui forum post: https://www.allegro.cc/forums/thread/612830
Agui GitHub: https://github.com/jmasterx/Agui
Hi there
I'm unfortunately not familiar with using MinGW. I have built the library on Linux, and OSX with g++, but on Windows I use Visual Studio. In theory, Agui should compile fine with MinGW, but I have never used it. Maybe others can help you with that aspect.
The library is compiled with CMAKE build system like Allegro. CMAKE generates the make file for you.
So you will want to install cmake: http://www.cmake.org/download/ http://www.cmake.org/runningcmake/
Start it up and point it to the Agui source code directory and the output directory (./build or something).
Click configure and you will be asked to select a generator.
Select MinGW makefiles.
Click Finish.
Then, if you have MinGW correctly configured it should now present you with a red box with choices. The default choices should be correct.
Once the make files are generated, I suspect you run MinGW's make.
Hopefully others can correct / help from here since I have never used MinGW.
Once you get those made and linked I can help you with using the library.
]]>It's not too hard. You want to make a build directory and then run cmake from there :
cd agui mkdir build cd build cmake -G "MinGW Makefiles" -DSHARED=On -DCMAKE_BUILD_TYPE=Release .. mingw32-make install
]]>
First off, I just want to thank you for how much help you have already been. This has already been my best experience asking for help with a programming issue.
Anyway, I used the cmake gui application, told it to make MinGW Makefiles and "use default native compilers", and pressed the Configure and Generate buttons. But, when I use mingw32-make (without the "install" argument because it just refuses to do anything if I use that) it tells me that it can't find "CMakeFiles/agui.dir/src/Agui/Clipboard/WinClipboard.cpp.obj". On further examination I found that no object files seem to have been created, although the folders that should contain them have.
Am I missing something?
]]>Maybe try -DSHARED=off
Agui should probably not be used as a dll.
That's odd that the clipboard is not compiling.
]]>Yeah, I guess agui doesn't support the install target, but that's not too hard, just copy the include and lib folder contents to mingw\include and mingw\lib or set your include search path using -Ipath or linker search path using -Lpath.
And I guess it doesn't support shared either as when I built it with -DSHARED=On it still built static libraries with no dlls.
I don't know why it can't find the clipboard file.
]]>Making c++ libraries work correctly as a dll is tricky. If you do not do things right, the standard library runtime will cause problems.
I don't get this clipboard thing. I looked at the cmake file, everything looks fine...
]]>Making c++ libraries work correctly as a dll is tricky. If you do not do things right, the standard library runtime will cause problems.
MinGW generally does the right thing when you create a dll with g++. It's MSVC that needs all the declspec dllimport stuff. I haven't bothered with MSVC for building eagle yet because of that.
Edit
It's just the c runtime stuff that you need to be aware of with MinGW. If your library dynamically links to libstdc++ or libgcc then your program that uses that library needs to do so as well.
I made a platform file based on something I had found online at the time. It appeared that mingw needed a declspec of sorts. Maybe not anymore? https://github.com/jmasterx/Agui/blob/master/include/Agui/Platform.hpp
Which reminds me, if you're going to build agui as a dll you need to define AGUI_BUILD and AGUI_BACKEND_BUILD
If you set WANT_SHARED to yes, cmake will define these for you.
]]>CodeBlocks has an option to generate .DEF files for you, and then you don't need declspec(dllexport)
]]>Ok, I finally got mingw32-make to work (ended up downloading Agui from the forum post instead of from GitHub) and got the example to successfully compile, except now I am evidently still doing something wrong as the resulting program crashes before it really displays anything. Any suggestions? I feed I should mention I am using Code::Blocks to compile.
Edit: I may also want to mention that I didn't touch WANT_SHARED the first time through. When the example program didn't work, I tried it with WANT_SHARED checked, and MinGW's make only made three files and gave me an error I am guessing when it was making libagui_allegro5.dll (if that is in fact a file it is supposed to create).
]]>You should post code for a minimal example program that crashes for you so we can try it too. I built from 0.2 src if that helps. And example.exe crashes for me too, in AppendText("Warning") or some such IIRC. So I built from git, and there are now a boatload of warnings and the dynamic version of agui_allegro5 fails because it doesn't link to allegro.
]]>It will crash if you are missing the example data folder because you need a font.
Also, what sort of warning are you getting?
Also, the example will crash if the source is not from GitHub, but that's easy to get. The crash is related to me making a mistake in the example code not the library itself.
]]>Oh, so there is something wrong with the "agui_example.cpp" file? Here are the contents of it:
It compiles just fine, but crashes a few seconds after it starts up without showing anything. The way it crashes I would think that it wasn't finding the font file, but I have tried executing it with the font file in the same folder with no luck. I really want to make sure the library installed correctly and everything before bothering to really get in and learn how to use the library.
EDIT: Just found out by using cout where the program is crashing: it is crashing somewhere inside the addWidgets() function
EDIT2: Just looked at the function and it is only one line:
creator = new WidgetCreator(gui);
EDIT3: I found the line it is crashing on!
exTextBox.appendText("WARNING!!!\n\n");
Have no clue why but hopefully this will give you more to work off of.
]]>Hi
I just compiled the code you posted and it ran fine on my machine. Are you using latest git sources? If not this is probably the issue, I was thinking of an older issue with the example but I think the one you mention was fixed after. Otherwise, make sure in the exe directory you have the data folder found in the agui/example folder https://github.com/jmasterx/Agui/tree/master/example
I think this commit fixed it https://github.com/jmasterx/Agui/commit/ecafedbb310bb515e20eba2173cc0081b24e8f49
If with latest sources you still get a crash I'll need to install MinGW and try to reproduce it.
{"name":"609142","src":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/a\/8\/a8d40c1aabb69c55e92da703af275559.png","w":723,"h":563,"tn":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/a\/8\/a8d40c1aabb69c55e92da703af275559"}
]]>Hey, it's working now! I redownloaded it from the git and this time mingw32-make accepted it. Had to add a display flag to make it render in OpenGL because Allegro with Directx and my game recording software of choice, PlayClaw, do not agree (I thought something was still wrong at first because only the background was displaying), but at least now everything seems to be working correctly! Thank you so much for your help.
]]>There are a couple warnings during the build process for the static git version :
I compiled the example from git and there was one warning :
c:\mingw\LIBS\AGUI_github\Agui-master\example>mingw32-g++ -Wall -g -o example.exe agui_example_a5.cpp -I..\include -L..\build -lagui_allegro5 -lagui -lallegro_monolith-debug.dll agui_example_a5.cpp: In member function 'virtual void SimpleActionListener::actionPerformed(const agui::ActionEvent&)': agui_example_a5.cpp:96:12: warning: passing NULL to non-pointer argument 6 of 'int al_show_native_message_box(ALLEGRO_DISPLAY*, const char*, const char*, const char*, const char*, int)' [-Wconversion-null] NULL,NULL); ^ c:\mingw\LIBS\AGUI_github\Agui-master\example>
Other than the shared version, it builds for me fine now.
With -DWANT_SHARED=On I get a bunch of warnings and unresolved allegro functions. Attached is a text error log.
]]>Thanks a lot Edgar I'll look into this when I get a chance. MSVC does not warn as much as it should Perhaps I should set the mingw compiler for MSVC.
@Peter glad it is working for you If you have any questions related to using the library I'll be happy to help.
]]>Changing line 139 of CMakeLists.txt to this :
target_link_libraries (agui_allegro5 agui liballegro_monolith-debug.dll.a)
made it build the shared libraries.
I cannot compile the example program though, because of this :
I must be doing something wrong, because those functions all seem to appear in TextBox/ExtendedTextBox.hpp and .cpp. I linked to agui though, so I don't know why they're not found. I've deleted all the old versions of .a files I have, for the dlls too. And the only headers I link to are the git ones. I don't know what's wrong though. ExtendedTextBox.cpp is in the list of sources in CMakeLists.txt, so it should be included in the library. I've rebuilt several times now.
]]>Oopsies that's my bad. I forgot to export the class. I'll commit it in the next few days.
For now change in https://github.com/jmasterx/Agui/blob/master/include/Agui/Widgets/TextBox/ExtendedTextBox.hpp
class ExtendedTextBox : public TextBox
to
class AGUI_CORE_DECLSPEC ExtendedTextBox : public TextBox
]]>Yeah, that was it.
]]>