'How can I compile Cimgui statically and then use it?
I'm new to C and I need some help with linking and compeileing.
Here is the library which I want to use: cimgui github I followed the instructions about how can I compile the library with the makefile and with CMake. (This is the make i use) When I used the makefile which was included in the project I used "make static" and in CMake I used MinGW makefile option and made the static option to "yes". With both options I successfully generated the .a file, so far so good. The problem comes when I try to compile a C code with the library. I tried: gcc main.c -o guitest cimgui.a but I get a lot of errors of compileing the header file (i guess). Any ideas how to make it work?
Thanks.
Here is some of the error code:
D:\Prog\C\gui>gcc main.c -o guitest cimgui.a
In file included from main.c:3:
cimgui.h:2560:28: error: expected identifier or '(' before ':' token
typedef struct ImGuiStorage::ImGuiStoragePair ImGuiStoragePair;
^
cimgui.h:2561:31: error: expected identifier or '(' before ':' token
typedef struct ImGuiTextFilter::ImGuiTextRange ImGuiTextRange;
^
cimgui.h:2562:14: error: expected '=', ',', ';', 'asm' or '__attribute__' before ':' token
typedef ImStb::STB_TexteditState STB_TexteditState;
^
cimgui.h:2563:14: error: expected '=', ',', ';', 'asm' or '__attribute__' before ':' token
typedef ImStb::StbTexteditRow StbTexteditRow;
^
cimgui.h:2564:14: error: expected '=', ',', ';', 'asm' or '__attribute__' before ':' token
typedef ImStb::StbUndoRecord StbUndoRecord;
^
cimgui.h:2565:14: error: expected '=', ',', ';', 'asm' or '__attribute__' before ':' token
typedef ImStb::StbUndoState StbUndoState;
^
cimgui.h:2566:22: error: expected '=', ',', ';', 'asm' or '__attribute__' before '<' token
typedef ImChunkStream<ImGuiTableSettings> ImChunkStream_ImGuiTableSettings;
^
cimgui.h:2567:22: error: expected '=', ',', ';', 'asm' or '__attribute__' before '<' token
typedef ImChunkStream<ImGuiWindowSettings> ImChunkStream_ImGuiWindowSettings;
^
cimgui.h:2568:15: error: expected '=', ',', ';', 'asm' or '__attribute__' before '<' token
typedef ImPool<ImGuiTabBar> ImPool_ImGuiTabBar;
^
cimgui.h:2569:15: error: expected '=', ',', ';', 'asm' or '__attribute__' before '<' token
typedef ImPool<ImGuiTable> ImPool_ImGuiTable;
^
cimgui.h:2570:15: error: expected '=', ',', ';', 'asm' or '__attribute__' before '<' token
typedef ImSpan<ImGuiTableCellData> ImSpan_ImGuiTableCellData;
^
cimgui.h:2571:15: error: expected '=', ',', ';', 'asm' or '__attribute__' before '<' token
typedef ImSpan<ImGuiTableColumn> ImSpan_ImGuiTableColumn;
^
cimgui.h:2572:15: error: expected '=', ',', ';', 'asm' or '__attribute__' before '<' token
typedef ImSpan<ImGuiTableColumnIdx> ImSpan_ImGuiTableColumnIdx;
^
cimgui.h:2573:17: error: expected '=', ',', ';', 'asm' or '__attribute__' before '<' token
typedef ImVector<ImDrawChannel> ImVector_ImDrawChannel;
^
cimgui.h:2574:17: error: expected '=', ',', ';', 'asm' or '__attribute__' before '<' token
typedef ImVector<ImDrawCmd> ImVector_ImDrawCmd;
^
cimgui.h:2575:17: error: expected '=', ',', ';', 'asm' or '__attribute__' before '<' token
typedef ImVector<ImDrawIdx> ImVector_ImDrawIdx;
^
cimgui.h:2576:17: error: expected '=', ',', ';', 'asm' or '__attribute__' before '<' token
typedef ImVector<ImDrawList*> ImVector_ImDrawListPtr;
cimgui.h:3768:51: error: unknown type name 'ImFontAtlas'
CIMGUI_API void igImFontAtlasBuildPackCustomRects(ImFontAtlas* atlas,void* stbrp_context_opaque);
^~~~~~~~~~~
cimgui.h:3769:42: error: unknown type name 'ImFontAtlas'
CIMGUI_API void igImFontAtlasBuildFinish(ImFontAtlas* atlas);
^~~~~~~~~~~
cimgui.h:3770:60: error: unknown type name 'ImFontAtlas'
CIMGUI_API void igImFontAtlasBuildRender8bppRectFromString(ImFontAtlas* atlas,int x,int y,int w,int h,const char* in_str,char in_marker_char,unsigned char in_marker_pixel_value);
^~~~~~~~~~~
cimgui.h:3771:61: error: unknown type name 'ImFontAtlas'
CIMGUI_API void igImFontAtlasBuildRender32bppRectFromString(ImFontAtlas* atlas,int x,int y,int w,int h,const char* in_str,char in_marker_char,unsigned int in_marker_pixel_value);
^~~~~~~~~~~
cimgui.h:3780:48: warning: 'struct ImGuiTextBuffer' declared inside parameter list will not be visible outside of this definition or declaration
CIMGUI_API void ImGuiTextBuffer_appendf(struct ImGuiTextBuffer *buffer, const char *fmt, ...);
^~~~~~~~~~~~~~~
cimgui.h:3787:12: error: unknown type name 'ImVector_ImWchar'
CIMGUI_API ImVector_ImWchar* ImVector_ImWchar_create(void);
^~~~~~~~~~~~~~~~
cimgui.h:3788:42: error: unknown type name 'ImVector_ImWchar'
CIMGUI_API void ImVector_ImWchar_destroy(ImVector_ImWchar* self);
^~~~~~~~~~~~~~~~
cimgui.h:3789:39: error: unknown type name 'ImVector_ImWchar'
CIMGUI_API void ImVector_ImWchar_Init(ImVector_ImWchar* p);
^~~~~~~~~~~~~~~~
cimgui.h:3790:41: error: unknown type name 'ImVector_ImWchar'
CIMGUI_API void ImVector_ImWchar_UnInit(ImVector_ImWchar* p);
^~~~~~~~~~~~~~~~
In file included from main.c:2:
main.c: In function 'main':
main.c:16:66: error: 'ImGuiIO' undeclared (first use in this function)
assert(igDebugCheckVersionAndDataLayout(igGetVersion(), sizeof(ImGuiIO), sizeof(ImGuiStyle),
^~~~~~~
main.c:16:66: note: each undeclared identifier is reported only once for each function it appears in
main.c:16:83: error: 'ImGuiStyle' undeclared (first use in this function); did you mean 'igGetStyle'?
assert(igDebugCheckVersionAndDataLayout(igGetVersion(), sizeof(ImGuiIO), sizeof(ImGuiStyle),
^~~~~~~~~~
main.c:17:50: error: 'ImVec2' undeclared (first use in this function)
sizeof(ImVec2), sizeof(ImVec4), sizeof(ImDrawVert),
^~~~~~
main.c:17:66: error: 'ImVec4' undeclared (first use in this function)
sizeof(ImVec2), sizeof(ImVec4), sizeof(ImDrawVert),
^~~~~~
main.c:17:82: error: 'ImDrawVert' undeclared (first use in this function)
sizeof(ImVec2), sizeof(ImVec4), sizeof(ImDrawVert),
^~~~~~~~~~
main.c:18:50: error: 'ImDrawIdx' undeclared (first use in this function)
sizeof(ImDrawIdx)));
^~~~~~~~~
main.c:20:3: warning: implicit declaration of function 'igCreateContext'; did you mean 'igGetCurrentContext'? [-Wimplicit-function-declaration]
igCreateContext(NULL);
^~~~~~~~~~~~~~~
igGetCurrentContext
main.c:21:12: error: 'io' undeclared (first use in this function)
ImGuiIO *io = igGetIO();
^~
main.c:25:3: warning: implicit declaration of function 'ImFontAtlas_GetTexDataAsRGBA32' [-Wimplicit-function-declaration]
ImFontAtlas_GetTexDataAsRGBA32(io->Fonts, &text_pixels, &text_w, &text_h, NULL);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
main.c:30:11: error: expected ';' before 'display_size'
ImVec2 display_size;
^~~~~~~~~~~~~
;
main.c:31:5: error: 'display_size' undeclared (first use in this function)
display_size.x = 1920;
^~~~~~~~~~~~
main.c:37:5: warning: implicit declaration of function 'igBegin'; did you mean 'igBeginMenu'? [-Wimplicit-function-declaration]
igBegin("mainwindow",NULL,ImGuiWindowFlags_NoTitleBar);
^~~~~~~
igBeginMenu
main.c:37:31: error: 'ImGuiWindowFlags_NoTitleBar' undeclared (first use in this function)
igBegin("mainwindow",NULL,ImGuiWindowFlags_NoTitleBar);
^~~~~~~~~~~~~~~~~~~~~~~~~~~
main.c:40:5: warning: implicit declaration of function 'igSliderFloat'; did you mean 'igValue_Float'? [-Wimplicit-function-declaration]
igSliderFloat("float", &f, 0.0f, 1.0f, "%.3f", 0);
^~~~~~~~~~~~~
igValue_Float
main.c:50:3: warning: implicit declaration of function 'igDestroyContext'; did you mean 'igGetCurrentContext'? [-Wimplicit-function-declaration]
igDestroyContext(NULL);
^~~~~~~~~~~~~~~~
igGetCurrentContext
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
