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

Getting " error LNK2005" on Windows #50

Open
gegles opened this issue Nov 4, 2019 · 4 comments
Open

Getting " error LNK2005" on Windows #50

gegles opened this issue Nov 4, 2019 · 4 comments

Comments

@gegles
Copy link
Contributor

gegles commented Nov 4, 2019

In my project, I checkout spdlog & spdlog_setup as submodules and use add_subdirectory to add them to my project. This works fine on all platforms, but on Windows I get:

spdlogd.lib(fmt.obj) : error LNK2005: "public: void __cdecl fmt::v6::internal::error_handler::on_error(char const *)" (?on_error@error_handler@internal@v6@fmt@@QEAAXPEBD@Z) already define
d in gateway_main.obj [C:\Users\gegles\Workspaces\ibm\fasp.io\_builds\windows-vs\cpp\gateway\fasp.io-gateway.vcxproj]
spdlogd.lib(fmt.obj) : error LNK2005: "public: virtual __cdecl fmt::v6::format_error::~format_error(void)" (??1format_error@v6@fmt@@UEAA@XZ) already defined in gateway_main.obj [C:\Users\
gegles\Workspaces\ibm\fasp.io\_builds\windows-vs\cpp\gateway\fasp.io-gateway.vcxproj]
C:\Users\gegles\Workspaces\ibm\fasp.io\_builds\windows-vs\bin\Debug\fasp.io-gateway.exe : fatal error LNK1169: one or more multiply defined symbols found [C:\Users\gegles\Workspaces\ibm\f
asp.io\_builds\windows-vs\cpp\gateway\fasp.io-gateway.vcxproj]

I've tried different things (e.g. checkout fmt also as a submodule and use SPDLOG_FMT_EXTERNAL) but I get the same error.

Any thoughts?

@gegles
Copy link
Contributor Author

gegles commented Nov 4, 2019

This is an excerpt of my 3rdparty/CMakeLists.txt:

  ### spdlog
  option(SPDLOG_INSTALL "" ON)
  add_subdirectory(spdlog)
  set_target_properties(spdlog PROPERTIES FOLDER 3rdparty)

  ### spdlog_setup
  option(SPDLOG_SETUP_CPPTOML_EXTERNAL "Use external CPPTOML library instead of bundled" ON)
  add_subdirectory(spdlog_setup)

All I do then is #include <spdlog_setup/conf.h> in my main.cpp.

@gegles
Copy link
Contributor Author

gegles commented Nov 4, 2019

Even though I don't refer to any spdlog:: in main.cpp, I had to also include spdlog.h for it to work:

#include <spdlog/spdlog.h>
#include <spdlog_setup/conf.h>

So, not sure if this is still a bug....

@guangie88
Copy link
Owner

Seems like libfmt has been somehow inlined more than once.

May I know the tag/commit versions of spdlog and spdlog_setup that you are using?

@gegles
Copy link
Contributor Author

gegles commented Nov 19, 2019

I was just able to repro this again with the latest of both projects:

 79259fdb3f57283f65185a8e41840968dae4043c 3rdparty/spdlog (v1.2.1-1017-g79259fdb)
 ebfbb0754bd194ff9417b395306acbcdf67caf4d 3rdparty/spdlog_setup (v0.3.0-1-gebfbb07)

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