1

I am new to SystemC and I just compiled it for using it with VS2010 using this tutorial. But when I tried to debug the following program:

#include <systemc.h>

SC_MODULE (systemcTest) {
SC_CTOR (systemcTest) {

}
void say_hello() {
    cout << "Hello World.\n";
}
};
int sc_main(int argc, char* argv[]) {
systemcTest hello("HELLO");
hello.say_hello();
return(0);
}

I got 51 errors similar to the following error:

error LNK2005: "public: void __thiscall std::basic_ios<char,struct std::char_traits<char> >::setstate(int,bool)" (?setstate@?$basic_ios@DU?$char_traits@D@std@@@std@@QAEXH_N@Z) already defined in SystemC.lib(sc_simcontext.obj) \msvcprtd.lib(MSVCP100D.dll)

Most were related to msvcprtd.lib, libcmtd.lib. How to solve this issue ?

Animesh Pandey
  • 5,900
  • 13
  • 64
  • 130

1 Answers1

1

This is mostly related to the different MS runtime libraries used for project used for compiling the SystemC library (SystemC.lib) and your SystemC project. With MS compiler, there are 4 different runtime libraries:

  • Multithreaded (/MT) --> LIBCMT.lib
  • Multithreaded-Debug (/MTd) --> LIBCMTD.lib
  • Multithreaded-DLL (/MD) --> MSVCRT.lib,MSVCPRT.lib + MSVCR100.DLL,MSVCP100.DLL
  • Multithreaded-Debug-DLL (/MDd) --> MSVCRTD.lib,MSVCPRTD.lib + MSVCR100D.DLL,MSVCP100D.DLL

It seems that you used /MDd to compile your SystemC.lib, but you are using /MTd to compile your SystemC project. You can correct it:

From the Property Pages select Configuration Properties ==> C/C++ ==> Code Generation ==> Runtime Library ==> Multithreaded-Debug-DLL (/MDd).

A similar thread can be found here: Linker errors between multiple projects in Visual C++

Community
  • 1
  • 1
kenny-liu
  • 309
  • 2
  • 8