-
-
Notifications
You must be signed in to change notification settings - Fork 10.5k
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
Strdup undeclared under MinGW with -std=c++11 in imgui_demo #520
Comments
I don't know which version you are looking at, but those ImStrdup were replaced with strdup a long time ago. The opengl_example* Makefile already have -limm32 for mingw. Where did you have to add it? |
Sorry, i messed up my original message, now edited, the compiler error was about About imm32 I just copied the 3 sdl_opengl_example files and setup this CMakeLists.txt for building on Clion: cmake_minimum_required(VERSION 3.4)
project(Imgui_demo)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
########### SDL paths ############
set(SDL_INCLUDE_DIR "D:/Dev/Lib/SDL2-2.0.3/i686-w64-mingw32/include/SDL2")
set(SDL_LIB_DIR "D:/Dev/Lib/SDL2-2.0.3/i686-w64-mingw32/lib")
find_library(SDL_LIBRARY
NAMES SDL2
HINTS ${SDL_LIB_DIR}
NO_DEFAULT_PATH)
#################################
list(APPEND LIBRARIES ${SDL_LIBRARY})
list(APPEND LIBRARIES opengl32)
list(APPEND LIBRARIES imm32)
set(SOURCE_FILES main.cpp)
list(APPEND SOURCE_FILES imgui.cpp imgui.h)
list(APPEND SOURCE_FILES imgui_impl_sdl.cpp imgui_impl_sdl.h)
list(APPEND SOURCE_FILES imgui_demo.cpp)
list(APPEND SOURCE_FILES imgui_internal.h)
list(APPEND SOURCE_FILES imgui_draw.cpp)
list(APPEND SOURCE_FILES stb_rect_pack.h)
list(APPEND SOURCE_FILES stb_textedit.h)
list(APPEND SOURCE_FILES stb_truetype.h)
include_directories(${SDL_INCLUDE_DIR})
add_executable(Imgui_demo ${SOURCE_FILES})
target_link_libraries("Imgui_demo" ${LIBRARIES}) |
Where is strdup declared with your compiler/system? |
Ok I should have searched a bit more, when using the -std=c++11 flag, in string.h, the strdup and several other functions are ifdef'ed out under STRICT_ANSI |
What that's another annoyance caused by MinGW and modern compilers I suppose :/ |
About imm32: the docs are for Visual Studio but the Makefile for MinGW in OpenGL examples have the imm32 library. We could have an extra command-line example for MinGW if you want to submit a PR that cover various examples. Ideally we have a better build system across all examples. cmake is just too ugly with the amount of temporary files it creates. |
FYI, leaving a note here for potential future readers stumbling here: I have renamed those two defines that are usable (but very rarely used) in imconfig.h Very few people will be affected and they will likely get a link error and therefore will notice. The discussion in this thread pertain to using GCC/MinGW and both have those functions disabled already, so GCC/MinGW shouldn't be affected. |
Not exactly STRICT_ANSI but STRICT_ANSI
|
Hi,
I just decided to give a try to this lib as it looks super cool and I only encoutered one compilation error so I though I should report it before forgetting about it 😃
In Clion, after copying and defining all the root files in the CMakeLists.txt, i got these errors:
My env is MinGW on Win7 with GCC 4.8.1
This function seems to be from POSIX standard but not from C/C++.
Looking at the code I found the
ImStrdup()
function declared inimgui_internal.h
and defined inimgui.cpp
.Changing the 2 strdup to ImStrdup and adding
#include "imgui_internal.h"
inimgui_demo.cpp
made the trick but I'm unsure if including the whole internal header is the best fix for this.PS: I also had to add
-limm32
to the compiler flag to make it link.The text was updated successfully, but these errors were encountered: