Navaneet kumar Posted January 24, 2020 Report Share Posted January 24, 2020 Hi, I have written a very simple sc_module and created a dll library (libmodule.dll and .lib) for the same under cygwin using msvc cmdline (corresponding to visual studio 2015). I then link this module with a sc_main program, which calls module constructor. As soon as the program is executed, I get this error: Error: (E533) module name stack is empty: did you forget to add a sc_module_name parameter to your module constructor? In file: ..\..\src\sysc\kernel\sc_object_manager.cpp:373 What could be the issue? Here is example source code: // Module.h class DLL_API myclass : public sc_core::sc_module { public: myclass(sc_core::sc_module_name name) ; void display(); }; // Module.cpp myclass::myclass(sc_core::sc_module_name name) : sc_core::sc_module(name) { std::cout << "Inside cons\n"; } void myclass::display() { std::cout << "Calling display\n"; } // DLL_API is defined as #ifdef DLL_EXPORT #define DLL_API __declspec(dllexport) #else #define DLL_API __declspec(dllimport) #endif // Main program int sc_main(int argc, char * argv[]) { myclass obj("myclass"); obj.display(); return 0; } //Compilation cmds cl /MD /EHsc /D DLL_EXPORT /I "C:\external_dep\systemc-2.3.1\src" -c Module.cpp link /SUBSYSTEM:WINDOWS /INCREMENTAL:NO /NOLOGO /DLL /OPT:REF /OPT:ICF /DYNAMICBASE:NO /NXCOMPAT /MACHINE:"X64" /LIBPATH:"C:\external_dep\systemc-2.3.1\msvc80\SystemC\x64\Release" /OUT:"libmodule.dll" SystemC.lib Module.obj cl /MD /EHsc /D DLL_EXPORT /I "C:\external_dep\systemc-2.3.1\src" -c sc_main.cpp link /SUBSYSTEM:CONSOLE /LIBPATH:"C:\external_dep\systemc-2.3.1\msvc80\SystemC\x64\Release" SystemC.lib libmodule.lib sc_main.obj ./sc_main.exe <- running this gives above error Surprisingly, when I move Module constructor body from Module.cpp to Module.h, the error goes away. Quote Link to comment Share on other sites More sharing options...
Roman Popov Posted January 24, 2020 Report Share Posted January 24, 2020 Do you have SystemC compiled as DLL? Otherwise you have same issue as described here : https://forums.accellera.org/topic/6540-inserting-existing-software-into-tlm-frame/ Quote Link to comment Share on other sites More sharing options...
Navaneet kumar Posted January 27, 2020 Author Report Share Posted January 27, 2020 I am compiling SystemC as static library (.lib). That's what is getting linked everywhere. Do you still think that can be issue? Quote Link to comment Share on other sites More sharing options...
maehne Posted January 28, 2020 Report Share Posted January 28, 2020 As you are already building your SystemC model using DLLs, I would suggest that you also build SystemC as a DLL and link to it. This most probably should fix your problem as suggested by @Roman Popov. Quote Link to comment Share on other sites More sharing options...
Navaneet kumar Posted January 30, 2020 Author Report Share Posted January 30, 2020 When I built SystemC as a DLL, it resolved all the issues. Thanks! 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.