Compiler error on Windows 7 #238

Closed
opened 2015-05-31 14:46:51 +00:00 by TimothyWrightSoftware · 9 comments
TimothyWrightSoftware commented 2015-05-31 14:46:51 +00:00 (Migrated from github.com)

Below is the only smallest example of code that does not compile.
I'm using Windows 7, msvc 2013, SDL 2.0.3.

static void renderDrawLists(ImDrawList** const cmd_lists, int cmd_lists_count) {

}

static const char* ImGui_ImplGlfw_GetClipboardText() {
    return "";
}

static void ImGui_ImplGlfw_SetClipboardText(const char* text) {

}

bool imgui_init() {

    ImGuiIO& io = ImGui::GetIO();
    io.KeyMap[ImGuiKey_Tab] = SDLK_SPACE;                 
    io.RenderDrawListsFn = renderDrawLists;
    io.SetClipboardTextFn = ImGui_ImplGlfw_SetClipboardText;
    io.GetClipboardTextFn = ImGui_ImplGlfw_GetClipboardText;

    return true;
}

The errors are as follows:

imgui.obj : error LNK2019: unresolved external symbol __imp_OpenClipboard referenced in function "char const * __cdecl GetClipboardTextFn_DefaultImpl(void)" (?GetClipboardTextFn_DefaultImpl@@YAPEBDXZ)
imgui.obj : error LNK2019: unresolved external symbol __imp_CloseClipboard referenced in function "char const * __cdecl GetClipboardTextFn_DefaultImpl(void)" (?GetClipboardTextFn_DefaultImpl@@YAPEBDXZ)
imgui.obj : error LNK2019: unresolved external symbol __imp_SetClipboardData referenced in function "void __cdecl SetClipboardTextFn_DefaultImpl(char const *)" (?SetClipboardTextFn_DefaultImpl@@YAXPEBD@Z)
imgui.obj : error LNK2019: unresolved external symbol __imp_GetClipboardData referenced in function "char const * __cdecl GetClipboardTextFn_DefaultImpl(void)" (?GetClipboardTextFn_DefaultImpl@@YAPEBDXZ)
imgui.obj : error LNK2019: unresolved external symbol __imp_EmptyClipboard referenced in function "void __cdecl SetClipboardTextFn_DefaultImpl(char const *)" (?SetClipboardTextFn_DefaultImpl@@YAXPEBD@Z)

I tried to compile with and without #define IMGUI_DISABLE_WIN32_DEFAULT_CLIPBOARD_FUNCS but it didn't make a difference.

Below is the only smallest example of code that does not compile. I'm using Windows 7, msvc 2013, SDL 2.0.3. ``` cpp static void renderDrawLists(ImDrawList** const cmd_lists, int cmd_lists_count) { } static const char* ImGui_ImplGlfw_GetClipboardText() { return ""; } static void ImGui_ImplGlfw_SetClipboardText(const char* text) { } bool imgui_init() { ImGuiIO& io = ImGui::GetIO(); io.KeyMap[ImGuiKey_Tab] = SDLK_SPACE; io.RenderDrawListsFn = renderDrawLists; io.SetClipboardTextFn = ImGui_ImplGlfw_SetClipboardText; io.GetClipboardTextFn = ImGui_ImplGlfw_GetClipboardText; return true; } ``` The errors are as follows: ``` imgui.obj : error LNK2019: unresolved external symbol __imp_OpenClipboard referenced in function "char const * __cdecl GetClipboardTextFn_DefaultImpl(void)" (?GetClipboardTextFn_DefaultImpl@@YAPEBDXZ) imgui.obj : error LNK2019: unresolved external symbol __imp_CloseClipboard referenced in function "char const * __cdecl GetClipboardTextFn_DefaultImpl(void)" (?GetClipboardTextFn_DefaultImpl@@YAPEBDXZ) imgui.obj : error LNK2019: unresolved external symbol __imp_SetClipboardData referenced in function "void __cdecl SetClipboardTextFn_DefaultImpl(char const *)" (?SetClipboardTextFn_DefaultImpl@@YAXPEBD@Z) imgui.obj : error LNK2019: unresolved external symbol __imp_GetClipboardData referenced in function "char const * __cdecl GetClipboardTextFn_DefaultImpl(void)" (?GetClipboardTextFn_DefaultImpl@@YAPEBDXZ) imgui.obj : error LNK2019: unresolved external symbol __imp_EmptyClipboard referenced in function "void __cdecl SetClipboardTextFn_DefaultImpl(char const *)" (?SetClipboardTextFn_DefaultImpl@@YAXPEBD@Z) ``` I tried to compile with and without `#define IMGUI_DISABLE_WIN32_DEFAULT_CLIPBOARD_FUNCS` but it didn't make a difference.
ocornut commented 2015-05-31 14:50:32 +00:00 (Migrated from github.com)

Those functions are defined in msvc 2013 " User32.lib " which you need to link into.

IMGUI_DISABLE_WIN32_DEFAULT_CLIPBOARD_FUNCS needs to be defined in imconfig.h for it to be seen while compiling imgui.cpp. Is that what you did? It should work and disable the use of those functions.

Those functions are defined in msvc 2013 " User32.lib " which you need to link into. IMGUI_DISABLE_WIN32_DEFAULT_CLIPBOARD_FUNCS needs to be defined in imconfig.h for it to be seen while compiling imgui.cpp. Is that what you did? It should work and disable the use of those functions.
TimothyWrightSoftware commented 2015-05-31 14:52:30 +00:00 (Migrated from github.com)

I'm compiling everything by hand, only using cl.exe and vim, so I don't have any win32 stuff in there by default. I will look at the imconfig.h and see if that works.

I'm compiling everything by hand, only using cl.exe and vim, so I don't have any win32 stuff in there by default. I will look at the imconfig.h and see if that works.
ocornut commented 2015-05-31 14:53:17 +00:00 (Migrated from github.com)

Normally user32.lib is linked automatically under Windows unless you ignored the default library or explicitly disabled it. I should probably use a link pragma there (and you can still disable it via imconfig.h)

Normally user32.lib is linked automatically under Windows unless you ignored the default library or explicitly disabled it. I should probably use a link pragma there (and you can still disable it via imconfig.h)
TimothyWrightSoftware commented 2015-05-31 14:54:58 +00:00 (Migrated from github.com)

It worked with the two #defines in the imconfig.h. I didn't look at that file at first, because I didn't know there was stuff in there. A quick note in the FAQ would fix this.

It worked with the two #defines in the imconfig.h. I didn't look at that file at first, because I didn't know there was stuff in there. A quick note in the FAQ would fix this.
ocornut commented 2015-05-31 14:56:52 +00:00 (Migrated from github.com)

Note that if you are compiling and linking for Windows you are probably better of using the native clipboard facilities rather than disabling it.

I added the linking pragma now. I was already using it for IME input support and nobody reported an issue so it looks like this added one won't be a probelm.

Note that if you are compiling and linking for Windows you are probably better of using the native clipboard facilities rather than disabling it. I added the linking pragma now. I was already using it for IME input support and nobody reported an issue so it looks like this added one won't be a probelm.
TimothyWrightSoftware commented 2015-05-31 15:00:15 +00:00 (Migrated from github.com)

Yep, that did it. Added the pragma, took out the #defines, and all is good.

Yep, that did it. Added the pragma, took out the #defines, and all is good.
TimothyWrightSoftware commented 2015-05-31 15:00:28 +00:00 (Migrated from github.com)

Thanks for the quick response!

Thanks for the quick response!
ocornut commented 2015-05-31 15:04:16 +00:00 (Migrated from github.com)

Cool. Good to hear!

Cool. Good to hear!
ocornut commented 2017-10-24 18:25:29 +00:00 (Migrated from github.com)

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
IMGUI_DISABLE_WIN32_DEFAULT_CLIPBOARD_FUNCS became IMGUI_DISABLE_WIN32_DEFAULT_CLIPBOARD_FUNCTIONS.
IMGUI_DISABLE_WIN32_DEFAULT_IME_FUNCS became IMGUI_DISABLE_WIN32_DEFAULT_IME_FUNCTIONS.

Very few people will be affected and they will likely get a link error and therefore will notice.

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 `IMGUI_DISABLE_WIN32_DEFAULT_CLIPBOARD_FUNCS` became `IMGUI_DISABLE_WIN32_DEFAULT_CLIPBOARD_FUNCTIONS`. `IMGUI_DISABLE_WIN32_DEFAULT_IME_FUNCS` became `IMGUI_DISABLE_WIN32_DEFAULT_IME_FUNCTIONS`. Very few people will be affected and they will likely get a link error and therefore will notice.
Sign in to join this conversation.
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
ocornut/imgui#238
No description provided.