ViVo Posted August 29, 2017 Report Share Posted August 29, 2017 Hi, i'm getting "error LNK2019: unresolved external symbol " for method well defined (as fat as i can tell..). the only difference from other blocks is the template of the module (so what??). the outline of the code is supplemented. hope someone can shade some light... V 1> Generating Code... 1>main.obj : error LNK2019: unresolved external symbol "public: void __thiscall lzd_unit<48,3>::thread0(void)" (?thread0@?$lzd_unit@$0DA@$02@@QAEXXZ) referenced in function "public: __thiscall lzd_unit<48,3>::lzd_unit<48,3>(class sc_core::sc_module_name)" (??0?$lzd_unit@$0DA@$02@@QAE@Vsc_module_name@sc_core@@@Z) 1>C:\workarea\Projects\SystemC\libs\awgn\lzd_unit\Debug\lzd_unit.exe : fatal error LNK1120: 1 unresolved externals ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ========== lzd_unit.h ___________ template <unsigned in_width, unsigned x_pe16> SC_MODULE(lzd_unit) { ... ... void thread0(void); SC_CTOR(lzd_unit) : pin_ext("pin"), vin("vin"), pout_ext("pout"), vout("vout") { SC_METHOD(thread0) ; sensitive << pin_ext ; ... ... } } lzd_unit.cpp ___________ template <unsigned in_width, unsigned x_pe16> void lzd_unit<in_width, x_pe16>::thread0(void) { ... } Quote Link to comment Share on other sites More sharing options...
Philipp A Hartmann Posted August 29, 2017 Report Share Posted August 29, 2017 You might want to read this "C++ Super FAQ" entry: https://isocpp.org/wiki/faq/templates#templates-defn-vs-decl Hope that helps, Philipp maehne 1 Quote Link to comment Share on other sites More sharing options...
ViVo Posted August 29, 2017 Author Report Share Posted August 29, 2017 Hi Philipp, thank you for promptly responding. as it is, i read this web page top to bottom, i still could not figure out the problem. i comment out the declaration SC_METHOD(thread0) and the compiler succeeded .. so the declaration is the problem? how can i distinguish between METHOD, THREAD and CTHREAD without this macro.. obviously, i have no clue what is going on here.. V Quote Link to comment Share on other sites More sharing options...
Roman Popov Posted August 29, 2017 Report Share Posted August 29, 2017 If you put template <unsigned in_width, unsigned x_pe16> void lzd_unit<in_width, x_pe16>::thread0(void) { ... } in lzd_unit.h instead of lzd_unit.cpp Does this fix the error? Quote Link to comment Share on other sites More sharing options...
ViVo Posted August 29, 2017 Author Report Share Posted August 29, 2017 Hi Roman, Yes. it builds successfully. but then it becomes inline.. is it mandatory to make it so? V Quote Link to comment Share on other sites More sharing options...
Roman Popov Posted August 29, 2017 Report Share Posted August 29, 2017 1 minute ago, ViVo said: Hi Roman, Yes. it builds successfully. but then it becomes inline.. is it mandatory to make it so? No, inlining should not be mandatory https://gcc.gnu.org/onlinedocs/gcc-3.1/gcc/Template-Instantiation.html Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.