Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: ImGui-SFML linker errors (impervious to all advice)  (Read 1130 times)

0 Members and 1 Guest are viewing this topic.

alcmd

  • Newbie
  • *
  • Posts: 2
    • View Profile
ImGui-SFML linker errors (impervious to all advice)
« on: January 18, 2024, 06:02:41 pm »
Alright, I've read two dozen threads with this exact same problem in this forum, but none of the advice that helped other posters has helped me, and I'm at my wit's end. I'm just running a test project only to get ImGui-SFML working. ImGui and SFML seem to be working in the project on their own, but I'm getting linker errors on all ImGui-SFML functions called in my test code. (It's simple test code that runs fine when the ImGui-SFML functions are commented out.)

Code is from Elias Daler's blog: https://edw.is/using-imgui-with-sfml-pt1/
I followed all instructions from his Option C "manual integration" for install.



Things I have tried or verified:
  • opengl32.lib is added to the linker input
  • so are all the sfml .dlls as recommended in a video (sfml-system-s-d, sfml-window-s-d etc)
  • I am using SFML_STATIC in the preprocessor
  • SFML version is the same as the C++ version used in my project (17)
  • I copied the #includes and defines from imconfig-sfml.h into imconfig.h as recommended
  • I changed the #included files between using double quotes and angle brackets (some people said this helped, not for me)
  • I added the ImGui-SFML source code location to the Additional Include Directories
  • I simply included the ImGui-SFML .cpps and .hs in my project directory

In various threads, some of this advice fixed the linker errors for the OPs, but none of it has worked for me.

I'm using Win10, Visual Studio 2022 and MSVC as eventually this needs to be a Windows app. The only advice I found that I haven't acted on is to compile and build it separately, and link against the project. That shouldn't be necessary in this case, right? Is that best practice? I'm fairly new to this so if anyone knows differently please let me know.

Any advice welcome. Thanks.
« Last Edit: January 18, 2024, 06:05:29 pm by alcmd »

kojack

  • Sr. Member
  • ****
  • Posts: 343
  • C++/C# game dev teacher.
    • View Profile
Re: ImGui-SFML linker errors (impervious to all advice)
« Reply #1 on: January 18, 2024, 10:45:10 pm »
The errors are saying that the linker can't find the functions that should be implemented by imgui-sfml.cpp.
If using imgui as a library, then it could be that the library isn't being linked correctly.
If adding imgui directly to your project, the file imgui-sfml.cpp isn't being built.

When you say "I simply included the ImGui-SFML .cpps and .hs in my project directory" did you also add those files to the project within visual studio using the "Add / Existing Item..." menu? Putting cpps in a directory doesn't make them get built, you have to explicitly tell Visual Studio you want to use them. They should appear in the Solution Explorer panel as part of the project.

alcmd

  • Newbie
  • *
  • Posts: 2
    • View Profile
Re: ImGui-SFML linker errors (impervious to all advice)
« Reply #2 on: January 20, 2024, 05:08:55 am »
Thanks for your response. Yes, I had put them in a subfolder and included it to the project as was recommended in a video, and they were part of the solution. I just started my IDE this morning and the linker errors were gone, and my simple test project ran on the original settings I'd set up with a video tutorial but which didn't work originally. Lmao.

All I can say on the original library linker errors is keep trying y'all, eventually you'll wake up one day and it works. I tried everything. Closing Visual Studio worked more than anything else!

 

anything