: error LNK2019: unresolved external symbol

Hi,

I'm implementing a CORBA wrapper in C++ with Visual C++ 2008 and Borland VisiBroker 8. As you can see below, the compilation process was successfully executed, but linking failed. If there's anybody out there who can give me a tip, i'd certainly appreciate it.

------ Build started: Project: C++CorbaWrapper, Configuration: Debug Win32 ------
Compiling...
MicrocontrollerFactoryImpl.cpp
MicrocontrollerImpl.cpp
MicrocontrollerManager_s.cpp
Server.cpp
Generating Code...
Linking...
MicrocontrollerFactoryImpl.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: virtual __thiscall PortableServer_ServantBase::~PortableServer_ServantBase(void)" (__imp_??1PortableServer_ServantBase@@UAE@XZ) referenced in function __unwindfunclet$??0MicrocontrollerFactoryImpl@@QAE@XZ$0
MicrocontrollerImpl.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: virtual __thiscall PortableServer_ServantBase::~PortableServer_ServantBase(void)" (__imp_??1PortableServer_ServantBase@@UAE@XZ)
MicrocontrollerManager_s.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: virtual __thiscall PortableServer_ServantBase::~PortableServer_ServantBase(void)" (__imp_??1PortableServer_ServantBase@@UAE@XZ)
Server.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: virtual __thiscall PortableServer_ServantBase::~PortableServer_ServantBase(void)" (__imp_??1PortableServer_ServantBase@@UAE@XZ)
Last edited on
Are you linking to the .lib?
Hi helios,

Thanks for your quick response! I'm not sure i do understand what u mean by linking to the .lib. I'm honestly not an experienced C++ and VC++ 2008 programmer. I'm new to these technologies. But after googling for a while and trying hard to understand the error message i think the Linker is unable to access certain libraries. Which Libraries??? I don't know.

My understanding is that the Linker configuration at Configuration Properties -> Linker -> Input -> Additional Dependencies needs to be modified.
Okay, I've never used whatever library it is you're using (I don't even know what CORBA is, actually), but the ordinary method for linking to a library with VC++ is this:
You should have gotten with the library at least the first two of these three:
1. One or more headers that tell the compiler what the functions look like. You obviously have this, or you'd be getting compiler errors.
2. One or more .libs that defines some or all of the functions, and tells the linker to shut up about the ones that aren't defines.
3. One or more DLLs that will be linked to the program at run time if some of the functions weren't fully defined by the .libs.

Now, assuming you have number 2, you should put it somewhere where the compiler can find them. I would set aside a directory in My Documents to put all .libs and then add it to the compiler list in tools>options>projects and solutions>VC++ directories>show directories for: library files. If you're feeling lazy, you can just leave them in one of the directories that are already listed there (e.g. "$(VSInstallDir)lib").
Next, you need to add their file names (not their full path. It will still work if you add the full path, but it's unnecessary thanks to the previous step) to that option you mentioned (Configuration Properties -> Linker -> Input -> Additional Dependencies). Don't forget the file name extensions.

That should clear the linker errors.
Hi helios,

Thank you very much for taking some time out to simplify this to me. I'll try it out and keep you updated as soon as i'm done with it.

I do appreciate your help.
Hi helios,

I tried your suggestion and the total number of link errors dropped from 124 to 17. Just like you rightly predicted in point 3, i'm a fraid some of the function aren't fully implemented. I tried all the libs in the lib folder and still wasn't able to get rid of the 17 remaining link errors.
Oh, boy. Well, let's take a look at them.
Here's the output:

------ Build started: Project: C++CorbaWrapper, Configuration: Debug Win32 ------
Linking...
MicrocontrollerFactoryImpl.obj : error LNK2019: unresolved external symbol "public: virtual __thiscall MicrocontrollerManager::Microcontroller_var::~Microcontroller_var(void)" (??1Microcontroller_var@MicrocontrollerManager@@UAE@XZ) referenced in function "public: virtual class MicrocontrollerManager::Microcontroller * __thiscall MicrocontrollerFactoryImpl::create(void)" (?create@MicrocontrollerFactoryImpl@@UAEPAVMicrocontroller@MicrocontrollerManager@@XZ)
MicrocontrollerManager_s.obj : error LNK2001: unresolved external symbol "public: virtual __thiscall MicrocontrollerManager::Microcontroller_var::~Microcontroller_var(void)" (??1Microcontroller_var@MicrocontrollerManager@@UAE@XZ)
MicrocontrollerFactoryImpl.obj : error LNK2019: unresolved external symbol "public: __thiscall MicrocontrollerManager::Microcontroller_var::Microcontroller_var(class MicrocontrollerManager::Microcontroller *)" (??0Microcontroller_var@MicrocontrollerManager@@QAE@PAVMicrocontroller@1@@Z) referenced in function "public: virtual class MicrocontrollerManager::Microcontroller * __thiscall MicrocontrollerFactoryImpl::create(void)" (?create@MicrocontrollerFactoryImpl@@UAEPAVMicrocontroller@MicrocontrollerManager@@XZ)
MicrocontrollerManager_s.obj : error LNK2001: unresolved external symbol "public: __thiscall MicrocontrollerManager::Microcontroller_var::Microcontroller_var(class MicrocontrollerManager::Microcontroller *)" (??0Microcontroller_var@MicrocontrollerManager@@QAE@PAVMicrocontroller@1@@Z)
MicrocontrollerFactoryImpl.obj : error LNK2019: unresolved external symbol "public: static class MicrocontrollerManager::Microcontroller * __cdecl MicrocontrollerManager::Microcontroller::_narrow(class CORBA_Object *)" (?_narrow@Microcontroller@MicrocontrollerManager@@SAPAV12@PAVCORBA_Object@@@Z) referenced in function "public: virtual class MicrocontrollerManager::Microcontroller * __thiscall MicrocontrollerFactoryImpl::create(void)" (?create@MicrocontrollerFactoryImpl@@UAEPAVMicrocontroller@MicrocontrollerManager@@XZ)
MicrocontrollerFactoryImpl.obj : error LNK2019: unresolved external symbol "class std::basic_ostream<char,struct std::char_traits<char> > & __cdecl MicrocontrollerManager::_marshal_in(class std::basic_ostream<char,struct std::char_traits<char> > &,class MicrocontrollerManager::Microcontroller_var const &)" (?_marshal_in@MicrocontrollerManager@@YAAAV?$basic_ostream@DU?$char_traits@D@std@@@std@@AAV23@ABVMicrocontroller_var@1@@Z) referenced in function "class std::basic_ostream<char,struct std::char_traits<char> > & __cdecl operator<<(class std::basic_ostream<char,struct std::char_traits<char> > &,class MicrocontrollerManager::Microcontroller_var const &)" (??6@YAAAV?$basic_ostream@DU?$char_traits@D@std@@@std@@AAV01@ABVMicrocontroller_var@MicrocontrollerManager@@@Z)
MicrocontrollerFactoryImpl.obj : error LNK2019: unresolved external symbol "public: static class VISOps_Info const * __cdecl MicrocontrollerManager::MicrocontrollerFactory_ops::_desc(void)" (?_desc@MicrocontrollerFactory_ops@MicrocontrollerManager@@SAPBVVISOps_Info@@XZ) referenced in function "public: virtual void * __thiscall POA_MicrocontrollerManager::MicrocontrollerFactory::_safe_downcast_ops(class VISOps_Info const &)" (?_safe_downcast_ops@MicrocontrollerFactory@POA_MicrocontrollerManager@@UAEPAXABVVISOps_Info@@@Z)
MicrocontrollerManager_s.obj : error LNK2001: unresolved external symbol "public: static class VISOps_Info const * __cdecl MicrocontrollerManager::MicrocontrollerFactory_ops::_desc(void)" (?_desc@MicrocontrollerFactory_ops@MicrocontrollerManager@@SAPBVVISOps_Info@@XZ)
MicrocontrollerImpl.obj : error LNK2019: unresolved external symbol "public: __thiscall Microcontrol::~Microcontrol(void)" (??1Microcontrol@@QAE@XZ) referenced in function "public: virtual void __thiscall MicrocontrollerImpl::sendToMicrocontroller(char)" (?sendToMicrocontroller@MicrocontrollerImpl@@UAEXD@Z)
MicrocontrollerImpl.obj : error LNK2019: unresolved external symbol "public: void __thiscall Microcontrol::SendToUART(char)" (?SendToUART@Microcontrol@@QAEXD@Z) referenced in function "public: virtual void __thiscall MicrocontrollerImpl::sendToMicrocontroller(char)" (?sendToMicrocontroller@MicrocontrollerImpl@@UAEXD@Z)
MicrocontrollerImpl.obj : error LNK2019: unresolved external symbol "public: __thiscall Microcontrol::Microcontrol(void)" (??0Microcontrol@@QAE@XZ) referenced in function "public: virtual void __thiscall MicrocontrollerImpl::sendToMicrocontroller(char)" (?sendToMicrocontroller@MicrocontrollerImpl@@UAEXD@Z)
MicrocontrollerImpl.obj : error LNK2019: unresolved external symbol "public: static class VISOps_Info const * __cdecl MicrocontrollerManager::Microcontroller_ops::_desc(void)" (?_desc@Microcontroller_ops@MicrocontrollerManager@@SAPBVVISOps_Info@@XZ) referenced in function "public: virtual void * __thiscall POA_MicrocontrollerManager::Microcontroller::_safe_downcast_ops(class VISOps_Info const &)" (?_safe_downcast_ops@Microcontroller@POA_MicrocontrollerManager@@UAEPAXABVVISOps_Info@@@Z)
MicrocontrollerManager_s.obj : error LNK2001: unresolved external symbol "public: static class VISOps_Info const * __cdecl MicrocontrollerManager::Microcontroller_ops::_desc(void)" (?_desc@Microcontroller_ops@MicrocontrollerManager@@SAPBVVISOps_Info@@XZ)
MicrocontrollerManager_s.obj : error LNK2019: unresolved external symbol "public: static class CORBA_TypeInfo const * __cdecl MicrocontrollerManager::Microcontroller::_desc(void)" (?_desc@Microcontroller@MicrocontrollerManager@@SAPBVCORBA_TypeInfo@@XZ) referenced in function "public: class MicrocontrollerManager::Microcontroller * __thiscall POA_MicrocontrollerManager::Microcontroller::_this(void)" (?_this@Microcontroller@POA_MicrocontrollerManager@@QAEPAV1MicrocontrollerManager@@XZ)
MicrocontrollerManager_s.obj : error LNK2019: unresolved external symbol "public: static class CORBA_TypeInfo const * __cdecl MicrocontrollerManager::MicrocontrollerFactory::_desc(void)" (?_desc@MicrocontrollerFactory@MicrocontrollerManager@@SAPBVCORBA_TypeInfo@@XZ) referenced in function "public: class MicrocontrollerManager::MicrocontrollerFactory * __thiscall POA_MicrocontrollerManager::MicrocontrollerFactory::_this(void)" (?_this@MicrocontrollerFactory@POA_MicrocontrollerManager@@QAEPAV1MicrocontrollerManager@@XZ)
MicrocontrollerManager_s.obj : error LNK2019: unresolved external symbol "class VISostream & __cdecl MicrocontrollerManager::_marshal_in(class VISostream &,class MicrocontrollerManager::Microcontroller_var const &)" (?_marshal_in@MicrocontrollerManager@@YAAAVVISostream@@AAV2@ABVMicrocontroller_var@1@@Z) referenced in function "class VISostream & __cdecl operator<<(class VISostream &,class MicrocontrollerManager::Microcontroller_var const &)" (??6@YAAAVVISostream@@AAV0@ABVMicrocontroller_var@MicrocontrollerManager@@@Z)
C:\Dokumente und Einstellungen\Jamaic\Eigene Dateien\Visual Studio 2008\Projects\C++CorbaWrapper\Debug\C++CorbaWrapper.exe : fatal error LNK1120: 12 unresolved externals
Build log was saved at "file://c:\Dokumente und Einstellungen\Jamaic\Eigene Dateien\Visual Studio 2008\Projects\C++CorbaWrapper\C++CorbaWrapper\Debug\BuildLog.htm"
C++CorbaWrapper - 17 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
Let me briefly describe what my program is suppose to do. It might give u a big picture of what i'm tryin to do.

My task is to let a Java client communicate with a C++ server. To realize this, CORBA specifies a programming methodology of how one can hoke a Java client to communicate with a C++ server and vice-versa. Borland VisiBroker here is actually a piece of software that implements the CORBA specification and provides libs, header files and compilers for this purpose. With the aid of the CORBA Interface Definition Language (CORBA IDL), i was able to create a file that describe the interfaces my C++ server exposes. Using the compilers in VisiBroker i generated Java and C++ proxy files from the IDL file. The generated Java and C++ files now have to be integrated in my Java client and C++ server respectively.

I did that and integrated some header files, from my VisiBroker include folder (C:\Borland\VisiBroker\include), into my program. The compilation was successful and linking failed. From the suggestion u gave me, i integrated some lib files, C:\Borland\VisiBroker\lib, into the VC++ 2008 Linker configuration. Because of this i was able to reduce the total number of link errors from 124 to 17.

I noticed something when i was tryin to lookup the right libs for the VC++2008 linker. The include folder in VisiBroker has many more useful header files than i was able to find lib folder. Is there a way of generating more libs from the header files ? My question is in reference to ur point 3. U said if the functions aren't fully implemented then the only option is to do it myself.
Last edited on
Topic archived. No new replies allowed.