tkem / fsmlite

Lightweight finite state machine framework for C++11
MIT License
156 stars 25 forks source link

Link errors with clang/LLVM (windows/VS2015) in player example. #6

Closed degski closed 8 years ago

degski commented 8 years ago

Compilation without errors, the following link errors arise:

1>------ Rebuild All started: Project: test, Configuration: Release x64 ------ 1>test_player_main.obj : error LNK2019: unresolved external symbol "public: static struct fsmlite::fsm<class player,int>::mem_fn_action<struct player::open_close,&private: void cdecl player::open_drawer(struct player::open_close const &)>::type fsmlite::fsm<class player,int>::mem_fn_action<struct player::open_close,&private: void cdecl player::open_drawer(struct player::open_close const &)>::value" (?value@?$mem_fn_action@Uopen_close@player@@$1?open_drawer@2@AEAAXAEBU12@@Z@?$fsm@Vplayer@@H@fsmlite@@2Utype@123@A) referenced in function "public: static void cdecl fsmlite::fsm<class player,int>::basic_row<0,struct player::open_close,1,struct fsmlite::fsm<class player,int>::mem_fn_action<struct player::open_close,&private: void cdecl player::open_drawer(struct player::open_close const &)>::type,&public: static struct fsmlite::fsm<class player,int>::mem_fn_action<struct player::open_close,&private: void cdecl player::open_drawer(struct player::open_close const &)>::type fsmlite::fsm<class player,int>::mem_fn_action<struct player::open_close,&private: void __cdecl player::open_drawer(struct player::open_close const &)>::value,struct fsmlite::fsm<class player,int>::no_guard::type,&public: static struct fsmlite::fsm<class player,int>::no_guard::type fsmlite::fsm<class player,int>::no_guard::value>::process_event(class player &,struct player::open_close const &)" (?process_event@?$basic_row@$0A@Uopen_close@player@@$00Utype@?$mem_fn_action@Uopen_close@player@@$1?open_drawer@2@AEAAXAEBU12@@Z@?$fsm@Vplayer@@H@fsmlite@@$1?value@456@2U3456@AU3?$no_guard@Uopen_close@player@@@56@$1?7856@2U3856@A@?$fsm@Vplayer@@H@fsmlite@@SAXAEAVplayer@@AEBUopen_close@4@@Z) 1>test_player_main.obj : error LNK2019: unresolved external symbol "public: static struct fsmlite::fsm<class player,int>::mem_fn_action<struct player::open_close,&private: void cdecl player::close_drawer(struct player::open_close const &)>::type fsmlite::fsm<class player,int>::mem_fn_action<struct player::open_close,&private: void cdecl player::close_drawer(struct player::open_close const &)>::value" (?value@?$mem_fn_action@Uopen_close@player@@$1?close_drawer@2@AEAAXAEBU12@@Z@?$fsm@Vplayer@@H@fsmlite@@2Utype@123@A) referenced in function "public: static void cdecl fsmlite::fsm<class player,int>::basic_row<1,struct player::open_close,2,struct fsmlite::fsm<class player,int>::mem_fn_action<struct player::open_close,&private: void cdecl player::close_drawer(struct player::open_close const &)>::type,&public: static struct fsmlite::fsm<class player,int>::mem_fn_action<struct player::open_close,&private: void __cdecl player::close_drawer(struct player::open_close const &)>::type fsmlite::fsm<class player,int>::mem_fn_action<struct player::open_close,&private: void cdecl player::close_drawer(struct player::open_close const &)>::value,struct fsmlite::fsm<class player,int>::no_guard::type,&public: static struct fsmlite::fsm<class player,int>::no_guard::type fsmlite::fsm<class player,int>::no_guard::value>::process_event(class player &,struct player::open_close const &)" (?process_event@?$basic_row@$00Uopen_close@player@@$01Utype@?$mem_fn_action@Uopen_close@player@@$1?close_drawer@2@AEAAXAEBU12@@Z@?$fsm@Vplayer@@H@fsmlite@@$1?value@456@2U3456@AU3?$no_guard@Uopen_close@player@@@56@$1?7856@2U3856@A@?$fsm@Vplayer@@H@fsmlite@@SAXAEAVplayer@@AEBUopen_close@4@@Z) 1>test_player_main.obj : error LNK2019: unresolved external symbol "public: static struct fsmlite::fsm<class player,int>::mem_fn_action<struct player::open_close,&private: void cdecl player::stop_and_open(struct player::open_close const &)>::type fsmlite::fsm<class player,int>::mem_fn_action<struct player::open_close,&private: void cdecl player::stop_and_open(struct player::open_close const &)>::value" (?value@?$mem_fn_action@Uopen_close@player@@$1?stop_and_open@2@AEAAXAEBU12@@Z@?$fsm@Vplayer@@H@fsmlite@@2Utype@123@A) referenced in function "public: static void cdecl fsmlite::fsm<class player,int>::basic_row<3,struct player::open_close,1,struct fsmlite::fsm<class player,int>::mem_fn_action<struct player::open_close,&private: void cdecl player::stop_and_open(struct player::open_close const &)>::type,&public: static struct fsmlite::fsm<class player,int>::mem_fn_action<struct player::open_close,&private: void cdecl player::stop_and_open(struct player::open_close const &)>::type fsmlite::fsm<class player,int>::mem_fn_action<struct player::open_close,&private: void __cdecl player::stop_and_open(struct player::open_close const &)>::value,struct fsmlite::fsm<class player,int>::no_guard::type,&public: static struct fsmlite::fsm<class player,int>::no_guard::type fsmlite::fsm<class player,int>::no_guard::value>::process_event(class player &,struct player::open_close const &)" (?process_event@?$basic_row@$02Uopen_close@player@@$00Utype@?$mem_fn_action@Uopen_close@player@@$1?stop_and_open@2@AEAAXAEBU12@@Z@?$fsm@Vplayer@@H@fsmlite@@$1?value@456@2U3456@AU3?$no_guard@Uopen_close@player@@@56@$1?7856@2U3856@A@?$fsm@Vplayer@@H@fsmlite@@SAXAEAVplayer@@AEBUopen_close@4@@Z) 1>test_player_main.obj : error LNK2019: unresolved external symbol "public: static struct fsmlite::fsm<class player,int>::mem_fn_action<struct player::cd_detected,&private: void cdecl player::store_cd_info(struct player::cd_detected const &)>::type fsmlite::fsm<class player,int>::mem_fn_action<struct player::cd_detected,&private: void cdecl player::store_cd_info(struct player::cd_detected const &)>::value" (?value@?$mem_fn_action@Ucd_detected@player@@$1?store_cd_info@2@AEAAXAEBU12@@Z@?$fsm@Vplayer@@H@fsmlite@@2Utype@123@A) referenced in function "public: static void cdecl fsmlite::fsm<class player,int>::basic_row<2,struct player::cd_detected,0,struct fsmlite::fsm<class player,int>::mem_fn_action<struct player::cd_detected,&private: void cdecl player::store_cd_info(struct player::cd_detected const &)>::type,&public: static struct fsmlite::fsm<class player,int>::mem_fn_action<struct player::cd_detected,&private: void cdecl player::store_cd_info(struct player::cd_detected const &)>::type fsmlite::fsm<class player,int>::mem_fn_action<struct player::cd_detected,&private: void cdecl player::store_cd_info(struct player::cd_detected const &)>::value,struct fsmlite::fsm<class player,int>::no_guard::type,&public: static struct fsmlite::fsm<class player,int>::no_guard::type fsmlite::fsm<class player,int>::no_guard::value>::process_event(class player &,struct player::cd_detected const &)" (?process_event@?$basic_row@$01Ucd_detected@player@@$0A@Utype@?$mem_fn_action@Ucd_detected@player@@$1?store_cd_info@2@AEAAXAEBU12@@Z@?$fsm@Vplayer@@H@fsmlite@@$1?value@456@2U3456@AU3?$no_guard@Ucd_detected@player@@@56@$1?7856@2U3856@A@?$fsm@Vplayer@@H@fsmlite@@SAXAEAVplayer@@AEBUcd_detected@4@@Z) 1>test_player_main.obj : error LNK2019: unresolved external symbol "public: static struct fsmlite::fsm<class player,int>::mem_fn_action<struct player::play,&private: void cdecl player::start_playback(struct player::play const &)>::type fsmlite::fsm<class player,int>::mem_fn_action<struct player::play,&private: void cdecl player::start_playback(struct player::play const &)>::value" (?value@?$mem_fn_action@Uplay@player@@$1?start_playback@2@AEAAXAEBU12@@Z@?$fsm@Vplayer@@H@fsmlite@@2Utype@123@A) referenced in function "public: static void cdecl fsmlite::fsm<class player,int>::basic_row<0,struct player::play,3,struct fsmlite::fsm<class player,int>::mem_fn_action<struct player::play,&private: void cdecl player::start_playback(struct player::play const &)>::type,&public: static struct fsmlite::fsm<class player,int>::mem_fn_action<struct player::play,&private: void __cdecl player::start_playback(struct player::play const &)>::type fsmlite::fsm<class player,int>::mem_fn_action<struct player::play,&private: void cdecl player::start_playback(struct player::play const &)>::value,struct fsmlite::fsm<class player,int>::no_guard::type,&public: static struct fsmlite::fsm<class player,int>::no_guard::type fsmlite::fsm<class player,int>::no_guard::value>::process_event(class player &,struct player::play const &)" (?process_event@?$basic_row@$0A@Uplay@player@@$02Utype@?$mem_fn_action@Uplay@player@@$1?start_playback@2@AEAAXAEBU12@@Z@?$fsm@Vplayer@@H@fsmlite@@$1?value@456@2U3456@AU3?$no_guard@Uplay@player@@@56@$1?7856@2U3856@A@?$fsm@Vplayer@@H@fsmlite@@SAXAEAVplayer@@AEBUplay@4@@Z) 1>test_player_main.obj : error LNK2019: unresolved external symbol "public: static struct fsmlite::fsm<class player,int>::mem_fn_action<struct player::play,&private: void cdecl player::resume_playback(struct player::play const &)>::type fsmlite::fsm<class player,int>::mem_fn_action<struct player::play,&private: void cdecl player::resume_playback(struct player::play const &)>::value" (?value@?$mem_fn_action@Uplay@player@@$1?resume_playback@2@AEAAXAEBU12@@Z@?$fsm@Vplayer@@H@fsmlite@@2Utype@123@A) referenced in function "public: static void cdecl fsmlite::fsm<class player,int>::basic_row<4,struct player::play,3,struct fsmlite::fsm<class player,int>::mem_fn_action<struct player::play,&private: void cdecl player::resume_playback(struct player::play const &)>::type,&public: static struct fsmlite::fsm<class player,int>::mem_fn_action<struct player::play,&private: void cdecl player::resume_playback(struct player::play const &)>::type fsmlite::fsm<class player,int>::mem_fn_action<struct player::play,&private: void __cdecl player::resume_playback(struct player::play const &)>::value,struct fsmlite::fsm<class player,int>::no_guard::type,&public: static struct fsmlite::fsm<class player,int>::no_guard::type fsmlite::fsm<class player,int>::no_guard::value>::process_event(class player &,struct player::play const &)" (?process_event@?$basic_row@$03Uplay@player@@$02Utype@?$mem_fn_action@Uplay@player@@$1?resume_playback@2@AEAAXAEBU12@@Z@?$fsm@Vplayer@@H@fsmlite@@$1?value@456@2U3456@AU3?$no_guard@Uplay@player@@@56@$1?7856@2U3856@A@?$fsm@Vplayer@@H@fsmlite@@SAXAEAVplayer@@AEBUplay@4@@Z) 1>test_player_main.obj : error LNK2019: unresolved external symbol "public: static struct fsmlite::fsm<class player,int>::mem_fn_action<struct player::pause,&private: void cdecl player::pause_playback(struct player::pause const &)>::type fsmlite::fsm<class player,int>::mem_fn_action<struct player::pause,&private: void cdecl player::pause_playback(struct player::pause const &)>::value" (?value@?$mem_fn_action@Upause@player@@$1?pause_playback@2@AEAAXAEBU12@@Z@?$fsm@Vplayer@@H@fsmlite@@2Utype@123@A) referenced in function "public: static void cdecl fsmlite::fsm<class player,int>::basic_row<3,struct player::pause,4,struct fsmlite::fsm<class player,int>::mem_fn_action<struct player::pause,&private: void cdecl player::pause_playback(struct player::pause const &)>::type,&public: static struct fsmlite::fsm<class player,int>::mem_fn_action<struct player::pause,&private: void __cdecl player::pause_playback(struct player::pause const &)>::type fsmlite::fsm<class player,int>::mem_fn_action<struct player::pause,&private: void cdecl player::pause_playback(struct player::pause const &)>::value,struct fsmlite::fsm<class player,int>::no_guard::type,&public: static struct fsmlite::fsm<class player,int>::no_guard::type fsmlite::fsm<class player,int>::no_guard::value>::process_event(class player &,struct player::pause const &)" (?process_event@?$basic_row@$02Upause@player@@$03Utype@?$mem_fn_action@Upause@player@@$1?pause_playback@2@AEAAXAEBU12@@Z@?$fsm@Vplayer@@H@fsmlite@@$1?value@456@2U3456@AU3?$no_guard@Upause@player@@@56@$1?7856@2U3856@A@?$fsm@Vplayer@@H@fsmlite@@SAXAEAVplayer@@AEBUpause@4@@Z) 1> LINK : MSIL .netmodule or module compiled with /GL found; restarting link with /LTCG; add /LTCG to the link command line to improve linker performance 1>test_player_main.obj : error LNK2001: unresolved external symbol "public: static struct fsmlite::fsm<class player,int>::mem_fn_action<struct player::open_close,&private: void cdecl player::open_drawer(struct player::open_close const &)>::type fsmlite::fsm<class player,int>::mem_fn_action<struct player::open_close,&private: void __cdecl player::open_drawer(struct player::open_close const &)>::value" (?value@?$mem_fn_action@Uopen_close@player@@$1?open_drawer@2@AEAAXAEBU12@@Z@?$fsm@Vplayer@@H@fsmlite@@2Utype@123@A) 1>test_player_main.obj : error LNK2001: unresolved external symbol "public: static struct fsmlite::fsm<class player,int>::mem_fn_action<struct player::open_close,&private: void cdecl player::close_drawer(struct player::open_close const &)>::type fsmlite::fsm<class player,int>::mem_fn_action<struct player::open_close,&private: void cdecl player::close_drawer(struct player::open_close const &)>::value" (?value@?$mem_fn_action@Uopen_close@player@@$1?close_drawer@2@AEAAXAEBU12@@Z@?$fsm@Vplayer@@H@fsmlite@@2Utype@123@A) 1>test_player_main.obj : error LNK2001: unresolved external symbol "public: static struct fsmlite::fsm<class player,int>::mem_fn_action<struct player::open_close,&private: void cdecl player::stop_and_open(struct player::open_close const &)>::type fsmlite::fsm<class player,int>::mem_fn_action<struct player::open_close,&private: void cdecl player::stop_and_open(struct player::open_close const &)>::value" (?value@?$mem_fn_action@Uopen_close@player@@$1?stop_and_open@2@AEAAXAEBU12@@Z@?$fsm@Vplayer@@H@fsmlite@@2Utype@123@A) 1>test_player_main.obj : error LNK2001: unresolved external symbol "public: static struct fsmlite::fsm<class player,int>::mem_fn_action<struct player::cd_detected,&private: void cdecl player::store_cd_info(struct player::cd_detected const &)>::type fsmlite::fsm<class player,int>::mem_fn_action<struct player::cd_detected,&private: void cdecl player::store_cd_info(struct player::cd_detected const &)>::value" (?value@?$mem_fn_action@Ucd_detected@player@@$1?store_cd_info@2@AEAAXAEBU12@@Z@?$fsm@Vplayer@@H@fsmlite@@2Utype@123@A) 1>test_player_main.obj : error LNK2001: unresolved external symbol "public: static struct fsmlite::fsm<class player,int>::mem_fn_action<struct player::play,&private: void cdecl player::start_playback(struct player::play const &)>::type fsmlite::fsm<class player,int>::mem_fn_action<struct player::play,&private: void cdecl player::start_playback(struct player::play const &)>::value" (?value@?$mem_fn_action@Uplay@player@@$1?start_playback@2@AEAAXAEBU12@@Z@?$fsm@Vplayer@@H@fsmlite@@2Utype@123@A) 1>test_player_main.obj : error LNK2001: unresolved external symbol "public: static struct fsmlite::fsm<class player,int>::mem_fn_action<struct player::play,&private: void cdecl player::resume_playback(struct player::play const &)>::type fsmlite::fsm<class player,int>::mem_fn_action<struct player::play,&private: void cdecl player::resume_playback(struct player::play const &)>::value" (?value@?$mem_fn_action@Uplay@player@@$1?resume_playback@2@AEAAXAEBU12@@Z@?$fsm@Vplayer@@H@fsmlite@@2Utype@123@A) 1>test_player_main.obj : error LNK2001: unresolved external symbol "public: static struct fsmlite::fsm<class player,int>::mem_fn_action<struct player::pause,&private: void cdecl player::pause_playback(struct player::pause const &)>::type fsmlite::fsm<class player,int>::mem_fn_action<struct player::pause,&private: void __cdecl player::pause_playback(struct player::pause const &)>::value" (?value@?$mem_fn_action@Upause@player@@$1?pause_playback@2@AEAAXAEBU12@@Z@?$fsm@Vplayer@@H@fsmlite@@2Utype@123@A) 1>x64\Release\test.exe : fatal error LNK1120: 7 unresolved externals ========== Rebuild All: 0 succeeded, 1 failed, 0 skipped ==========

tkem commented 8 years ago

I was able to reproduce this with clang 3.5.0, but only with -O0. No problems with -O2, that's why I didn't notice until now. Seems I completely forgot to add definitions for static value members, which get usually optimized away. Shame on me. I just added branch fix/6 which contains a quick workaround for this. Would be great if you could test this, so I know whether my assumptions are correct.

degski commented 8 years ago

Hi Thomas,

Thanks for reacting so quickly... I'll test and get back to you (probably tomorrow)...

You write "...which get usually optimized away...", probably, but need to be defined first, before they can get optimized away, I guess (or it seems)...

I'm on clang 3.9.0 as per http://llvm.org/builds/ .

Have a good day,

degski

On 19 February 2016 at 15:04, Thomas Kemmer notifications@github.com wrote:

I was able to reproduce this with clang 3.5.0, but only with -O0. No problems with -O2, that's why I didn't notice until now. Seems I completely forgot to add definitions for static value members, which get usually optimized away. Shame on me. I just added branch fix/6 which contains a quick workaround for this. Would be great if you could test this, so I know whether my assumptions are correct.

— Reply to this email directly or view it on GitHub https://github.com/tkem/fsmlite/issues/6#issuecomment-186205814.

degski commented 8 years ago

Hi Thomas,

Just tested. Works!

The changes to make_mem_fn_guard work with your new definition, but also with the "FIXME" one, I don't know how relevant this is, but clang gives the thumbs up on both.

VC14 can't make anything out it, but that's become irrelevant with the event of clang.

It this a final fix, or does it need some more work?

A good day again,

degski

On 19 February 2016 at 15:56, degski degski@gmail.com wrote:

Hi Thomas,

Thanks for reacting so quickly... I'll test and get back to you (probably tomorrow)...

You write "...which get usually optimized away...", probably, but need to be defined first, before they can get optimized away, I guess (or it seems)...

I'm on clang 3.9.0 as per http://llvm.org/builds/ .

Have a good day,

degski

On 19 February 2016 at 15:04, Thomas Kemmer notifications@github.com wrote:

I was able to reproduce this with clang 3.5.0, but only with -O0. No problems with -O2, that's why I didn't notice until now. Seems I completely forgot to add definitions for static value members, which get usually optimized away. Shame on me. I just added branch fix/6 which contains a quick workaround for this. Would be great if you could test this, so I know whether my assumptions are correct.

— Reply to this email directly or view it on GitHub https://github.com/tkem/fsmlite/issues/6#issuecomment-186205814.

tkem commented 8 years ago

Thanks for testing so quickly! This definitely needs some more work/thinking, but if it works for you, I guess it's good enough for a v0.2.0 (which means this is far from "production-ready", mind you). As for VC++, there's #3, which I haven't gotten around to. Much other stuff to do nowadays, some even paying the rent ;-) I guess I'll find some time to merge this into master branch and tag as v0.2.0 by next week.

degski commented 8 years ago

Hi Thomas,

As to #3, I'm happy to whip up something, but for the moment VC14 is not yet up to scratch, or it will need some work-arounds from your end. I wouldn't put much effort in that, they [M$] are working hard on compliance and it's coming, but it takes time. Clang/LLVM is much faster though (with all the benefits of clang), so for my part it's a past station, the train has left.

I'll keep an eye out on your progress and will report back if things don't go to plan.

Have a good day,

degski

On 19 February 2016 at 17:23, Thomas Kemmer notifications@github.com wrote:

Thanks for testing so quickly! This definitely needs some more work/thinking, but if it works for you, I guess it's good enough for a v0.2.0 (which means this is far from "production-ready", mind you). As for VC++, there's #3 https://github.com/tkem/fsmlite/issues/3, which I haven't gotten around to. Much other stuff to do nowadays, some even paying the rent ;-) I guess I'll find some time to merge this into master branch and tag as v0.2.0 by next week.

— Reply to this email directly or view it on GitHub https://github.com/tkem/fsmlite/issues/6#issuecomment-186258519.

tkem commented 8 years ago

Thanks for the hint about VC/Clang. Wasn't planning to do much about it for now, so I might just close this and state prominently that this won't work with VC14, thanks to your efforts.

tkem commented 8 years ago

@degski: BTW, "starring" or "watching" this project in GitHub will make it easier for you to follow. It may also help attract more people, which will lead to better code quality, as we just saw ;-) Just noticed you're new to GitHub, thanks for creating an account!