mio icon indicating copy to clipboard operation
mio copied to clipboard

Linker errors when using latest mio

Open pps83 opened this issue 2 years ago • 2 comments

After updating to latest mio I'm getting linker errors all over the place. I didn't have these with older mio.

These are the linker errors:

3>common.lib(compressed_reader.obj) : error LNK2005: "class std::basic_string<wchar_t,struct std::char_traits<wchar_t>,class std::allocator<wchar_t> > __cdecl mio::detail::win::s_2_ws(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (?s_2_ws@win@detail@mio@@YA?AV?$basic_string@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@AEBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@5@@Z) already defined in common.lib(DataSource.obj)
4>common.lib(compressed_reader.obj) : error LNK2005: "class std::basic_string<wchar_t,struct std::char_traits<wchar_t>,class std::allocator<wchar_t> > __cdecl mio::detail::win::s_2_ws(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (?s_2_ws@win@detail@mio@@YA?AV?$basic_string@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@AEBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@5@@Z) already defined in common.lib(DataSource.obj)
5>common.lib(DataSource.obj) : error LNK2005: "class std::basic_string<wchar_t,struct std::char_traits<wchar_t>,class std::allocator<wchar_t> > __cdecl mio::detail::win::s_2_ws(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (?s_2_ws@win@detail@mio@@YA?AV?$basic_string@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@AEBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@5@@Z) already defined in common.lib(compressed_reader.obj)

pps83 avatar May 07 '22 20:05 pps83

@mandreyel ^^^ please merge

pps83 avatar May 07 '22 21:05 pps83

plz

p-groarke avatar May 10 '22 01:05 p-groarke

bump

Green-Sky avatar Jan 16 '23 14:01 Green-Sky

bump @mandreyel

dudantas avatar Feb 15 '23 12:02 dudantas

Thanks for the reminder, I haven't been active here. I'm no longer using windows, I'll ask a friend if he could verify this PR. If not, I'll merge it in good faith.

I'd also be open to hand out maintenance rights of this repo to someone who's interested in it as I don't have the capacity to maintain it anymore.

vimpunk avatar Mar 02 '23 15:03 vimpunk

@mandreyel You can merge the PR, it's good. I wish you mentioned that a few months ago, I may have stepped up to the plate :) In the end I wrote my own small mmap object (much less fancy than yours i'll say).

I hope you find someone to maintain this lib! take care

edit : Apparently it's not a pr? Anyhow, you just need to mark the 2 functions inline. On VS, non-templated "free functions" implemented in headers must be marked inline for the linker. I'm unsure why it compiles on clang / gcc but eh.

p-groarke avatar Mar 02 '23 16:03 p-groarke

That's the PR that closes the issue: https://github.com/mandreyel/mio/pull/88 the PR fixes a few issues in the code. It didn't have inline to avoid linker errors, it didn't have #include <vector> because vector was used. Also, on top of that, these changes had to be done in mmap.ipp and in mio.hpp files.

My PR updates s_2_ws so that it doesn't use intermediate vector, but writes directly to preallocated wstring.

pps83 avatar Mar 02 '23 22:03 pps83

Yep, my bad, I had meant to comment on #88 rather than this issue. Either way, it's merged now, thanks everyone for the patience.

I'll put up a notice about looking for a maintainer shortly. I hadn't realized this lib was used much at all...

vimpunk avatar Mar 03 '23 09:03 vimpunk

a very simple github ci script would have caught this. :)

I hadn't realized this lib was used much at all...

good/simple code just walks on its own :wink:

Green-Sky avatar Mar 03 '23 13:03 Green-Sky