EttoreBarattelli Posted June 15, 2016 Report Share Posted June 15, 2016 Hi all, after a few attemps, I managed to get a "Hello World" Win32 project to compile and run on Visual Studio (the version I'm using is Visual Studio 2013, toolkit v120), but it did require a few changes in the uGFX library code. The procedure I'm using is the following: generate code (i.e. preview button in uGFX Studio) for a Hello World project (a simple container with a Label widget) from uGFX Studio (version 0.15 for Windows) create a VS solution to compile both the uGFX library and the GUI code generated by uGFX Studio To compile the library I'm using the "single file inclusion" method, therefore I just added the "gfx_mk.c" and "gdisp_lld_Win32.c" files (as well as "gui.c" and "main.c" generated by uGFX Studio) in the VS solution and set the include paths and preprocessor symbols accordingly. Here the list of changes I had to apply to the uGFX library code: file src/gos/gos_win32.c: changed line 77: //typedef LONG __stdcall (*_NtQuerySemaphore)( // INITIAL typedef LONG (__stdcall *_NtQuerySemaphore)( // FIXED file src/gos/gos_win32.c: changed line 100: //gfxThreadHandle gfxThreadCreate(void *stackarea, size_t stacksz, threadpriority_t prio, DECLARE_THREAD_FUNCTION((*fn),p), void *param) { // INITIAL gfxThreadHandle gfxThreadCreate(void *stackarea, size_t stacksz, threadpriority_t prio, DECLARE_THREAD_FUNCTION(*fn,p), void *param) { // FIXED file src/gos/gos_win32.h: changed lines 49-50: //#define DECLARE_THREAD_FUNCTION(fnName, param) threadreturn_t WINAPI fnName(void *param) // INITIAL //#define DECLARE_THREAD_STACK(name, sz) uint8_t name[0]; #define DECLARE_THREAD_FUNCTION(fnName, param) threadreturn_t (WINAPI fnName)(void *param) // FIXED #define DECLARE_THREAD_STACK(name, sz) uint8_t name[sz]; file src/gos/gos_win32.h: changed line 99: //gfxThreadHandle gfxThreadCreate(void *stackarea, size_t stacksz, threadpriority_t prio, DECLARE_THREAD_FUNCTION((*fn),p), void *param); // INITIAL gfxThreadHandle gfxThreadCreate(void *stackarea, size_t stacksz, threadpriority_t prio, DECLARE_THREAD_FUNCTION(*fn,p), void *param); // FIXED file src/gfx_compilers.h: changed line 728: //#warning "You are using an un-tested compiler. Please report any compile errors or warnings on the ugfx forum" // INITIAL #pragma message( "You are using an un-tested compiler. Please report any compile errors or warnings on the ugfx forum" ) // FIXED file src/gfx_compilers.h: changed line 901: //#define GFXINLINE inline // INITIAL #define GFXINLINE __forceinline // FIXED Obviously these changes are specific to Visual Studio and might (and probably will) break other compilers. If you like I can share the project with all resources (VS solution, updated uGFX library code, generated code for sample GUI). Thanks, Ettore Link to comment Share on other sites More sharing options...
Joel Bodenmann Posted June 23, 2016 Report Share Posted June 23, 2016 Hello Ettore and welcome to the community! Sorry for the late reply. We appreciate this a lot. It's nice that you list everything in such a level of detail, nice work! As you mentioned, these changes are very Visual Studio specific. Sadly we don't see a way (yet) to integrate them in an easy way without breaking support for other compilers or introducing a very ugly #ifdef mess. For the time being, we added a note to the documentation that points to this forum topic: http://wiki.ugfx.org/index.php/Win32 Keep up the good work! Link to comment Share on other sites More sharing options...
inmarket Posted June 23, 2016 Report Share Posted June 23, 2016 The visual studio compiler should be detected automatically, we just need to add the appropriate #if tests. I will look at it later when i get some time. Link to comment Share on other sites More sharing options...
Joel Bodenmann Posted June 23, 2016 Report Share Posted June 23, 2016 That will be a lot of #ifdefs. But I guess as almost all of them are located inside the specific Windows port we might give it a go... Link to comment Share on other sites More sharing options...
inmarket Posted June 23, 2016 Report Share Posted June 23, 2016 @EttoreBarattelli Can you please zip and attach your hello world solution project files? It will save me some time in testing for integration. Link to comment Share on other sites More sharing options...
EttoreBarattelli Posted June 27, 2016 Author Report Share Posted June 27, 2016 Hi @inmarket, attached my VS2013 test project, with modified uGFX library source files and test GUI. Thanks, Ettore uGFXLib_VS2013.zip Link to comment Share on other sites More sharing options...
inmarket Posted June 27, 2016 Report Share Posted June 27, 2016 Thanks. Link to comment Share on other sites More sharing options...
Nic Heath Posted June 26, 2017 Report Share Posted June 26, 2017 Ettore, your zip file was extremely helpful thank you. Link to comment Share on other sites More sharing options...
inmarket Posted June 30, 2017 Report Share Posted June 30, 2017 The repository has now been updated to properly support Visual Studio when compiling. Link to comment Share on other sites More sharing options...
jarekk Posted October 17, 2017 Report Share Posted October 17, 2017 Was it really ? I tried the same with 2015 Community Edition and ugfx 2.7 - had to apply same fixes. Also got some chinese characters for free :-) ( this is sample project from ugfx repo for win32 ) Link to comment Share on other sites More sharing options...
inmarket Posted October 17, 2017 Report Share Posted October 17, 2017 Use the git repository version not the released 2.7 zip. The repository has all the latest updates including the fixes you need. http://git.ugfx.io Link to comment Share on other sites More sharing options...
jarekk Posted October 18, 2017 Report Share Posted October 18, 2017 Thanks. Much much better - now indeed it works without any glitches Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now