I get the following error while trying to compile a sample implementation of firefox protocol handler. I am using Gecko SDK 3.6, Visual Studio 2010 on Windows Vista. I think the sample is very old and was not build using version 3.6 of the SDK.
1>nsKeywordModule.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) unsigned int __cdecl NS_NewGenericModule2(struct nsModuleInfo const *,class nsIModule * *)" (_imp?NS_NewGenericModule2##YAIPBUnsModuleInfo##PAPAVnsIModule###Z) referenced in function _NSGetModule
1>nsKeywordProtocolHandler.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall nsFixedCString::nsFixedCString(char *,unsigned int,unsigned int)" (_imp??0nsFixedCString##QAE#PADII#Z) referenced in function "public: __thiscall nsCAutoString::nsCAutoString(void)" (??0nsCAutoString##QAE#XZ)
1>nsKeywordProtocolHandler.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: static char * nsCharTraits::sEmptyBuffer" (_imp?sEmptyBuffer#?$nsCharTraits#D##2PADA)
1>nsKeywordProtocolHandler.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall nsACString_internal::nsACString_internal(char *,unsigned int,unsigned int)" (_imp??0nsACString_internal##QAE#PADII#Z) referenced in function "protected: __thiscall nsCString::nsCString(char *,unsigned int,unsigned int)" (??0nsCString##IAE#PADII#Z)
I belief the sample was using the complete mozilla implementation to get the header files. Now since we have gecko sdk all the internal linkage will have to be migrated to use frozen linkage because internal linkage is not supported by gecko sdk 3.6.
So in my case i changed nsAString.h to nsStringAPI.h and followed other guidelines
Related
I have a running project in Visual Studio 2010 using OpenCV 2.49 and Point Cloud Library 1.6 . I am trying to make a standalone executable so I don´t need to install OpenCV and PCL in other computers to make it run.
OpenCV and PCL were installed using the precompiled binaries, and PCL also included boost (1.49) and vtk (5.8) libraries, among others.
For making the static build, I changed the Runtime Library in VS to /MT. Then, some Boost static libraries were missing, so I installed boost again (version 1.56, I believe I needed the libs with the 's').
Then I had errors like:
1>MSVCRT.lib(MSVCR100.dll) : error LNK2005: _malloc already defined in LIBCMT.lib(malloc.obj)
so I added msvcrt.lib, msvcprt.lib to the section "Ignore Specific Defaul Libraries".
Now I have errors like:
1>vtkCommon.lib(vtkVoidArray.obj) : error LNK2001: unresolved external symbol "__declspec(dllimport) public: class std::basic_ostream<char,struct std::char_traits<char> > & __thiscall std::basic_ostream<char,struct std::char_traits<char> >::operator<<(void const *)" (__imp_??6?$basic_ostream#DU?$char_traits#D#std###std##QAEAAV01#PBX#Z)
1>vtkCommon.lib(vtkVariantArray.obj) : error LNK2001: unresolved external symbol "__declspec(dllimport) public: class std::basic_ostream<char,struct std::char_traits<char> > & __thiscall std::basic_ostream<char,struct std::char_traits<char> >::operator<<(void const *)" (__imp_??6?$basic_ostream#DU?$char_traits#D#std###std##QAEAAV01#PBX#Z)
1>vtkCommon.lib(vtkTimerLog.obj) : error LNK2001: unresolved external symbol __imp__strncpy
1>vtkCommon.lib(vtkMath.obj) : error LNK2001: unresolved external symbol __imp__modf
1>vtksys.lib(SystemTools.obj) : error LNK2001: unresolved external symbol __imp___utime64
1>OLDNAMES.lib(unlink.obi) : error LNK2001: unresolved external symbol __imp__unlink
The vtk library is included exactly the same way as in the non-static release build. And, if I understood it correctly, .lib is an extension for a static libray.
What am I doing wrong?
EDIT: I tried using CMake, but I am getting the same kind of errors (There are a lot more):
2>vtksys.lib(SystemTools.obj) : error LNK2019: unresolved external symbol __imp___time64 referenced in function _time
2>vtkCommon.lib(vtkVariant.obj) : error LNK2019: unresolved external symbol "__declspec(dllimport) public: class std::basic_istream<char,struct std::char_traits<char> > & __thiscall std::basic_istream<char,struct std::char_traits<char> >::operator>>(short &)" (__imp_??5?$basic_istream#DU?$char_traits#D#std###std##QAEAAV01#AAF#Z) referenced in function "short __cdecl vtkVariantStringToNumeric<short>(class vtkStdString,bool *,short *)" (??$vtkVariantStringToNumeric#F##YAFVvtkStdString##PA_NPAF#Z)
This is my CMakeList.txt:
cmake_minimum_required(VERSION 2.8 FATAL_ERROR)
project(3DVisualizerCM)
set(BUILD_SHARED_LIBS OFF)
SET(CMAKE_EXE_LINKER_FLAGS "/NODEFAULTLIB:msvcrt.lib
/NODEFAULTLIB:msvcprt.lib")
find_package(PCL 1.4 REQUIRED)
find_package(OpenCV REQUIRED)
include_directories(${PCL_INCLUDE_DIRS} )
link_directories(${PCL_LIBRARY_DIRS} )
add_definitions(${PCL_DEFINITIONS} )
add_executable (3D_v4
3D_v4.cpp
C3DVisualizer.cpp
C3DVisualizerMultiple.cpp
C3DVisualizerSingle.cpp
CCameraParameters.cpp
CImageTrack.cpp
CImg.cpp
CImgMultiple.cpp
CImgSingle.cpp
helpers.cpp
)
target_link_libraries (3D_v4 ${PCL_LIBRARIES} ${OpenCV_LIBS})
The precompiled vtk libraries you are using from PCL must have been compiled using /MD flag (Multithreaded DLL) in Visual Studio. You need to recompile them using the /MT flag (Multithreaded static link).
I am trying to use Boost Unit Test Framework by building a stand alone library as detailed here:
http://www.boost.org/doc/libs/1_35_0/libs/test/doc/components/utf/compilation.html
So I created a VC library project containing the mentioned files and build it and it was successful. Then I created a test project and referenced the library project I just created, but when I tried to build it, I got the following linking errors:
1>Type.obj : error LNK2019: unresolved external symbol "bool __cdecl boost::test_tools::tt_detail::check_impl(class boost::test_tools::predicate_result const &,class boost::unit_test::lazy_ostream const &,class boost::unit_test::basic_cstring<char const >,unsigned __int64,enum boost::test_tools::tt_detail::tool_level,enum boost::test_tools::tt_detail::check_type,unsigned __int64,...)" (?check_impl#tt_detail#test_tools#boost##YA_NAEBVpredicate_result#23#AEBVlazy_ostream#unit_test#3#V?$basic_cstring#$$CBD#63#_KW4tool_level#123#W4check_type#123#3ZZ) referenced in function "public: void __cdecl test1::test_method(void)" (?test_method#test1##QEAAXXZ)
1>BoostUnitTestFramework.lib(framework.obj) : error LNK2019: unresolved external symbol "void __cdecl boost::debug::break_memory_alloc(long)" (?break_memory_alloc#debug#boost##YAXJ#Z) referenced in function "void __cdecl boost::unit_test::framework::init(class boost::unit_test::test_suite * (__cdecl*)(int,char * * const),int,char * * const)" (?init#framework#unit_test#boost##YAXP6APEAVtest_suite#23#HQEAPEAD#ZH0#Z)
1>BoostUnitTestFramework.lib(framework.obj) : error LNK2019: unresolved external symbol "void __cdecl boost::debug::detect_memory_leaks(bool)" (?detect_memory_leaks#debug#boost##YAX_N#Z) referenced in function "void __cdecl boost::unit_test::framework::init(class boost::unit_test::test_suite * (__cdecl*)(int,char * * const),int,char * * const)" (?init#framework#unit_test#boost##YAXP6APEAVtest_suite#23#HQEAPEAD#ZH0#Z)
1>BoostUnitTestFramework.lib(execution_monitor.obj) : error LNK2019: unresolved external symbol "bool __cdecl boost::debug::attach_debugger(bool)" (?attach_debugger#debug#boost##YA_N_N#Z) referenced in function "public: int __cdecl boost::detail::system_signal_exception::operator()(unsigned int,struct _EXCEPTION_POINTERS *)" (??Rsystem_signal_exception#detail#boost##QEAAHIPEAU_EXCEPTION_POINTERS###Z)
1>BoostUnitTestFramework.lib(execution_monitor.obj) : error LNK2019: unresolved external symbol "bool __cdecl boost::debug::under_debugger(void)" (?under_debugger#debug#boost##YA_NXZ) referenced in function "public: int __cdecl boost::execution_monitor::execute(class boost::unit_test::callback0<int> const &)" (?execute#execution_monitor#boost##QEAAHAEBV?$callback0#H#unit_test#2##Z)
1>BoostUnitTestFramework.lib(unit_test_main.obj) : error LNK2019: unresolved external symbol "class boost::unit_test::test_suite * __cdecl init_unit_test_suite(int,char * * const)" (?init_unit_test_suite##YAPEAVtest_suite#unit_test#boost##HQEAPEAD#Z) referenced in function main
1>C:\Users\Rafid\Workspace\MyPhysics\Builds\VC10\Tests\Debug\Tests.exe : fatal error LNK1120: 6 unresolved externals
They seem to be mainly caused by Boost debug library, but I can't see a reason why I should get linking errors putting in mind that Boost debug library only need to be included as header files, rather than linking against as a library!
Any ideas?!
OK, I figured out what the problem is. Apparently, the list of files mentioned in Boost's website misses the following files:
debug.cpp
test_main.cpp
test_tools.cpp
Once I added those files to my project, the test project compiled and run successfully!
UPDATE: Just wanted to mention that I actually built against Boost 1.51, so it could be that the documentation is a bit old, because I can see that in the page, they are linking the files to Boost 1.35!
For compile unit-tests of boots 1.57 on windows,
I use #Rafid answer,
For me it was add this files to projects:
test_tools.cpp
unit_test_main.cpp
framework.cpp
That locate in BOOST_DIR/libs/test/src
I'm trying to build a small command line BitTorrent client using Rasterbar's libtorrent, which depends on Boost. I've built both the Boost libraries and the libtorrent library using their respective directions, but when I try to build my project I get the following linking errors
1>------ Build started: Project: MiniBT, Configuration: Debug Win32 ------
1>MiniBT.obj : error LNK2019: unresolved external symbol "protected: static void __cdecl boost::asio::detail::winsock_init_base::throw_on_error(struct boost::asio::detail::winsock_init_base::data &)" (?throw_on_error#winsock_init_base#detail#asio#boost##KAXAAUdata#1234##Z) referenced in function "public: __thiscall boost::asio::detail::winsock_init<2,0>::winsock_init<2,0>(bool)" (??0?$winsock_init#$01$0A##detail#asio#boost##QAE#_N#Z)
1>MiniBT.obj : error LNK2019: unresolved external symbol "protected: static void __cdecl boost::asio::detail::winsock_init_base::startup(struct boost::asio::detail::winsock_init_base::data &,unsigned char,unsigned char)" (?startup#winsock_init_base#detail#asio#boost##KAXAAUdata#1234#EE#Z) referenced in function "public: __thiscall boost::asio::detail::winsock_init<2,0>::winsock_init<2,0>(bool)" (??0?$winsock_init#$01$0A##detail#asio#boost##QAE#_N#Z)
1>MiniBT.obj : error LNK2019: unresolved external symbol "class boost::system::error_category const & __cdecl boost::asio::error::get_misc_category(void)" (?get_misc_category#error#asio#boost##YAABVerror_category#system#3#XZ) referenced in function "void __cdecl boost::asio::error::`dynamic initializer for 'misc_category''(void)" (??__Emisc_category#error#asio#boost##YAXXZ)
1>MiniBT.obj : error LNK2019: unresolved external symbol "unsigned long __cdecl boost::asio::detail::win_tss_ptr_create(void)" (?win_tss_ptr_create#detail#asio#boost##YAKXZ) referenced in function "public: __thiscall boost::asio::detail::win_tss_ptr<class boost::asio::detail::call_stack<class boost::asio::detail::win_iocp_io_service,unsigned char>::context>::win_tss_ptr<class boost::asio::detail::call_stack<class boost::asio::detail::win_iocp_io_service,unsigned char>::context>(void)" (??0?$win_tss_ptr#Vcontext#?$call_stack#Vwin_iocp_io_service#detail#asio#boost##E#detail#asio#boost###detail#asio#boost##QAE#XZ)
1>MiniBT.obj : error LNK2019: unresolved external symbol "protected: static void __cdecl boost::asio::detail::winsock_init_base::cleanup(struct boost::asio::detail::winsock_init_base::data &)" (?cleanup#winsock_init_base#detail#asio#boost##KAXAAUdata#1234##Z) referenced in function "public: __thiscall boost::asio::detail::winsock_init<2,0>::~winsock_init<2,0>(void)" (??1?$winsock_init#$01$0A##detail#asio#boost##QAE#XZ)
It seems to indicate that the asio::detail namespace didn't get included in the boost-system library as it is only those 5 symbols that it seems to have a problem with and it is linking to the boost-system library just fine otherwise. I'm trying to build a 32-bit application on a 64-bit system, but everything I've checked seems to be correctly configured for this.
I know I'm missing something, but I can't seem to figure out what. Does anyone have any suggestions?
With BOOST_ASIO_SEPARATE_COMPILATION defined, in addition to #include "boost/asio/ssl/impl/src.hpp", you must also #include "boost/asio/impl/src.hpp" in one of your cpp files.
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.
I am converting my project from vc6 to VS 2010.When I compile my project i get error as below for may .lib inputs. I have added all these lib in the Linker-> Input-> Additional Dependencies, also provided the path of these .lib files in Link->General->Additional Library directories. Any tip on this will be very helpful.
lb0.lib(ob0.obj) :error LNK2001: unresolved external symbol "void __stdcall SetLastExP(class ExceptionClass *)" (?SetLastExP##YGXPAVExceptionClass###Z)
lb1.lib(ob1.obj) : error LNK2001: unresolved external symbol "void __stdcall SetLastExP(class ExceptionClass *)" (?SetLastExP##YGXPAVExceptionClass###Z)
lb2.lib(ob2.obj) : error LNK2001: unresolved external symbol "void __stdcall SetLastExP(class ExceptionClass *)" (?SetLastExP##YGXPAVExceptionClass###Z)
lb3.lib(ob3.obj) : error LNK2001: unresolved external symbol "void __stdcall SetLastExP(class ExceptionClass *)" (?SetLastExP##YGXPAVExceptionClass###Z)
lb3.lib(ob4.obj) : error LNK2001: unresolved external symbol "void __stdcall SetLastExP(class ExceptionClass *)" (?SetLastExP##YGXPAVExceptionClass###Z)
lb3.lib(ob5.obj) : error LNK2001: unresolved external symbol "void __stdcall SetLastExP(class ExceptionClass *)" (?SetLastExP##YGXPAVExceptionClass###Z)
lb4.lib(0b6.obj) : error LNK2001: unresolved external symbol "void __stdcall SetLastExP(class ExceptionClass *)" (?SetLastExP##YGXPAVExceptionClass###Z)
Thanks
You need to identify where the SetLastExP() function is defined.
Check that the library that implements SetLastExP is linked.
Get the .obj file and check with dumpbin if it implements in the decoration that you expect.
dumpbin /symbols foo.obj | find "External" | find "SetLastExP"
Compare the decoration you see with the decoration you have in the Linker error message.
Probably the function is defined as extern "C" while your header file doesn't reflect this.
Sometimes, if you have different Character sets (Configuration properties -> general) in your subprojects, Visual Studio shows this kind of error:
error LNK2001: unresolved external symbol" with an *.obj