Allegro.cc - Online Community

Allegro.cc Forums » Programming Questions » Help needed installing agui library

Credits go to Edgar Reynaldo and jmasterx for helping out!
This thread is locked; no one can reply to it. rss feed Print
Help needed installing agui library
Peter Gill
Member #15,850
January 2015

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

jmasterx
Member #11,410
October 2009

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.

Edgar Reynaldo
Member #8,592
May 2007
avatar

Peter Gill
Member #15,850
January 2015

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?

jmasterx
Member #11,410
October 2009

Maybe try -DSHARED=off

Agui should probably not be used as a dll.

That's odd that the clipboard is not compiling.

Edgar Reynaldo
Member #8,592
May 2007
avatar

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.

jmasterx
Member #11,410
October 2009

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...

Edgar Reynaldo
Member #8,592
May 2007
avatar

jmasterx said:

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.

jmasterx
Member #11,410
October 2009

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.

Edgar Reynaldo
Member #8,592
May 2007
avatar

Peter Gill
Member #15,850
January 2015

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).

Edgar Reynaldo
Member #8,592
May 2007
avatar

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.

jmasterx
Member #11,410
October 2009

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.

Peter Gill
Member #15,850
January 2015

Oh, so there is something wrong with the "agui_example.cpp" file? Here are the contents of it:

#SelectExpand
1/* _____ 2 * /\ _ \ __ 3 * \ \ _\ \ __ __ __ /_\ 4 * \ \ __ \ /'_ `\ /\ /\ \/\ \ 5 * \ \ /\ \ /\ _\ \\ \ _\ \\ \ \ 6 * \ _\ _\\ ____ \\ ____/ \ _\ 7 * /_//_/ /____\ \/___/ /_/ 8 * /____/ 9 * _/__/ 10 * 11 * Copyright (c) 2011 Joshua Larouche 12 * 13 * 14 * License: (BSD) 15 * Redistribution and use in source and binary forms, with or without 16 * modification, are permitted provided that the following conditions 17 * are met: 18 * 1. Redistributions of source code must retain the above copyright 19 * notice, this list of conditions and the following disclaimer. 20 * 2. Redistributions in binary form must reproduce the above copyright 21 * notice, this list of conditions and the following disclaimer in 22 * the documentation and/or other materials provided with the 23 * distribution. 24 * 3. Neither the name of Agui nor the names of its contributors may 25 * be used to endorse or promote products derived from this software 26 * without specific prior written permission. 27 * 28 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 29 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 30 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 31 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 32 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 33 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 34 * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 35 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 36 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 37 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 38 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 39 */ 40 41#include <Agui/Agui.hpp> 42#include <Agui/Backends/Allegro5/Allegro5.hpp> 43 44#include <Agui/Widgets/Button/Button.hpp> 45#include <Agui/Widgets/CheckBox/CheckBox.hpp> 46#include <Agui/Widgets/DropDown/DropDown.hpp> 47#include <Agui/Widgets/TextField/TextField.hpp> 48#include <Agui/Widgets/Frame/Frame.hpp> 49#include <Agui/Widgets/RadioButton/RadioButton.hpp> 50#include <Agui/Widgets/RadioButton/RadioButtonGroup.hpp> 51#include <Agui/Widgets/Slider/Slider.hpp> 52#include <Agui/Widgets/TextBox/ExtendedTextBox.hpp> 53#include <Agui/Widgets/Tab/TabbedPane.hpp> 54#include <Agui/Widgets/ListBox/ListBox.hpp> 55#include <Agui/Widgets/ScrollPane/ScrollPane.hpp> 56#include <Agui/FlowLayout.hpp> 57 58#include <allegro5/allegro_native_dialog.h> 59#include <stdlib.h> 60#include <vector> 61#include <ctime> 62#include <iostream> 63 64 65#define FRAME_RATE 60 66 67//Globals 68ALLEGRO_DISPLAY *display = NULL; 69ALLEGRO_TIMER *timer = NULL; 70ALLEGRO_EVENT event; 71ALLEGRO_EVENT_QUEUE *queue = NULL; 72bool done = false; 73agui::Gui *gui = NULL; 74agui::Allegro5Input* inputHandler = NULL; 75agui::Allegro5Graphics* graphicsHandler = NULL; 76 77agui::Font *defaultFont = NULL; 78 79 80class SimpleActionListener : public agui::ActionListener 81{ 82public: 83 virtual void actionPerformed(const agui::ActionEvent &evt) 84 { 85 agui::Slider* slider = dynamic_cast<agui::Slider*>(evt.getSource()); 86 if(slider) 87 { 88 slider->setBackColor(agui::Color(slider->getValue(),slider->getValue(),slider->getValue())); 89 return; 90 91 } 92 al_show_native_message_box(al_get_current_display(), 93 "Agui Action Listener", 94 "", 95 "An Action Event has occured!", 96 NULL,NULL); 97 } 98}; 99 100 101 102class WidgetCreator { 103private: 104 SimpleActionListener simpleAL; 105 agui::FlowLayout flow; 106 agui::Button button; 107 agui::CheckBox checkBox; 108 agui::DropDown dropDown; 109 agui::TextField textField; 110 agui::Frame frame; 111 agui::Gui* mGui; 112 agui::RadioButton rButton[3]; 113 agui::RadioButtonGroup rGroup; 114 agui::Slider slider; 115 agui::ExtendedTextBox exTextBox; 116 agui::TabbedPane tabbedPane; 117 agui::Tab tab[3]; 118 agui::ListBox listBox; 119 agui::ScrollPane scrollPane; 120 agui::Button scrollButtons[15]; 121 122public: 123 WidgetCreator(agui::Gui *guiInstance) 124{ 125 mGui = guiInstance; 126 mGui->add(&flow); 127 flow.add(&button); 128 button.setSize(80,40); 129 button.setText("Push Me"); 130 button.addActionListener(&simpleAL); 131 132 flow.add(&checkBox); 133 checkBox.setAutosizing(true); 134 checkBox.setText("Show me a message box"); 135 checkBox.setCheckBoxAlignment(agui::ALIGN_MIDDLE_LEFT); 136 checkBox.addActionListener(&simpleAL); 137 138 flow.add(&dropDown); 139 dropDown.setText("Select Item"); 140 dropDown.setSize(120,30); 141 dropDown.addItem("Apples"); 142 dropDown.addItem("Oranges"); 143 dropDown.addItem("Grapes"); 144 dropDown.addItem("Peaches"); 145 dropDown.addActionListener(&simpleAL); 146 147 flow.add(&textField); 148 textField.setText("Press Enter!"); 149 textField.resizeToContents(); 150 textField.addActionListener(&simpleAL); 151 152 gui->add(&frame); 153 frame.setSize(220,120); 154 frame.setLocation(60,60); 155 frame.setText("Example Frame"); 156 std::stringstream ss; 157 for(int i = 0; i < 3; ++i) 158 { 159 ss.str(""); 160 ss.clear(); 161 ss << "Sample Radio Button "; 162 ss << i; 163 164 rGroup.add(&rButton[i]); 165 rButton[i].setAutosizing(true); 166 rButton[i].setText(ss.str()); 167 frame.add(&rButton[i]); 168 rButton[i].setLocation(0,30 * i); 169 rButton[i].addActionListener(&simpleAL); 170 } 171 172 flow.add(&slider); 173 slider.setSize(100,36); 174 slider.setMaxValue(255); 175 slider.setMarkerSize(agui::Dimension(10,30)); 176 slider.addActionListener(&simpleAL); 177 178 exTextBox.setWordWrap(true); 179 exTextBox.setText("Welcome \n"); 180 exTextBox.setCurrentColor(agui::Color(255,0,0)); 181 exTextBox.appendText("WARNING!!!\n\n"); 182 exTextBox.setCurrentColor(agui::Color(255,0,255)); 183 exTextBox.appendText("Viewing text in magenta is not recommended\n\n"); 184 exTextBox.setCurrentColor(agui::Color(100,0,200)); 185 exTextBox.appendText("Copyright (c) 2011 Joshua Larouche \n \ 186\ 187License: (BSD) \n \ 188Redistribution and use in source and binary forms, with or without \ 189modification, are permitted provided that the following conditions \ 190are met: \n \ 1911. Redistributions of source code must retain the above copyright \ 192notice, this list of conditions and the following disclaimer. \n \ 1932. Redistributions in binary form must reproduce the above copyright \ 194notice, this list of conditions and the following disclaimer in \ 195the documentation and/or other materials provided with the distribution. \n \ 1963. Neither the name of Agui nor the names of its contributors may \ 197be used to endorse or promote products derived from this software \ 198without specific prior written permission. \n\n \ 199"); 200 201 exTextBox.setCurrentColor(agui::Color(255,128,0)); 202exTextBox.appendText("THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \ 203\"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT \ 204LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR \ 205A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT \ 206OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, \ 207SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED \ 208TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR \ 209PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF \ 210LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING \ 211NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS \ 212SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. \ 213"); 214 exTextBox.setSelection(84,100); 215 exTextBox.setSelectionColor(agui::Color(255,0,0)); 216 exTextBox.setSelection(0,0); 217 exTextBox.setTextAlignment(agui::ALIGN_CENTER); 218 exTextBox.setSize(600,300); 219 exTextBox.positionCaret(0,0); 220 221 tabbedPane.setSize(agui::Dimension(300,400)); 222 flow.add(&tabbedPane); 223 tab[0].setText("Text Box"); 224 tab[1].setText("List Box"); 225 tab[2].setText("Scroll Pane"); 226 tabbedPane.addTab(&tab[0],&exTextBox); 227 tabbedPane.addTab(&tab[1],&listBox); 228 tabbedPane.addTab(&tab[2],&scrollPane); 229 230 tabbedPane.setResizeTabContent(true); 231 232 for(int i = 0; i < 250; ++i) 233 { 234 ss.str(""); 235 ss.clear(); 236 ss << "Item "; 237 ss << i; 238 239 listBox.addItem(ss.str()); 240 } 241 242 listBox.setMultiselectExtended(true); 243 244 int count = 0; 245 for(int i = 0; i < 3; ++i) 246 { 247 for(int j = 0; j < 5; ++j) 248 { 249 250 ss.str(""); 251 ss.clear(); 252 ss << "Scroll Button "; 253 ss << i + 1; 254 ss << " , "; 255 ss << j + 1; 256 257 scrollPane.add(&scrollButtons[count]); 258 scrollButtons[count].setSize(200,100); 259 scrollButtons[count].setLocation(210 * i,110 * j); 260 scrollButtons[count].setText(ss.str()); 261 262 count++; 263 } 264 } 265} 266}; 267 268WidgetCreator* creator; 269 270bool initializeAllegro() { 271 //Initialize Allegro 272 if(!al_init()) 273 { 274 return false; 275 } 276 277 if(!al_init_image_addon()) 278 { 279 return false; 280 } 281 282 al_init_font_addon(); 283 284 if(!al_init_ttf_addon()) 285 { 286 return false; 287 } 288 289 if(!al_init_primitives_addon()) 290 { 291 return false; 292 } 293 if(!al_install_mouse()) 294 { 295 return false; 296 } 297 if(!al_install_keyboard()) 298 { 299 return false; 300 } 301 302 // Start a timer to regulate speed 303 timer = al_create_timer(1.0/FRAME_RATE); 304 al_start_timer(timer); 305 306 //show screen 307 308 al_set_new_display_flags(ALLEGRO_RESIZABLE); 309 310 display = al_create_display(640,480); 311 312 if(!display) 313 { 314 315 return false; 316 } 317 //show the mouse 318 al_show_mouse_cursor(display); 319 320 al_set_new_bitmap_flags(ALLEGRO_VIDEO_BITMAP); 321 322 //Window Title 323 al_set_window_title(display,"Agui - Example"); 324 325 queue = al_create_event_queue(); 326 327 return true; 328} 329 330void initializeAgui() 331{ 332 333 //Set the image loader 334 agui::Image::setImageLoader(new agui::Allegro5ImageLoader); 335 336 //Set the font loader 337 agui::Font::setFontLoader(new agui::Allegro5FontLoader); 338 339 //Instance the input handler 340 inputHandler = new agui::Allegro5Input(); 341 342 //Instance the graphics handler 343 graphicsHandler = new agui::Allegro5Graphics(); 344 345 //Allegro does not automatically premultiply alpha so let Agui do it 346 agui::Color::setPremultiplyAlpha(true); 347 348 //Instance the gui 349 gui = new agui::Gui(); 350 351 //Set the input handler 352 gui->setInput(inputHandler); 353 354 //Set the graphics handler 355 gui->setGraphics(graphicsHandler); 356 357 defaultFont = agui::Font::load("data/DejaVuSans.ttf",16); 358 359 //Setting a global font is required and failure to do so will crash. 360 agui::Widget::setGlobalFont(defaultFont); 361 362 363} 364 365void addWidgets() 366{ 367 creator = new WidgetCreator(gui); 368} 369void cleanUp() 370{ 371 gui->getTop()->clear(); 372 delete creator; 373 creator = NULL; 374 delete gui; 375 gui = NULL; 376 delete inputHandler; 377 delete graphicsHandler; 378 inputHandler = NULL; 379 graphicsHandler = NULL; 380 381 delete defaultFont; 382 defaultFont = NULL; 383} 384 void render() 385 { 386 al_clear_to_color(al_map_rgb(240,240,240)); 387 388 //render the widgets 389 gui->render(); 390 391 al_flip_display(); 392 393 } 394 395int main(int argc, char *argv[]) 396 397{ 398 if (!initializeAllegro()) 399 { 400 return 1; 401 } 402 403 initializeAgui(); 404 addWidgets(); 405 bool needRedraw = true; 406 // Start the event queue to handle keyboard input, mouse and our timer 407 408 al_register_event_source(queue, (ALLEGRO_EVENT_SOURCE*)al_get_keyboard_event_source()); 409 al_register_event_source(queue, (ALLEGRO_EVENT_SOURCE*)al_get_mouse_event_source()); 410 al_register_event_source(queue, (ALLEGRO_EVENT_SOURCE*)timer); 411 al_register_event_source(queue, (ALLEGRO_EVENT_SOURCE*)display); 412 413 while(!done) { 414 415 // Block until an event enters the queue 416 al_wait_for_event(queue, &event); 417 418 //Let Agui process the event 419 inputHandler->processEvent(event); 420 421 //Handle rendering and logic 422 if (needRedraw && al_event_queue_is_empty(queue)) { 423 424 gui->logic(); 425 render(); 426 427 needRedraw = false; 428 } 429 430 431 switch(event.type) { 432 433 case ALLEGRO_EVENT_TIMER: 434 if(event.timer.source == timer) 435 { 436 437 needRedraw = true; 438 } 439 440 break; 441 case ALLEGRO_EVENT_DISPLAY_RESIZE: 442 443 al_acknowledge_resize(event.display.source); 444 445 //Resize Agui 446 gui->resizeToDisplay(); 447 448 break; 449 case ALLEGRO_EVENT_DISPLAY_SWITCH_IN: 450 //Resize Agui 451 gui->resizeToDisplay(); 452 break; 453 case ALLEGRO_EVENT_DISPLAY_CLOSE: 454 return 0; 455 break; 456 } 457 } 458 459 cleanUp(); 460 461 return 0; 462}

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. :)

jmasterx
Member #11,410
October 2009

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"}609142

Peter Gill
Member #15,850
January 2015

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. ;D

Edgar Reynaldo
Member #8,592
May 2007
avatar

There are a couple warnings during the build process for the static git version :

#SelectExpand
1c:\mingw\LIBS\AGUI_github\Agui-master\build>mingw32-make 2[ 1%] Building CXX object CMakeFiles/agui.dir/src/Agui/Clipboard/WinClipboard.cpp.obj 3C:\mingw\LIBS\AGUI_github\Agui-master\src\Agui\Clipboard\WinClipboard.cpp: In static member function 'static std::string agui::WinClipboard::_winUTF16ToUTF8(const wstring&)': 4C:\mingw\LIBS\AGUI_github\Agui-master\src\Agui\Clipboard\WinClipboard.cpp:135:15: warning: passing NULL to non-pointer argument 2 of 'int WideCharToMultiByte(UINT, DWORD, LPCWSTR, int, LPSTR, int, LPCSTR, LPBOOL)' [-Wconversion-null] 5 NULL, NULL ); 6 ^ 7C:\mingw\LIBS\AGUI_github\Agui-master\src\Agui\Clipboard\WinClipboard.cpp:146:16: warning: passing NULL to non-pointer argument 2 of 'int WideCharToMultiByte(UINT, DWORD, LPCWSTR, int, LPSTR, int, LPCSTR, LPBOOL)' [-Wconversion-null] 8 NULL, NULL ) > 0 ) 9 ^ 10C:\mingw\LIBS\AGUI_github\Agui-master\src\Agui\Clipboard\WinClipboard.cpp: In static member function 'static std::wstring agui::WinClipboard::_winUTF8ToUTF16(const string&)': 11C:\mingw\LIBS\AGUI_github\Agui-master\src\Agui\Clipboard\WinClipboard.cpp:159:12: warning: passing NULL to non-pointer argument 2 of 'int MultiByteToWideChar(UINT, DWORD, LPCSTR, int, LPWSTR, int)' [-Wconversion-null] 12 NULL, 0 ); 13 ^ 14C:\mingw\LIBS\AGUI_github\Agui-master\src\Agui\Clipboard\WinClipboard.cpp:169:35: warning: passing NULL to non-pointer argument 2 of 'int MultiByteToWideChar(UINT, DWORD, LPCSTR, int, LPWSTR, int)' [-Wconversion-null] 15 &result[0], int(result.size())) > 0 ) 16 ^ 17[ 2%] Building CXX object CMakeFiles/agui.dir/src/Agui/Clipboard/Clipboard.cpp.obj 18...

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.

jmasterx
Member #11,410
October 2009

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.

Edgar Reynaldo
Member #8,592
May 2007
avatar

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 :

#SelectExpand
1 2c:\mingw\LIBS\AGUI_github\Agui-master\example>mingw32-g++ -Wall -g -o example.exe -I..\include -L..\build agui_example_a5.cpp -lagui_allegro5.dll -lagui.dll -lallegro_monolith-debug.dll 3agui_example_a5.cpp: In member function 'virtual void SimpleActionListener::actionPerformed(const agui::ActionEvent&)': 4agui_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] 5 NULL,NULL); 6 ^ 7C:\Users\Marc\AppData\Local\Temp\ccjsT2pe.o: In function `ZN13WidgetCreatorC1EPN4agui3GuiE': 8c:\mingw\LIBS\AGUI_github\Agui-master\example/agui_example_a5.cpp:124: undefined reference to `agui::ExtendedTextBox::ExtendedTextBox(agui::HScrollBar*, agui::VScrollBar*, agui::Widget*)' 9c:\mingw\LIBS\AGUI_github\Agui-master\example/agui_example_a5.cpp:179: undefined reference to `agui::ExtendedTextBox::setText(std::string const&)' 10c:\mingw\LIBS\AGUI_github\Agui-master\example/agui_example_a5.cpp:180: undefined reference to `agui::ExtendedTextBox::setCurrentColor(agui::Color const&)' 11c:\mingw\LIBS\AGUI_github\Agui-master\example/agui_example_a5.cpp:181: undefined reference to `agui::ExtendedTextBox::appendText(std::string const&, bool, bool)' 12c:\mingw\LIBS\AGUI_github\Agui-master\example/agui_example_a5.cpp:182: undefined reference to `agui::ExtendedTextBox::setCurrentColor(agui::Color const&)' 13c:\mingw\LIBS\AGUI_github\Agui-master\example/agui_example_a5.cpp:183: undefined reference to `agui::ExtendedTextBox::appendText(std::string const&, bool, bool)' 14c:\mingw\LIBS\AGUI_github\Agui-master\example/agui_example_a5.cpp:184: undefined reference to `agui::ExtendedTextBox::setCurrentColor(agui::Color const&)' 15c:\mingw\LIBS\AGUI_github\Agui-master\example/agui_example_a5.cpp:199: undefined reference to `agui::ExtendedTextBox::appendText(std::string const&, bool, bool)' 16c:\mingw\LIBS\AGUI_github\Agui-master\example/agui_example_a5.cpp:201: undefined reference to `agui::ExtendedTextBox::setCurrentColor(agui::Color const&)' 17c:\mingw\LIBS\AGUI_github\Agui-master\example/agui_example_a5.cpp:213: undefined reference to `agui::ExtendedTextBox::appendText(std::string const&, bool, bool)' 18c:\mingw\LIBS\AGUI_github\Agui-master\example/agui_example_a5.cpp:215: undefined reference to `agui::ExtendedTextBox::setSelectionColor(agui::Color const&)' 19c:\mingw\LIBS\AGUI_github\Agui-master\example/agui_example_a5.cpp:124: undefined reference to `agui::ExtendedTextBox::~ExtendedTextBox()' 20C:\Users\Marc\AppData\Local\Temp\ccjsT2pe.o: In function `ZN13WidgetCreatorD1Ev': 21c:\mingw\LIBS\AGUI_github\Agui-master\example/agui_example_a5.cpp:102: undefined reference to `agui::ExtendedTextBox::~ExtendedTextBox()' 22c:\mingw\LIBS\AGUI_github\Agui-master\example/agui_example_a5.cpp:102: undefined reference to `agui::ExtendedTextBox::~ExtendedTextBox()' 23collect2.exe: error: ld returned 1 exit status 24 25c:\mingw\LIBS\AGUI_github\Agui-master\example>

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.

jmasterx
Member #11,410
October 2009

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

Edgar Reynaldo
Member #8,592
May 2007
avatar

Go to: