Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Visual Studio & Boost C++ build problem

Posted on 2008-10-25
6
Medium Priority
?
2,325 Views
Last Modified: 2013-11-26
Hi Experts!

I am trying to build a C++ project in Visual Studio 2005 that makes use of the Boost C++ threading libraries. However, I am getting a series of LNK2019 errors shown in the code snippet. I asked someone how to get around this problem, and they said:

"Enable the define DBOOST_LIB_DIAGNOSTIC and see if it is properly auto-linking to the correct boost library (libboost_threads in this case). If you are building on win64, you will need to also define DBOOST_BIND_ENABLE_STDCALL."

I am indeed trying to build on win64, but don't understand how to apply said solution. Could I please get some help? Thank you.
1>GPUWorker.obj : error LNK2019: unresolved external symbol "public: void __cdecl boost::thread::join(void)" (?join@thread@boost@@QEAAXXZ) referenced in function "public: __cdecl GPUWorker::~GPUWorker(void)" (??1GPUWorker@@QEAA@XZ)
1>.....
1>.....
1>../../bin/win64/Debug/simpleMultiGPU.exe : fatal error LNK1120: 11 unresolved externals

Open in new window

0
Comment
Question by:Vense
  • 3
  • 2
6 Comments
 
LVL 17

Expert Comment

by:CSecurity
ID: 22804103
Did you added pragma comment to boost lib files?

#pragma comment(lib, "BOOSTLIBNAMEHERE.LIB")

You need to add it after your #includes
0
 

Author Comment

by:Vense
ID: 22804948
Unfortunately that didn't change any of the error messages. I'm not very skilled with the linker, so I just don't understand how to try what is in quoted text.
0
 
LVL 17

Accepted Solution

by:
CSecurity earned 750 total points
ID: 22806448
Check boost LIB folder or any location boost have *.lib files, find one that you use, maybe something like boost_thread.lib, then put that in quotes.

0
NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

 
LVL 17

Expert Comment

by:CSecurity
ID: 22806454
Also don't forget Boost LIB and Include folders should be defined in directories of Visual Studio...

That is in Tools -> Options -> Directories (something like that)

You need to add Boost Include folder into Includes of Visual Studio and Boot Lib folder into Lib folders of Visual Studio.
0
 
LVL 1

Assisted Solution

by:sridhard
sridhard earned 750 total points
ID: 22821682
Hi,

Confirm your library  and your project(simpleMultiGPU) are compiled with Multi-threaded (/MT ) or Multi-threaded Debug (/MTd) option in "Configuration properties -> C++ -> Code Generation -> Runtime Library"

Also you can confirm whether  you have included the library file under your simpleMultiGPU projects "Configuration properties -> Linker -> Input -> Additional Dependencies"

Regards,
Sri
0
 

Author Comment

by:Vense
ID: 22847414
Thanks for the responses guys. However the errors are still occurring. This is the full error output:

1>GPUWorker.obj : error LNK2019: unresolved external symbol "public: void __cdecl boost::thread::join(void)" (?join@thread@boost@@QEAAXXZ) referenced in function "public: __cdecl GPUWorker::~GPUWorker(void)" (??1GPUWorker@@QEAA@XZ)
1>GPUWorker.obj : error LNK2019: unresolved external symbol "public: __cdecl boost::thread_resource_error::thread_resource_error(void)" (??0thread_resource_error@boost@@QEAA@XZ) referenced in function "void * __cdecl boost::detail::win32::create_anonymous_event(enum boost::detail::win32::event_type,enum boost::detail::win32::initial_event_state)" (?create_anonymous_event@win32@detail@boost@@YAPEAXW4event_type@123@W4initial_event_state@123@@Z)
1>GPUWorker.obj : error LNK2001: unresolved external symbol "public: virtual __cdecl boost::thread_resource_error::~thread_resource_error(void)" (??1thread_resource_error@boost@@UEAA@XZ)
1>GPUWorker.obj : error LNK2001: unresolved external symbol "public: virtual char const * __cdecl boost::thread_resource_error::what(void)const " (?what@thread_resource_error@boost@@UEBAPEBDXZ)
1>GPUWorker.obj : error LNK2019: unresolved external symbol "public: virtual __cdecl boost::thread_exception::~thread_exception(void)" (??1thread_exception@boost@@UEAA@XZ) referenced in function "public: virtual void * __cdecl boost::thread_exception::`scalar deleting destructor'(unsigned int)" (??_Gthread_exception@boost@@UEAAPEAXI@Z)
1>GPUWorker.obj : error LNK2019: unresolved external symbol "public: __cdecl boost::lock_error::lock_error(void)" (??0lock_error@boost@@QEAA@XZ) referenced in function "public: void __cdecl boost::unique_lock<class boost::mutex>::lock(void)" (?lock@?$unique_lock@Vmutex@boost@@@boost@@QEAAXXZ)
1>GPUWorker.obj : error LNK2001: unresolved external symbol "public: virtual __cdecl boost::lock_error::~lock_error(void)" (??1lock_error@boost@@UEAA@XZ)
1>GPUWorker.obj : error LNK2001: unresolved external symbol "public: virtual char const * __cdecl boost::lock_error::what(void)const " (?what@lock_error@boost@@UEBAPEBDXZ)
1>GPUWorker.obj : error LNK2019: unresolved external symbol "private: void __cdecl boost::thread::start_thread(void)" (?start_thread@thread@boost@@AEAAXXZ) referenced in function "public: __cdecl boost::thread::thread<class boost::_bi::bind_t<void,class boost::_mfi::mf0<void,class GPUWorker>,class boost::_bi::list1<class boost::_bi::value<class GPUWorker *> > > >(class boost::_bi::bind_t<void,class boost::_mfi::mf0<void,class GPUWorker>,class boost::_bi::list1<class boost::_bi::value<class GPUWorker *> > >)" (??$?0V?$bind_t@XV?$mf0@XVGPUWorker@@@_mfi@boost@@V?$list1@V?$value@PEAVGPUWorker@@@_bi@boost@@@_bi@3@@_bi@boost@@@thread@boost@@QEAA@V?$bind_t@XV?$mf0@XVGPUWorker@@@_mfi@boost@@V?$list1@V?$value@PEAVGPUWorker@@@_bi@boost@@@_bi@3@@_bi@1@@Z)
1>GPUWorker.obj : error LNK2019: unresolved external symbol "bool __cdecl boost::this_thread::interruptible_wait(void *,struct boost::detail::timeout)" (?interruptible_wait@this_thread@boost@@YA_NPEAXUtimeout@detail@2@@Z) referenced in function "protected: bool __cdecl boost::detail::basic_condition_variable::do_wait<class boost::unique_lock<class boost::mutex> >(class boost::unique_lock<class boost::mutex> &,struct boost::detail::timeout)" (??$do_wait@V?$unique_lock@Vmutex@boost@@@boost@@@basic_condition_variable@detail@boost@@IEAA_NAEAV?$unique_lock@Vmutex@boost@@@2@Utimeout@12@@Z)
1>GPUWorker.obj : error LNK2019: unresolved external symbol "public: __cdecl boost::thread::~thread(void)" (??1thread@boost@@QEAA@XZ) referenced in function "public: void * __cdecl boost::thread::`scalar deleting destructor'(unsigned int)" (??_Gthread@boost@@QEAAPEAXI@Z)
1>../../bin/win64/Debug/simpleMultiGPU.exe : fatal error LNK1120: 11 unresolved externals

I've had linker trouble in the past but this time it seems much worst ;(
0

Featured Post

[Webinar] Database Backup and Recovery

Does your company store data on premises, off site, in the cloud, or a combination of these? If you answered “yes”, you need a data backup recovery plan that fits each and every platform. Watch now as as Percona teaches us how to build agile data backup recovery plan.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes relatively difficult and non-obvious issues that are likely to arise when creating COM class in Visual Studio and deploying it by professional MSI-authoring tools. It is assumed that the reader is already familiar with the cla…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.
Suggested Courses

581 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question