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

Compiler error on Windows 7 #238

Closed
TimothyWrightSoftware opened this issue May 31, 2015 · 9 comments
Closed

Compiler error on Windows 7 #238

TimothyWrightSoftware opened this issue May 31, 2015 · 9 comments

Comments

@TimothyWrightSoftware
Copy link

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.

@ocornut
Copy link
Owner

ocornut commented May 31, 2015

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
Copy link
Author

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
Copy link
Owner

ocornut commented May 31, 2015

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
Copy link
Author

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 added a commit that referenced this issue May 31, 2015
… function (unless IMGUI_DISABLE_WIN32_DEFAULT_CLIPBOARD_FUNCS) #238
@ocornut
Copy link
Owner

ocornut commented May 31, 2015

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
Copy link
Author

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

@TimothyWrightSoftware
Copy link
Author

Thanks for the quick response!

@ocornut
Copy link
Owner

ocornut commented May 31, 2015

Cool. Good to hear!

ocornut added a commit that referenced this issue Oct 24, 2017
…32_DEFAULT_IME_FUNCS to IMGUI_DISABLE_WIN32_DEFAULT_CLIPBOARD_FUNCTIONS/IMGUI_DISABLE_WIN32_DEFAULT_IME_FUNCTIONS for consistency. (ref #238, #520, #738)
@ocornut
Copy link
Owner

ocornut commented Oct 24, 2017

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 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