jlison
March 17th, 2008, 11:10 AM
Here's my situation:
I have Visual Studio 2k3. There's an old C++ program I wrote that uses a command-line interface. I would like to upgrade this to a Visual Basic .NET app.
It seemed to me that the best way to do this is to take the old C++ classes, and write some mixed-mode wrapper classes around them. Then, I could make a VB.NET app that calls the mixed-mode classes. I'm running into some serious linking problems with my attempts at making these wrappers.
In an attempt to isolate these problems while removing most of the complexity, I've made a simple solution called LUE that replicates the general idea of what I'm trying to do, as well as all of the linking errors that occur when I try to do it.
First, there's a static library called ULUE. It consists of three classes written in unmanaged C++. It builds just fine.
Next, there's a CLI app called Earth. It calls functions from the classes in ULUE. It builds and runs just fine.
Next is a VB.NET app called Earth2. It's meant to be the successor to Earth. It *will* call functions from mixed-mode classes once they work. Until then, it won't work either.
Finally, there's a .NET library called MLUE. It consists of one class - a mixed-mode wrapper for one of the classes in ULUE.
Here's my current problem. One of the unmanaged classes is "Everything." One of its functions, multiply, has a local ifstream myFile (currently dormant, but I'll need it later). If I comment this out, everything builds fine. But when it's left in, ULUE builds and Earth work as expected, but MLUE seems to resent its inclusion and won't build. I get these link errors:
Linking...
LINK : warning LNK4075: ignoring '/EDITANDCONTINUE' due to '/INCREMENTAL:NO' specification
libcpmtd.lib(xlock.obj) : error LNK2005: "public: __thiscall std::_Lockit::_Lockit(int)" (??0_Lockit@std@@QAE@H@Z) already defined in ULUE.lib(Everything.obj)
libcpmtd.lib(xlock.obj) : error LNK2005: "public: __thiscall std::_Lockit::~_Lockit(void)" (??1_Lockit@std@@QAE@XZ) already defined in ULUE.lib(Everything.obj)
libcd.lib(dbgheap.obj) : error LNK2005: __malloc_dbg already defined in msvcrtd.lib(MSVCR71D.dll)
libcd.lib(dbgheap.obj) : error LNK2005: __free_dbg already defined in msvcrtd.lib(MSVCR71D.dll)
libcd.lib(crt0init.obj) : error LNK2005: ___xc_z already defined in msvcrtd.lib(cinitexe.obj)
libcd.lib(crt0init.obj) : error LNK2005: ___xc_a already defined in msvcrtd.lib(cinitexe.obj)
libcd.lib(crt0init.obj) : error LNK2005: ___xi_z already defined in msvcrtd.lib(cinitexe.obj)
libcd.lib(crt0init.obj) : error LNK2005: ___xi_a already defined in msvcrtd.lib(cinitexe.obj)
libcd.lib(winxfltr.obj) : error LNK2005: ___CppXcptFilter already defined in msvcrtd.lib(MSVCR71D.dll)
msvcrtd.lib(ti_inst.obj) : error LNK2005: "private: __thiscall type_info::type_info(class type_info const &)" (??0type_info@@AAE@ABV0@@Z) already defined in libcd.lib(typinfo.obj)
msvcrtd.lib(ti_inst.obj) : error LNK2005: "private: class type_info & __thiscall type_info::operator=(class type_info const &)" (??4type_info@@AAEAAV0@ABV0@@Z) already defined in libcd.lib(typinfo.obj)
msvcrtd.lib(cinitexe.obj) : warning LNK4098: defaultlib 'libcd.lib' conflicts with use of other libs; use /NODEFAULTLIB:library
libcd.lib(crt0.obj) : error LNK2019: unresolved external symbol _main referenced in function _mainCRTStartup
E:\LUE\Debug\MLUE.dll : fatal error LNK1120: 1 unresolved externals
What do I need to do with MLUE to resolve these errors? I've attached a ZIP containing the project. If anyone could take a look at it and let me know what I'm doing wrong, I'd appreciate it. Thanks.
I have Visual Studio 2k3. There's an old C++ program I wrote that uses a command-line interface. I would like to upgrade this to a Visual Basic .NET app.
It seemed to me that the best way to do this is to take the old C++ classes, and write some mixed-mode wrapper classes around them. Then, I could make a VB.NET app that calls the mixed-mode classes. I'm running into some serious linking problems with my attempts at making these wrappers.
In an attempt to isolate these problems while removing most of the complexity, I've made a simple solution called LUE that replicates the general idea of what I'm trying to do, as well as all of the linking errors that occur when I try to do it.
First, there's a static library called ULUE. It consists of three classes written in unmanaged C++. It builds just fine.
Next, there's a CLI app called Earth. It calls functions from the classes in ULUE. It builds and runs just fine.
Next is a VB.NET app called Earth2. It's meant to be the successor to Earth. It *will* call functions from mixed-mode classes once they work. Until then, it won't work either.
Finally, there's a .NET library called MLUE. It consists of one class - a mixed-mode wrapper for one of the classes in ULUE.
Here's my current problem. One of the unmanaged classes is "Everything." One of its functions, multiply, has a local ifstream myFile (currently dormant, but I'll need it later). If I comment this out, everything builds fine. But when it's left in, ULUE builds and Earth work as expected, but MLUE seems to resent its inclusion and won't build. I get these link errors:
Linking...
LINK : warning LNK4075: ignoring '/EDITANDCONTINUE' due to '/INCREMENTAL:NO' specification
libcpmtd.lib(xlock.obj) : error LNK2005: "public: __thiscall std::_Lockit::_Lockit(int)" (??0_Lockit@std@@QAE@H@Z) already defined in ULUE.lib(Everything.obj)
libcpmtd.lib(xlock.obj) : error LNK2005: "public: __thiscall std::_Lockit::~_Lockit(void)" (??1_Lockit@std@@QAE@XZ) already defined in ULUE.lib(Everything.obj)
libcd.lib(dbgheap.obj) : error LNK2005: __malloc_dbg already defined in msvcrtd.lib(MSVCR71D.dll)
libcd.lib(dbgheap.obj) : error LNK2005: __free_dbg already defined in msvcrtd.lib(MSVCR71D.dll)
libcd.lib(crt0init.obj) : error LNK2005: ___xc_z already defined in msvcrtd.lib(cinitexe.obj)
libcd.lib(crt0init.obj) : error LNK2005: ___xc_a already defined in msvcrtd.lib(cinitexe.obj)
libcd.lib(crt0init.obj) : error LNK2005: ___xi_z already defined in msvcrtd.lib(cinitexe.obj)
libcd.lib(crt0init.obj) : error LNK2005: ___xi_a already defined in msvcrtd.lib(cinitexe.obj)
libcd.lib(winxfltr.obj) : error LNK2005: ___CppXcptFilter already defined in msvcrtd.lib(MSVCR71D.dll)
msvcrtd.lib(ti_inst.obj) : error LNK2005: "private: __thiscall type_info::type_info(class type_info const &)" (??0type_info@@AAE@ABV0@@Z) already defined in libcd.lib(typinfo.obj)
msvcrtd.lib(ti_inst.obj) : error LNK2005: "private: class type_info & __thiscall type_info::operator=(class type_info const &)" (??4type_info@@AAEAAV0@ABV0@@Z) already defined in libcd.lib(typinfo.obj)
msvcrtd.lib(cinitexe.obj) : warning LNK4098: defaultlib 'libcd.lib' conflicts with use of other libs; use /NODEFAULTLIB:library
libcd.lib(crt0.obj) : error LNK2019: unresolved external symbol _main referenced in function _mainCRTStartup
E:\LUE\Debug\MLUE.dll : fatal error LNK1120: 1 unresolved externals
What do I need to do with MLUE to resolve these errors? I've attached a ZIP containing the project. If anyone could take a look at it and let me know what I'm doing wrong, I'd appreciate it. Thanks.