Linking issue with boost mpi in Visual Studio - visual-studio-2010

I'm using Visual Studio 2010 and I've installed openmpi and boost. I've successfully managed to build the boost mpi libraries but when I try to run their example hello_world program I get linking errors like:
Error 16 error LNK2001: unresolved external symbol "public: void __cdecl boost::mpi::communicator::send(int,int,class boost::mpi::packed_oarchive const &)const " (??$send#Vpacked_oarchive#mpi#boost###communicator#mpi#boost##QEBAXHHAEBVpacked_oarchive#12##Z) C:\Dropbox\mpi_tess\MPITess\hello_world.obj
I've included the build lib files into the linker path. Any ideas what's wrong?
Thanks for the help,
Elad

Related

Linking tesseract and opencv in Visual Studio 2013 on x64 bit machine

I'm trying to run a program based on tesseract and opencv on Visual Studio 2013. I have a x64 bit machine and the problem is when I run it under Win32 I got only opencv linking errors, however under x64 I got tesseract linking errors.
Here are some errors screenshots :
Tesseract Errors :
error LNK2001: unresolved external symbol pixDestroy
error LNK2001: unresolved external symbol pixReadTesseract
error LNK1120: 7 unresolved externals
Opencv Errors :
error LNK2001: unresolved external symbol _cvLoadImage
error LNK2001: unresolved external symbol _cvCreateImage
error LNK2001: unresolved external symbol _cvSaveImage
error LNK2001: unresolved external symbol _cvReleaseImage
error LNK1120: 4 unresolved externals
Thank you guys :-)
Your problem appears to be that you have 32bit build of Tesseract and 64bit build of OpenCV, and trying to use them both in the same program. That will not work -- you either need all 64bit libraries for a 64bit application, or all 32bit libraries for a 32bit application.
If you want to stick with OpenCV 3.1 (since the standard distribution package doesn't seem to contain 32bit binaries), then you have to go and build one of the libraries yourself. The older versions still had them.
Another option is to download this nuget package along with the associated redistributables package. Since the files are just ZIP files with a different extension, it is possible to extract all the headers, import libraries and DLLs manually.

Linker errors (LNK2001) with Boost library (filesystem.hpp) in CLI/CLR code

I have been trying to figure this out for a few days and can't seem to find a solution. I am creating a Windows Forms application inside of MSVS 2012 (but the application itself is using MSVS 2010 binaries and .NET 4.0). The application requires the use of CLI/CLR managed code.
I have followed the Getting Started guide and built the libraries using:
bootstrap.bat
.\b2.exe --toolset=msvc-10.0 --build-type=complete
I setup/linked the directories to my project inside of Visual Studio:
C/C++ > General > Additional Include Directories > "C:\Program Files %28x86%29\Microsoft Visual Studio 11.0\Boost"
Linker > General > Additional Library Directories > "C:\Program Files %28x86%29\Microsoft Visual Studio 11.0\Boost\stage\lib"
Here is all that I added to my previously compiling and executing code:
#define BOOST_LIB_DIAGNOSTIC //show diagnostics
#define BOOST_USE_WINDOWS_H
#define BOOST_FILESYSTEM_NO_DEPRECATED //don't use deprecated code
#include <boost/filesystem.hpp>
using namespace boost::filesystem;
Here is the output of the build (Release/Win32):
1>------ Build started: Project: PROJECT_NAME (Visual Studio 2010), Configuration: Release Win32 ------
1> PROJECT_NAME.cpp
1> Linking to lib file: libboost_filesystem-vc100-mt-1_53.lib
1> Linking to lib file: libboost_system-vc100-mt-1_53.lib
1>PROEJCT_NAME.obj : error LNK2001: unresolved external symbol "class boost::system::error_category const & __clrcall boost::system::system_category(void)" (?system_category#system#boost##$$FYMABVerror_category#12#XZ)
1>PROJECT_NAME.obj : error LNK2001: unresolved external symbol "class boost::system::error_category const & __clrcall boost::system::generic_category(void)" (?generic_category#system#boost##$$FYMABVerror_category#12#XZ)
1>PROJECT_NAME.obj : error LNK2001: unresolved external symbol "void __clrcall boost::filesystem::path_traits::convert(wchar_t const *,wchar_t const *,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > &,class std::codecvt<wchar_t,char,int> const &)" (?convert#path_traits#filesystem#boost##$$FYMXPB_W0AAV?$basic_string#DU?$char_traits#D#std##V?$allocator#D#2##std##ABV?$codecvt#_WDH#5##Z)
1>PROJECT_NAME.obj : error LNK2001: unresolved external symbol "public: static class std::codecvt<wchar_t,char,int> const & __clrcall boost::filesystem::path::codecvt(void)" (?codecvt#path#filesystem#boost##$$FSMABV?$codecvt#_WDH#std##XZ)
1>PROJECT_NAME.obj : error LNK2001: unresolved external symbol "class boost::system::error_code __clrcall boost::filesystem::detail::dir_itr_close(void * &)" (?dir_itr_close#detail#filesystem#boost##$$FYM?AVerror_code#system#3#AAPAX#Z)
1>C:\Users\USERNAME\Documents\Visual Studio 2012\Projects\PROJECT_NAME\Release\PROJECT_NAME.exe : fatal error LNK1120: 5 unresolved externals
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
Do I still not have something built/linked correctly? Let me know if there's more information needed and I will supply what I can.
Reviving an old post, I know, but I spent a long time trying to figure out a similar issue, so I'm posting for the next person who comes across similar issues.
For this to work, you'll need to build Boost with VS2012 or download it from Teeks99 or Sourceforge. I was unable to make it work with VS2010.
Change the Platform Toolset to Visual Studio 2012 (v110) in the Project configuration properties. That worked for me when I was trying to figure out a similar problem (#include <boost/filesystem.hpp> in a VS2010 minimal example code). Make sure that the Common Language Runtime Support is set to /clr (NOT /clr:pure).

Visual Studio 2010 linking errors using VTK

I'm having trouble to compile VTK 5.10.1 example code in Visual Studio 2010 on Windows 7 64 bit SP1.
First of all, I installed VTK using this tutorial.
No errors occured while installing VTK and the example executables like cone.exe located at C:\VTK5.10.1_cmake\bin\Release are running just fine.
In Visual Studio 2010 I started a new Win32 console application and tested the first example code from this site.
I edited the projekt properties (additional include directories, additional Library directories and additional dependencies).
The linker errors looked like that:
vtktest.obj : error LNK2019: unresolved external symbol ""public: void __thiscall vtkRenderer::AddActor(class vtkProp *)" (?AddActor#vtkRenderer##QAEXPAVvtkProp###Z)" referenced in function "_main".
Most of the the other people with the same error forgot to add the libs to the additional dependencies.
However I added all libs in the C:\VTK5.10.1_bin\lib\vtk-5.10 directory and the opengl32 library. I tried to seperate the libs by a space, a semicolon and a new line.
Then, I read that people are using the shared libraries. I'm not really familiar with dlls. I reinstalled VTK
with shared libraries options turned on and copied the resulting dlls to the System32 directory.
Now, the errors looks slightly different:
vtktest.obj : error LNK2019: unresolved external symbol ""__declspec(dllimport) public: void __thiscall vtkRenderer::AddActor(class vtkProp *)" (__imp_?AddActor#vtkRenderer##QAEXPAVvtkProp###Z)" referenced in function "_main".
Any help would be appriciated!
Nevermind, forgot to change the platform to x64 :/

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.

linking with boost unresolved extern link error

Visual Studio 2005
I am linking with boost libraries release 1_33_1.
I keep getting this link error.
libboost_thread-vc80-mt-sgd-1_33_1.lib(once.obj) :error LNK2001: unresolved external symbol "public: void __thiscall std::_String_base::_Xran(void)const " (?_Xran#_String_base#std##QBEXXZ)
Does anyone have any suggestions?
Many thanks,
Edit ======
After recompiling the boost libraries using these switches:
C:\boost_1_42_0>bjam --build-dir=d:\boost_1_42 --build-type-complete --toolset=msvc-8.0 address-model=32 architecture=x86
I am getting some of the following errors:
1>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 LIBCMTD.lib(typinfo.obj)
1>msvcrtd.lib(MSVCR80D.dll) : error LNK2005: __wassert already defined in LIBCMTD.lib(wassert.obj)
Anyone have any ideas?
Many thanks,
First of all you don't have to set address-model and architecture explicitly if building 32 bit. Also your call has an error: --build-type-complete should be --build-type=complete. If I'm not wrong your call builds absolutely all libs, including filesystem, regex etc.
Obviously you need boost::thread only, so I would recommend to try this call:
C:\boost_1_42_0>bjam --build-dir=d:\boost_1_42 --build-type=complete --toolset=msvc-8.0 --with-thread
But I don't think that will solve your prob but you could give it a try.
My guess is that you somehow mixed /MD and /MT in the project settings.
See these links: First, second
What is probably happening is that your project is linking to the static debug version of the C++ runtime, which causes the static debug boost thread library to be linked and is also linking to another static library which was dynamically linked to the C++ runtime.
The sgd tag in libboost_thread-vc80-mt-sgd-1_33_1.lib means that the boost thread library you're linking with was built against the static debug version of the C++ runtime.

Resources