SFML/imgui-sfml

Linking error

buridan1999 opened this issue · 15 comments

Get this error, while trying to link it was my project:

1>sfml-system-d.lib(sfml-system-d-2.dll) : error LNK2005: "public: __cdecl sf::String::~String(void)" (??1String@sf@@qeaa@XZ) alreay defined at ImGui-SFML.lib(imgui-SFML.obj)
1>D:\repos\rpg-pixelart\src\rpg-sfml\rpg-sfml\x64\Debug\rpg-sfml.exe : fatal error LNK1169:

OK, I guess you should try to solve it then 🤷

What IDE/build system are you using?
Looks like you're linking SFML twice - you don't need to explicitly link SFML if you link imgui-sfml because imgui-sfml already links to SFML.

It was my mistake, cause I try to link it with x86 version of SFML.
So i try to configur imgui-sfml cmake project again, and it can't find SFML if I give him x86 SFML.
But it work great with x64 version.

But why it can't link with x86...

cmake-log.txt

What IDE/build system are you using? Looks like you're linking SFML twice - you don't need to explicitly link SFML if you link imgui-sfml because imgui-sfml already links to SFML.

I use cmake + MSVC2022

This is more of an environment/IDE/build system problem than ImGui-SFML problem.
Try to get minimal SFML example to compile and then try to add ImGui-SFML to the mix.

Also try setting IMGUI_SFML_FIND_SFML to OFF

Set IMGUI_SFML_FIND_SFML to OFF.
Now he can't find header.

cmake-log.txt

I pass -DSFML_DIR=%SFML-Dir% to cmake command, but it's can't find SFML...

Are you able to compile basic SFML program without ImGui-SFML?
This all looks like general CMake/IDE problems and I don't want to provide support about basics such as these.

You can read my article about working with CMake and managing dependencies. It shows how to set up a project which uses SFML and ImGui-SFML.

@eliasdaler
Yea, i fix it.
But problem is in .lib file naming, cause it's do not have -d suffix in Debug configuration. Is it right?

It's here: https://github.com/eliasdaler/imgui-sfml/blob/master/CMakeLists.txt#L143
Why it setted only for (BUILD_SHARED_LIBS)?

Introduced and described here: #125
But it shouldn't be a problem if you link statically. I previously did static linking on Windows and it worked.

I use dynamic linking(

@eliasdaler I try to build it on ci\cd, and it's failed too... There are clear env
0.txt

Here such problem: #108

fix it with -BUILD_SHARED_LIBS=ON