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

LNK2005 error of boost::archive::codecvt_null<wchar_t> #232

Open
Mitsuhiko-Matsukawa opened this issue Apr 19, 2021 · 8 comments
Open

LNK2005 error of boost::archive::codecvt_null<wchar_t> #232

Mitsuhiko-Matsukawa opened this issue Apr 19, 2021 · 8 comments

Comments

@Mitsuhiko-Matsukawa
Copy link

When I use boost/archive/xml_wiarchive.hpp in dll and exe together, LNK2005 error occurs.
boost 1_76_0, Visual Studio 2019

LNK2005_codecvt_null.zip

Please download and put as below.
boost_1_76_0
-boost
-stage
--x64
--x86
LNK2005_codecvt_null
-LNK2005_codecvt_null.sln

@Mitsuhiko-Matsukawa
Copy link
Author

@robertramey
If I revert these files before Jun 19, 2020, my test code works.

  • serialization/include/boost/archive/codecvt_null.hpp
  • serialization/src/codecvt_null.cpp

@Mitsuhiko-Matsukawa
Copy link
Author

@robertramey
If I revert commit 812ef99 from master branch, my test code works.

@AdmiralPellaeon
Copy link

AdmiralPellaeon commented Feb 15, 2022

@Mitsuhiko-Matsukawa I have the same issues. I tried your workaround for boost 1.78.0, but this leads to a different linker error. Did you already test it with the newest boost version?
Atm I try to use boost with shared linking to overcome with this problem. But I would prefer to link it statically how I did it all the time before.

@robertramey
Copy link
Member

what is the current status on this? I've tested extensively with both static and shared linking with no problems.

@Mitsuhiko-Matsukawa
Copy link
Author

@robertramey @AdmiralPellaeon
This issue still exists on boost1.80.0 + Visual Studio 2019.

I have applied this patch and the problem has been resolved.
#240

The idea of this patch is simple.
Move implementations from cpp to hpp so that they will be inline and linker error doesn't occur.

@robertramey
Why did you move them from hpp to cpp? Is there a good point to do that?

@robertramey
Copy link
Member

I'm still trying to understand what's going on here. When you "move" this implementation, do you rebuild the libraries when you verify that "it works".

@Mitsuhiko-Matsukawa
Copy link
Author

@robertramey
Have you downloaded this file and tried to build?

When you "move" this implementation, do you rebuild the libraries when you verify that "it works".

Yes, I have rebuilt the libraries and succeeded to link to my test code.
My test code fails to link before I move but succeeds after I move.
I have tested only for Visual Studio 2019. It might be error for other platforms. In that case, we should switch by preprocessor.
This issue still exists on 1.81.0.

@oicchris
Copy link

Hi! I ran into the same link error and saw this open issue. I just wanted to comment, adding the boost_serialization-vc140-mt.lib to my build fixed the link error. Library was provided by vcpkg, boost v1.81.0 shared library. I hope that solves your issue as well!

svigerske added a commit to scip-ci/scipoptsuite-feedstock that referenced this issue Nov 5, 2024
svigerske added a commit to scip-ci/scipoptsuite-feedstock that referenced this issue Nov 5, 2024
svigerske added a commit to scip-ci/scipoptsuite-feedstock that referenced this issue Nov 6, 2024
svigerske added a commit to scip-ci/scipoptsuite-feedstock that referenced this issue Nov 6, 2024
svigerske added a commit to scip-ci/scipoptsuite-feedstock that referenced this issue Nov 9, 2024
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

4 participants