Linker errors in pcp_main example from libjingle - visual-studio

I'm working to get libjingle working on windows7 using visual studio. I followed GYP methodology to build lib jingle and got libs after executing the libjingle.sln file.
Now, when I'm trying to run pcp_main.cc file, I got slashed with linker errors, after some work around, I was left with 5 linker errors. Can someone help me how to resolve those errors?
Error 5 error LNK1120: 4 unresolved externals C:\Users\username\documents\visual studio
2012\Projects\PCPTest\Debug\PCPTest.exe Error 3 error LNK2001:
unresolved external symbol "protected: virtual bool __thiscall
buzz::JingleInfoTask::HandleStanza(class buzz::XmlElement const *)"
(?HandleStanza#JingleInfoTask#buzz##MAE_NPBVXmlElement#2##Z) C:\Users\username\documents\visual
studio 2012\Projects\PCPTest\PCPTest\pcp_main.obj
Error 1 error LNK2001: unresolved external symbol "public: virtual int
__thiscall buzz::JingleInfoTask::ProcessStart(void)" (?ProcessStart#JingleInfoTask#buzz##UAEHXZ) C:\Users\username\documents\visual
studio 2012\Projects\PCPTest\PCPTest\pcp_main.obj
Error 2 error LNK2019: unresolved external symbol "public: void
__thiscall buzz::JingleInfoTask::RefreshJingleInfoNow(void)" (?RefreshJingleInfoNow#JingleInfoTask#buzz##QAEXXZ) referenced in
function "public: void __thiscall
AutoPortAllocator::SetXmppClient(class buzz::XmppClient *)"
(?SetXmppClient#AutoPortAllocator##QAEXPAVXmppClient#buzz###Z) C:\Users\username\documents\visual
studio 2012\Projects\PCPTest\PCPTest\pcp_main.obj
Error 4 error LNK2019: unresolved external symbol
_imp_InternetQueryOptionW#16 referenced in function "bool __cdecl talk_base::GetIeLanProxySettings(char const *,struct
talk_base::ProxyInfo *)"
(?GetIeLanProxySettings#talk_base##YA_NPBDPAUProxyInfo#1##Z) C:\Users\username\documents\visual
studio 2012\Projects\PCPTest\PCPTest\libjingle.lib(proxydetect.obj)
My include folder is pointing to
C:\Users\username\Desktop\libjingle\trunk\testing
C:\Users\username\Desktop\libjingle\trunk\
and lib folder to
C:\Users\username\Desktop\libjingle\trunk\build\Debug\lib
Additional dependencies have absolute paths of all the available libs.
C:\Users\username\Desktop\libjingle\trunk\build\Debug\lib\audio_processing_sse2.lib
C:\Users\username\Desktop\libjingle\trunk\build\Debug\lib\bitrate_controller.lib
C:\Users\username\Desktop\libjingle\trunk\build\Debug\lib\CNG.lib
...
...
...
The source codeI'm using is present here.
http://pastebin.com/GATFYWnW

Got the answer!
The Error 4 can be removed by adding the following line
#pragma comment(lib, "Wininet.lib")
The remaining errors correspond to the jingleInfoTask.cc and JingleInfotask.h files. Its a bit surprise to see that the solution file (libjingle.sln) doesnt have these files when it built libraries. The work around would be to add the jingleinfotask.cc and jingleinfotask.h files into xmpp folder and re-build the libjingle.sln file.
This will produce the jingleinfotask.obj and required lib files. Make sure you point the generated lib file in the additional dependencies section in linker section of project properties.

Related

Linking Errors after Visual Studio 2012 to 2017 migration

I am migrating my project from Visual Studio 2012 to 2017. I have selected Windows sdk V 10.0.17763.0 and and platform toolset as Visual Studio 2017 (v141) for all the projects in a solution. and target WINVER 0x0601 . Apart from this i have not made any changes .When I compile all the projects compile but i get error during Linking .There around 400 errors .I am linking the source files of static library files which belongs to other project (Added in additional include directories).Looks like most of the errors are coming from files that belongs to that project. I have even changed the toolset/sdk settings for that project. I am pretty much stuck .Unable to find out the root cause for this error .
Error LNK2019 unresolved external symbol "void __cdecl RemoveRefForStatic(class GlobalSignalSourceInfo *)" (??$RemoveRefForStatic#VGlobalSignalSourceInfo####YAXPAVGlobalSignalSourceInfo###Z) referenced in function "public: __thiscall ATL::CAtlComModule::CAtlComModule(void)" (??0CAtlComModule#ATL##QAE#XZ) CSMediaPlayer D:\CoolSign\trunk\Development\common\2008\CSMediaPlayer_CEF\COMInterface D:\CoolSign\trunk\Development\common\2008\CSMediaPlayer_CEF\COMInterface\CSMediaEngine.lib(StdAfx.obj)
Error LNK2019 unresolved external symbol "void cdecl AddRefForStatic(class GlobalSignalSourceInfo *)" (??$AddRefForStatic#VGlobalSignalSourceInfo####YAXPAVGlobalSignalSourceInfo###Z) referenced in function "long __stdcall ATL::AtlWinModuleTerm(struct ATL::_ATL_WIN_MODULE70 *,struct HINSTANCE *)" (?AtlWinModuleTerm#ATL##YGJPAU_ATL_WIN_MODULE70#1#PAUHINSTANCE__###Z) CSMediaPlayer D:\CoolSign\trunk\Development\common\2008\CSMediaPlayer_CEF\COMInterface D:\CoolSign\trunk\Development\common\2008\CSMediaPlayer_CEF\COMInterface\CSMediaEngine.lib(StdAfx.obj) 1
Error LNK2001 unresolved external symbol "void __cdecl RemoveRefForStatic(class GlobalSignalSourceInfo *)" (??$RemoveRefForStatic#VGlobalSignalSourceInfo####YAXPAVGlobalSignalSourceInfo###Z) CSMediaPlayer D:\CoolSign\trunk\Development\common\2008\CSMediaPlayer_CEF\COMInterface D:\CoolSign\trunk\Development\common\2008\CSMediaPlayer_CEF\COMInterface\CSLib.lib(criticalsection.obj) 1
Error LNK1120 18 unresolved externals CSMediaPlayer D:\CoolSign\trunk\Development\common\2008\CSMediaPlayer_CEF\COMInterface\Debug D:\CoolSign\trunk\Development\common\2008\CSMediaPlayer_CEF\COMInterface\Debug\CSMediaPlayer.dll 1

Using Q_OBJECT in VS2010 project gives unresolved externals

I'm trying to use the Q_OBJECT macro in my Visual Studio 2010 Ultimate project, and it gives me unresolved external errors:
1>Application.obj : error LNK2001: unresolved external symbol "public: virtual int __thiscall MyButton::qt_metacall(enum QMetaObject::Call,int,void * *)" (?qt_metacall#MyButton##UAEHW4Call#QMetaObject##HPAPAX#Z)
1>Application.obj : error LNK2001: unresolved external symbol "public: virtual void * __thiscall MyButton::qt_metacast(char const *)" (?qt_metacast#MyButton##UAEPAXPBD#Z)
1>Application.obj : error LNK2001: unresolved external symbol "public: virtual struct QMetaObject const * __thiscall MyButton::metaObject(void)const " (?metaObject#MyButton##UBEPBUQMetaObject##XZ)
I've had a similar project using QMaker, and solved it by doing clean project and re-running qmake. The thing is, there's no "Qmake" button in VS!
I have read few articles like this one and done everything they told me to. Though it didnt really help, because I've got an existing project of a few .cpp and a few header files, and I would like to avoid creating a .pro file and moving code into it.
I've installed VS Qt add-in, it gave me new cool "Qt" button on VS panel, though didn't help with unresolved externals (probably I don't know how to use it properly).
I have ran moc with via custom build tool in VS on my Application.h file (the only one that has Q_OBJECT), but that still didn't help:
C:\Utilities\QtSDK\Desktop\Qt\4.8.1\msvc2010\bin\moc Application.h -o tmp\moc\moc_Application.cpp
What might cause my problem and how do I solve it?
I would guess that you forgot to add the file generated by MOC (moc_Application.cpp in this case) into your Visual Studio project. You have to do this to make sure it gets built. I'm pretty sure this should resolve the linker errors you see.

Boost SSL with Visual Studio 2010 and OpenSSL

I'm trying to compile the Boost 1.47 ASIO SSL server and client examples. I can sucessfully incorporate Boost into my project, but I cannot incorporate OpenSSL. When I try to add it I get the errors:
1>SSLServer.obj : error LNK2019: unresolved external symbol _ERR_reason_error_string referenced in function "public: virtual class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __thiscall boost::asio::error::detail::ssl_category::message(int)const " (?message#ssl_category#detail#error#asio#boost##UBE?AV?$basic_string#DU?$char_traits#D#std##V?$allocator#D#2##std##H#Z)
1>SSLServer.obj : error LNK2019: unresolved external symbol _CRYPTO_set_id_callback referenced in function "public: __thiscall boost::asio::ssl::detail::openssl_init_base::do_init::do_init(void)" (??0do_init#openssl_init_base#detail#ssl#asio#boost##QAE#XZ)
1>SSLServer.obj : error LNK2019: unresolved external symbol _CRYPTO_set_locking_callback referenced in function "public: __thiscall boost::asio::ssl::detail::openssl_init_base::do_init::do_init(void)" (??0do_init#openssl_init_base#detail#ssl#asio#boost##QAE#XZ)
1>SSLServer.obj : error LNK2019: unresolved external symbol _CRYPTO_num_locks referenced in function "public: __thiscall boost::asio::ssl::detail::openssl_init_base::do_init::do_init(void)" (??0do_init#openssl_init_base#detail#ssl#asio#boost##QAE#XZ)
1>SSLServer.obj : error LNK2019: unresolved external symbol _SSL_load_error_strings referenced in function "public: __thiscall boost::asio::ssl::detail::openssl_init_base::do_init::do_init(void)" (??0do_init#openssl_init_base#detail#ssl#asio#boost##QAE#XZ)
1>SSLServer.obj : error LNK2019: unresolved external symbol _SSL_library_init referenced in function "public: __thiscall boost::asio::ssl::detail::openssl_init_base::do_init::do_init(void)" (??0do_init#openssl_init_base#detail#ssl#asio#boost##QAE#XZ)
1>SSLServer.obj : error LNK2019: unresolved external symbol _ENGINE_cleanup referenced in function "public: __thiscall boost::asio::ssl::detail::openssl_init_base::do_init::~do_init(void)" (??1do_init#openssl_init_base#detail#ssl#asio#boost##QAE#XZ)
1>SSLServer.obj : error LNK2019: unresolved external symbol _CONF_modules_unload referenced in function "public: __thiscall boost::asio::ssl::detail::openssl_init_base::do_init::~do_init(void)" (??1do_init#openssl_init_base#detail#ssl#asio#boost##QAE#XZ)
1>SSLServer.obj : error LNK2019: unresolved external symbol _CRYPTO_cleanup_all_ex_data referenced in function "public: __thiscall boost::asio::ssl::detail::openssl_init_base::do_init::~do_init(void)" (??1do_init#openssl_init_base#detail#ssl#asio#boost##QAE#XZ)
1>SSLServer.obj : error LNK2019: unresolved external symbol _EVP_cleanup referenced in function "public: __thiscall boost::asio::ssl::detail::openssl_init_base::do_init::~do_init(void)" (??1do_init#openssl_init_base#detail#ssl#asio#boost##QAE#XZ)
1>SSLServer.obj : error LNK2019: unresolved external symbol _ERR_remove_state referenced in function "public: __thiscall boost::asio::ssl::detail::openssl_init_base::do_init::~do_init(void)" (??1do_init#openssl_init_base#detail#ssl#asio#boost##QAE#XZ)
1>SSLServer.obj : error LNK2019: unresolved external symbol _ERR_free_strings referenced in function "public: __thiscall boost::asio::ssl::detail::openssl_init_base::do_init::~do_init(void)" (??1do_init#openssl_init_base#detail#ssl#asio#boost##QAE#XZ)
1>C:\Users\Epicism\Documents\Visual Studio 2010\Projects\SSLServer\Debug\SSLServer.exe : fatal error LNK1120: 12 unresolved externals
1>
1>Build FAILED.
I have tried adding the directory C:\OpenSSL-Win32\lib\, C:\OpenSSL-Win32\lib\VC\, C:\OpenSSL-Win32\lib\VC\static, C:\OpenSSL-Win32\bin, C:\OpenSSL-Win32\include to Project->General Properties->Linker->Additional Library Directories using the openssl pre-compiled libraries (http://www.openssl.org/related/binaries.html). I have also tried compiling OpenSSL myself with the same errors. I'm really at a loss, I have tried everything I have searched Google about a thousand times, tried IRC, every combination of directories I can think of...
My setup is:
Windows 7 64-bit
Windows Visual Studio 2010 64 bit
Boost 1.47
OpenSSL 1.0.0E and G
C/C++ Additional Include Directories: C:\Program Files (x86)\boost\boost_1_47;C:\openssl\include\;C:\OpenSSL-Win32\lib;%(AdditionalIncludeDirectories)
Project->General Properties->Linker->Additional Library Directories: C:\Program Files (x86)\boost\boost_1_47\lib;C:\openssl\lib;C:\openssl;%(AdditionalLibraryDirectories)
- I've tried adding every directory to this property as well....
Right now I'm just trying to compile the following in a VS C++ console project:
// SSLServer.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <cstdlib>
#include <iostream>
#include <boost/bind.hpp>
#include <boost/asio.hpp>
#include <boost/asio/ssl.hpp>
int _tmain(int argc, _TCHAR* argv[])
{
return 0;
}
Thanks in advance.
Looks like you're using the 32-bit version of OpenSSL on a 64-bit machine.
Try downloading the 64-bit version (Win64 OpenSSL v1.0.0g) from http://www.slproweb.com/products/Win32OpenSSL.html
After that's installed (if you use default paths), you should have a C:\OpenSSL-Win64 folder.
You should add:
C:\OpenSSL-Win64\include to your Additional Include Directories
C:\OpenSSL-Win64\lib\VC\static or C:\OpenSSL-Win64\lib\VC to your Additional Library Directories depending on whether you want the static libs or the dlls respectively
libeay32<XXX>.lib and ssleay32<XXX>.lib to Additional Dependencies where <XXX> matches whatever setting you have for [C/C++]->[Code Generation]->[Runtime Library]
I managed to get your little program above to build by linking with the 32-bit version of the Boost library along with the 32-bit version of OpenSSL. You will also need the 32-bit version of the redistributables as well. The bug is present in Boost version 1.51 and 1.52, which are the only versions I tested.
I believe there is a bug in the 64-bit version of the ASIO library. Although, it is possible that it is some sort of configuration problem that has affected many others. I have submitted a Boost bug report about the issue.
I met with the similar issue(VS2010), solved methods:
1)Properties->C/C++ ->general->additional include Directories: yourpath\boost_1_58_0\boost_1_58_0 (I use 1.58.0 version)
2)Properties->Linker ->general->additional library directories:
yourpath\boost_1_58_0\boost_1_58_0\stage\lib
3)Properties->Linker ->Input ->additional Dependencies:
libeay32.lib
ssleay32.lib
These two .lib files are copied from openssl install directory.

Build problem in Visual Studio 2010

I use CS106 library in the university.After changing Visual Studio 2008 with Visual Studio 2010, I have problems with building new projects or the old ones.I think that new Visual studio is not compatible with CS106 library.Can anyone tell how to fix this problem?
This is the output:
1>------ Build started: Project: Blank, Configuration: Debug Win32 ------
1>Build started 3/15/2011 2:03:21 PM.
1>InitializeBuildStatus:
1> Touching "Debug\Blank.unsuccessfulbuild".
1>ClCompile:
1> All outputs are up-to-date.
1>CS106CPPLib.lib(strutils.obj) : error LNK2001: unresolved external symbol "public: static void __cdecl std::_String_base::_Xran(void)" (?_Xran#_String_base#std##SAXXZ)
1>CS106CPPLib.lib(simpio.obj) : error LNK2019: unresolved external symbol "public: static void __cdecl std::_String_base::_Xran(void)" (?_Xran#_String_base#std##SAXXZ) referenced in function "public: class std::basic_string,class std::allocator > & __thiscall std::basic_string,class std::allocator >::assign(class std::basic_string,class std::allocator > const &,unsigned int,unsigned int)" (?assign#?$basic_string#DU?$char_traits#D#std##V?$allocator#D#2##std##QAEAAV12#ABV12#II#Z)
1>CS106CPPLib.lib(genlib.obj) : error LNK2001: unresolved external symbol "public: static void __cdecl std::_String_base::_Xran(void)" (?_Xran#_String_base#std##SAXXZ)
1>CS106CPPLib.lib(init.obj) : error LNK2001: unresolved external symbol "public: static void __cdecl std::_String_base::_Xran(void)" (?_Xran#_String_base#std##SAXXZ)
1>CS106CPPLib.lib(pcgraphics.obj) : error LNK2001: unresolved external symbol "public: static void __cdecl std::_String_base::_Xran(void)" (?_Xran#_String_base#std##SAXXZ)
1>CS106CPPLib.lib(strutils.obj) : error LNK2001: unresolved external symbol "public: static void __cdecl std::_String_base::_Xlen(void)" (?_Xlen#_String_base#std##SAXXZ)
1>CS106CPPLib.lib(simpio.obj) : error LNK2019: unresolved external symbol "public: static void __cdecl std::_String_base::_Xlen(void)" (?_Xlen#_String_base#std##SAXXZ) referenced in function "protected: bool __thiscall std::basic_string,class std::allocator >::_Grow(unsigned int,bool)" (?_Grow#?$basic_string#DU?$char_traits#D#std##V?$allocator#D#2##std##IAE_NI_N#Z)
1>CS106CPPLib.lib(genlib.obj) : error LNK2001: unresolved external symbol "public: static void __cdecl std::_String_base::_Xlen(void)" (?_Xlen#_String_base#std##SAXXZ)
1>CS106CPPLib.lib(init.obj) : error LNK2001: unresolved external symbol "public: static void __cdecl std::_String_base::_Xlen(void)" (?_Xlen#_String_base#std##SAXXZ)
1>CS106CPPLib.lib(pcgraphics.obj) : error LNK2001: unresolved external symbol "public: static void __cdecl std::_String_base::_Xlen(void)" (?_Xlen#_String_base#std##SAXXZ)
1>CS106CPPLib.lib(simpio.obj) : error LNK2019: unresolved external symbol "private: static void __cdecl std::locale::facet::facet_Register(class std::locale::facet *)" (?facet_Register#facet#locale#std##CAXPAV123##Z) referenced in function "public: void __thiscall std::locale::facet::_Register(void)" (?_Register#facet#locale#std##QAEXXZ)
1>CS106CPPLib.lib(strutils.obj) : error LNK2001: unresolved external symbol "private: static void __cdecl std::locale::facet::facet_Register(class std::locale::facet *)" (?facet_Register#facet#locale#std##CAXPAV123##Z)
1>CS106CPPLib.lib(simpio.obj) : error LNK2001: unresolved external symbol "long const std::_BADOFF" (?_BADOFF#std##3JB)
1>CS106CPPLib.lib(strutils.obj) : error LNK2001: unresolved external symbol "long const std::_BADOFF" (?_BADOFF#std##3JB)
1>Debug\Blank.exe : fatal error LNK1120: 4 unresolved externals
1>
1>Build FAILED.
1>
1>Time Elapsed 00:00:00.97
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
Here is the solution:
http://melbsdailydigest.blogspot.com/
1.) Download one of the latest projects from the Stanford CS106B Website:
CS106B Assignment 1
2.) Unzip the project and find its subdirectory \CS106. This is the folder that contains all the library (CS106CPPLib.lib) and header files for the CS106 program.
3.) Copy this folder as a subdirectory to one of your assignment folders (ex. C:\Assignment1\CS106.
4.) Startup Visual Studio2008 and click File->New->Project… When given the choice choose to create a new Console program.
5.) You’ll then be presented with a new project with multiple files including stdafx.h, stdafx.cpp and similarly named files for whatever you named your project when prompted earlier. DELETE/ REMOVE all these files from the project.
6.) Right click the Source File Folder and choose Add->Existing Item… Choose the first assignment file (Assign1warmup.cpp).
7.) If you compile at this point you’ll realize that it’s still looking for the stdafx.h precompiled header. Let’s fix that. Go to Project->Assignment1 Properties… (or whatever your project might be named). Go to the option in the “tree” menu for Configuration Properties->C/C++->Pre-Compiled Headers . Under the option for Create/Use Precompiled header, choose the drop down option for Not Using Precompiled headers.
8.) While you’re in this section, take the time now to also select the location for the header files for this project. Under the Configuration Properties->C/C++->General section choose the Additional Include Directories option and use the … to browse and select the CS106 folder that you copied to your project folder earlier.
9.) One last thing you should change here is in the Configuration Properties->C/C++->Code Generation section. Change the default (which I believe is for a Multi-Threaded Debug .DLL) to just Multi-Threaded Debug (or just Multi-Threaded if you are doing your release build).
10.) Lastly, we’ll need to let the linker know where to find the CS106 library file. To do that you’ll need to make 2 additional settings. One is in the Configuration Properties->Linker->General section where you can select the location of your additional library files in the section titled appropriately enough – “Additional Library Directories”. You’ll also need to add your library to the project through the “Additional Dependencies” section which is under Configuration Properties->Linker->Input. Just type in CS106CPPLIB.lib.
Note: I found that there seems to be some difference in the menus you get and the settings that get saved depending on what your selection is at the moment in the solution Explorer Window. I originally made all my changes while I was selecting the actual source file, but there were no linker menus at that point. I had to move up to the Source File Folder level to get additional menus where I could set my linker options. Also important to note is that if you make your settings at the lower level (ie. Cpp file) they seem to supersede whatever is set in the level above it.
At this point the project should correctly build with the selection of the Build->Rebuild Solution command.
Happy programming!
The source code would help to fix this. But....did you add #include <string> at the top of the file producing the errors?

Problem with statically linking hunspell library in visual studio 2010

I can't statically link hunspell library to my C++ project in Visual Studio 2010.
I downloaded hunspell and went to hunspell-1.3.1\src\win_api folder. I opened libhunspell.vcproj file in visual studio 2010 and converted project. I built solution in Realease configuration and it generated "libhunspel.lib" file in hunspell-1.3.1\src\win_api\Release\libhunspell folder.
In my simple C++ console program that use hunpell:
I added this folder with libhunspel.lib file in Property Pages/Configuration Properties/VC++ Directories/Library Directories
I added "hunspell-1.3.1\src\" folder to Property Pages/Configuration Properties/VC++ Directories/Include Directories
and "libhunspell.lib" to Property Pages/Linker/Input/Additional Dependancies.
But it still gives me unresolved external symbol error:
Error 2 error LNK2019: unresolved external symbol "__declspec(dllimport) public: int __thiscall Hunspell::spell(char const *,int *,char * *)" (__imp_?spell#Hunspell##QAEHPBDPAHPAPAD#Z) referenced in function _main C:\Users\Me\Documents\Visual Studio 2010\Projects\hunspell_learning\hunspell_learning\main.obj hunspell_learning
Error 3 error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall Hunspell::Hunspell(char const *,char const *,char const *)" (__imp_??0Hunspell##QAE#PBD00#Z) referenced in function _main C:\Users\Me\Documents\Visual Studio 2010\Projects\hunspell_learning\hunspell_learning\main.obj hunspell_learning
Error 1 error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall Hunspell::~Hunspell(void)" (__imp_??1Hunspell##QAE#XZ) referenced in function _main C:\Users\Me\Documents\Visual Studio 2010\Projects\hunspell_learning\hunspell_learning\main.obj hunspell_learning
Error 4 error LNK1120: 3 unresolved externals C:\Users\Me\Documents\Visual Studio 2010\Projects\hunspell_learning\Debug\hunspell_learning.exe 1 1 hunspell_learning
I don't have idea what can be wrong. I also tries with dynamic library. Built Hunspell solution in Release_dll configuration and just changed Include Directories in my app to hunspell-1.3.1\src\win_api\Release_dll\libhunspell and it compiles. I only need to copy libhunspell.dll where my executable program is so dll will be loaded.
You need to put "#define HUNSPELL_STATIC" somewhere in your stdafx.h.

Resources