-
November 17th, 2015, 04:16 PM
#1
Linker error with pure virtual function.
I am making a static library. when I try to use it in an application
I get following errors in MVS 2013:
error LNK2001: unresolved external symbol "private: virtual void __thiscall serial::ArduinoMessageParser:arse(class ATL::CStringT<wchar_t,class StrTraitMFC<wchar_t,class ATL::ChTraitsCRT<wchar_t> > >)" (?parse@ArduinoMessageParser@serial@@EAEXV?$CStringT@_WV?$StrTraitMFC@_WV?$ChTraitsCRT@_W@ATL@@@@@ATL@@@Z)
error LNK2001: unresolved external symbol "private: virtual void __thiscall serial::ArduinoMessageParser:arse(class ATL::CStringT<wchar_t,class StrTraitMFC<wchar_t,class ATL::ChTraitsCRT<wchar_t> > >)" (?parse@ArduinoMessageParser@serial@@EAEXV?$CStringT@_WV?$StrTraitMFC@_WV?$ChTraitsCRT@_W@ATL@@@@@ATL@@@Z)
error LNK2019: unresolved external symbol "protected: __thiscall serial::AbstractSerialParser::AbstractSerialParser(void)" (??0AbstractSerialParser@serial@@IAE@XZ) referenced in function "public: __thiscall serial::ArduinoMessageParser::ArduinoMessageParser(struct HWND__ *)" (??0ArduinoMessageParser@serial@@QAE@PAUHWND__@@@Z)
1>E:\Doc\Unterricht\CJ2\SerialComm_Arduino\Debug\ArduinoController.exe : fatal error LNK1120: 2 unresolved externals
relevant declarations in corresping files neglecting neseccary includes:
Code:
class AbstractSerialParser
{
protected:
virtual void parse(CString s)=0;
AbstractSerialParser();
public:
void operator()(const CString &serial_string){ std::thread(&AbstractSerialParser::parse, this, serial_string).detach(); }
virtual ~AbstractSerialParser(){};
};
Code:
class ArduinoMessageParser : public AbstractSerialParser
{
private:
HWND target_window;
virtual void parse(CString)override;
public:
ArduinoMessageParser() = delete;
ArduinoMessageParser(HWND h) :target_window(h){}
ArduinoMessageParser(const ArduinoMessageParser&) = default;
~ArduinoMessageParser(){};
Code:
void ArduinoMessageParser::parse(CString message)
{
///implementation for parser
}
I probably miss just a minor detail, but spent a few hours swithout fsuccedding to figure this out
-
December 3rd, 2015, 07:26 PM
#2
Re: Linker error with pure virtual function.
The error message from the linker refers to "ArduinoMessageParser:arse". Check your code to see if "parse" is misspelled somewhere.
-
December 4th, 2015, 02:36 AM
#3
Re: Linker error with pure virtual function.
The linker expects both classes to be defined in the namespace 'serial'. From the code you posted, it's not clear if you really defined the classes in this namespace.
-
December 4th, 2015, 03:20 AM
#4
Re: Linker error with pure virtual function.
Originally Posted by Prandr
Code:
void operator()(const CString &serial_string){ std::thread(&AbstractSerialParser::parse, this, serial_string).detach(); }
as a side note, you're probably using a non-standard implementation of std::thread here ( maybe, vs2013 implemented an early draft ? ) because destroying a detached std::thread will invoke std::terminate()...
-
December 4th, 2015, 03:32 AM
#5
Re: Linker error with pure virtual function.
Originally Posted by RichardDuNord
The error message from the linker refers to "ArduinoMessageParser:arse". Check your code to see if "parse" is misspelled somewhere.
The linker error message as displayed is not shown properly as some of the chars are displayed as an emotive. The correct error message contains
Code:
serial::ArduinoMessageParser::Parse(
All advice is offered in good faith only. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only - not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/ and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums - and not via private messages!
C++23 Compiler: Microsoft VS2022 (17.6.5)
-
December 4th, 2015, 08:16 AM
#6
Re: Linker error with pure virtual function.
in
Code:
class ArduinoMessageParser : public AbstractSerialParser
try changing
Code:
virtual void parse(CString)override;
to
Code:
virtual void parse(CString s )override;
any joy?
ahoodin
To keep the plot moving, that's why.
-
December 21st, 2015, 04:18 PM
#7
Re: Linker error with pure virtual function.
You all gussed wrong.
What really happened I stepped on the same rake as in the thread http://forums.codeguru.com/showthrea...rtual-function
this thread could be merged into it
-
December 23rd, 2015, 03:54 PM
#8
Re: Linker error with pure virtual function.
You could have kept that under your hat, but
maybe your not a self promoter.
ahoodin
To keep the plot moving, that's why.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|