Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Help-me for build with mingw on windows #45

Open
MarcosSoares10 opened this issue May 5, 2018 · 5 comments
Open

Help-me for build with mingw on windows #45

MarcosSoares10 opened this issue May 5, 2018 · 5 comments

Comments

@MarcosSoares10
Copy link

MarcosSoares10 commented May 5, 2018

Hello good evening, I'm having problems compiling your lib in my project, a good part of the implementations are compiling correctly in my MINGW compiler on a Windows machine.

However, adding #include "imguifilesystem.h" in the main.cpp file generates several errors like:

/usr/share/mingw-w64/include/minwindef.h:142:17: error: 'typedef float FLOAT' redeclared as different kind of symbol
/usr/share/mingw-w64/include/winnt.h:598:16: error: 'typedef BYTE BOOLEAN' redeclared as different kind of symbol  typedef BYTE BOOLEAN;
/usr/share/mingw-w64/include/winnt.h:3651:7: error: 'BOOLEAN' does not name a type BOOLEAN EffectiveOnly;

I'm including your lib in Cmake as follows:

set (IMGUI_INCLUDE_DIRS
  $ {CMAKE_CURRENT_SOURCE_DIR} / dependencies / imgui /
  $ {CMAKE_CURRENT_SOURCE_DIR} / dependencies / imgui / addons
  $ {CMAKE_CURRENT_SOURCE_DIR} / dependencies / imgui / addons / imguifilesystem)

set (IMGUI_LIBRARY imgui)

set (IMGUI_USE_MINIZIP OFF CACHE BOOL "IMGUI_USE_MINIZIP")
add_definitions (-DYES_IMGUIADDONS_ALL)

INCLUDE_DIRECTORIES (
    $ {CMAKE_CURRENT_SOURCE_DIR} / imgui / addons /
    $ {CMAKE_CURRENT_SOURCE_DIR} / imgui /
    $ {CMAKE_CURRENT_SOURCE_DIR} / imgui / addons / imguifilesystem /
)

add_library (imgui STATIC
    $ {CMAKE_CURRENT_SOURCE_DIR} /imgui/imgui.h
    $ {CMAKE_CURRENT_SOURCE_DIR} /imgui/imgui.cpp
    $ {CMAKE_CURRENT_SOURCE_DIR} /imgui/imgui_demo.cpp
    $ {CMAKE_CURRENT_SOURCE_DIR} /imgui/imgui_draw.cpp
    $ {CMAKE_CURRENT_SOURCE_DIR} /imgui/addons/imgui_user.h
    $ {CMAKE_CURRENT_SOURCE_DIR} /imgui/addons/imguifilesystem/dirent_portable.h
    $ {CMAKE_CURRENT_SOURCE_DIR} /imgui/addons/imguifilesystem/imguifilesystem.h
    $ {CMAKE_CURRENT_SOURCE_DIR} /imgui/addons/imguifilesystem/imguifilesystem.cpp
    )

How can I proceed with a solution?
Thank you for your cooperation.

@Flix01
Copy link
Owner

Flix01 commented May 5, 2018

Well, I'm not familiar with editing a CMake file... however:

a good part of the implementations are compiling correctly in my MINGW compiler on a Windows machine. However, adding #include "imguifilesystem.h" in the main.cpp file generates several errors like:

/usr/share/mingw-w64/include/minwindef.h:142:17: error: 'typedef float FLOAT' redeclared as different kind of symbol
/usr/share/mingw-w64/include/winnt.h:598:16: error: 'typedef BYTE BOOLEAN' redeclared as different kind of symbol  typedef BYTE BOOLEAN;
/usr/share/mingw-w64/include/winnt.h:3651:7: error: 'BOOLEAN' does not name a type BOOLEAN EffectiveOnly;

Well, from the paths you're posting it looks like a Linux or Mac OS rather than Windows, doesn't it?

But what's more important, there are different ways to use the addons correctly. They're explained here: README_FIRST.txt.

In short:

  1. If you just want to use plain Dear Imgui + imguifilesystem, you should try removing the lines:
set (IMGUI_USE_MINIZIP OFF CACHE BOOL "IMGUI_USE_MINIZIP")
add_definitions (-DYES_IMGUIADDONS_ALL)
  1. Otherwise, if you want to use the whole framework, you should define something like:
-/D"IMGUI_INCLUDE_IMGUI_USER_H" -D"IMGUI_INCLUDE_IMGUI_USER_INL" -D"IMGUI_USE_GLEW_BINDING" 

(or another binding) and remove any cpp file related to the addons, that in your case is $ {CMAKE_CURRENT_SOURCE_DIR} /imgui/addons/imguifilesystem/imguifilesystem.cpp.

If you want to use option 2, it would be better if you try to compile the whole first demo from the command line to see if it works. Unluckily, I've not added any command line for mingw in README_FIRST.txt, so you should try to modify some of the command lines that are present. I've got a mingw installation on Linux I can use to provide some further feedback if needed.

More than the CMake file, I'd be interested to see the compiler command lines, if you can provide them.

@Flix01
Copy link
Owner

Flix01 commented May 5, 2018

I've just tried this command line (launched from the examples/addon_examples subfolder) on Linux-Mingw64 and it works for me to compile the first demo using plain Window API + GLEW.

The problem is that I had to add to the command line below all my include folders and library paths (using the -I and -L options (these are system-dependent and can't be easily copied).

x86_64-w64-mingw32-g++ -O2 -mwindows ../../imgui.cpp ../../imgui_draw.cpp ../../imgui_demo.cpp main.cpp -o imgui_addons_example1.exe -fexceptions -DIMGUI_INCLUDE_IMGUI_USER_H -DIMGUI_INCLUDE_IMGUI_USER_INL -DIMIMPL_SHADER_GL3 -DIMGUI_USE_WINAPI_BINDING -DIMGUI_USE_GLEW -DWINVER=0x0800 -D_WIN32 -D_WIN64 -I"." -I"../.." -static-libgcc -static-libstdc++ -lglew32 -lopengl32 -limm32 -luser32 -lkernel32 -s 

Hope it helps.

@MarcosSoares10
Copy link
Author

Thank you for your collaboration

Well, from the paths you're posting it looks like a Linux or Mac OS rather than Windows, doesn't it?
Yes, actually this is a linux log, this was because I reproduced the error in travis.ci
If I remove these commands

set (IMGUI_USE_MINIZIP OFF CACHE BOOL "IMGUI_USE_MINIZIP")
add_definitions (-DYES_IMGUIADDONS_ALL)

The crashes continue and this occurs only for build in mingw, all similar to this:
winnt.h:3651:7: error: 'BOOLEAN' does not name a type BOOLEAN EffectiveOnly;

-/D"IMGUI_INCLUDE_IMGUI_USER_H" -D"IMGUI_INCLUDE_IMGUI_USER_INL" -D"IMGUI_USE_GLEW_BINDING"
and remove any cpp file related to the addons,
{CMAKE_CURRENT_SOURCE_DIR} /imgui/addons/imguifilesystem/imguifilesystem.cpp.
also did not solve and continued with the same error

More than the CMake file, I'd be interested to see the compiler command lines, if you can provide them.
I do not use any command line, I just added the files to build, as described in previous posts.

@Flix01
Copy link
Owner

Flix01 commented May 7, 2018

I do not use any command line, I just added the files to build, as described in previous posts.

The compiler command line log must still be present somewhere (behind the scenes) when you compile your project.

Without this, I can't help you because I cannot replicate your issue, I don't have a Window OS and I've never seen such an error.

Yes, actually this is a linux log, this was because I reproduced the error in travis.ci
If I remove these commands

Well, then I should be able to replicate it with my Linux installation of mingw (if you can provide something I can replicate).

winnt.h:3651:7: error: 'BOOLEAN' does not name a type BOOLEAN EffectiveOnly;

Not sure, but BOOLEAN and FLOAT (uppercase) are plain C types AFAIK.
Are you mixing C++ files with some plain C file ? Or it's just some header file that is missing ?

@Flix01
Copy link
Owner

Flix01 commented May 7, 2018

About:

winnt.h:3651:7: error: 'BOOLEAN' does not name a type BOOLEAN EffectiveOnly;

in winnt.h:

#ifndef _BOOLEAN_
#define _BOOLEAN_
  typedef BYTE BOOLEAN;
#endif
  typedef BOOLEAN *PBOOLEAN;

// [...]

    typedef BOOLEAN SECURITY_CONTEXT_TRACKING_MODE,*PSECURITY_CONTEXT_TRACKING_MODE;

    typedef struct _SECURITY_QUALITY_OF_SERVICE {
      DWORD Length;
      SECURITY_IMPERSONATION_LEVEL ImpersonationLevel;
      SECURITY_CONTEXT_TRACKING_MODE ContextTrackingMode;
      BOOLEAN EffectiveOnly;   // <=== This is when BOOLEAN is undefined for you
    } SECURITY_QUALITY_OF_SERVICE,*PSECURITY_QUALITY_OF_SERVICE;

So basically such an error might happen if: _BOOLEAN_ is defined somewhere before an inclusion of winnt.h, without BOOLEAN being defined.

Hard to tell when this happens without seeing an example I can reproduce.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants