Hi all,
I'm starting to use boost for the first time now, but I'm having
problems linking to the thread library (libboost_thread.lib) from
within Visual C++.
Using my main compiler, VC++ 6.0, I get the following linker error:
libboost_thread.lib(exceptions.obj) : error LNK2001: unresolved
external symbol "__declspec(dllimport) public: __thiscall
std::basic_string
cadenzajon wrote:
Hi all, ...
Using my main compiler, VC++ 6.0, I get the following linker error: libboost_thread.lib(exceptions.obj) : error LNK2001: unresolved external symbol "__declspec(dllimport) public: __thiscall std::basic_string
::basic_string (char const *)" ... Does anybody have any experience with this or ideas on what I could be doing wrong? I'm just starting to do multi-platform software design, and boost::thread would be a godsend! Thanks,
Jonathan
We have recently started to use boost in Windows and we have had a similar problem. After some tries, we have sucesfully made a Multithreaded Console Application doing this: In C/C++ -> Code Generation -> Use run-time library select Debug Multithreaded DLL In C/C++ -> C++ Language select Enable RTTI In Link -> Input -> Object/Library modules clean all the entries (leave it blank) In Link -> Input -> Ignore Libraries set: libcmtd.lib, libcmt.lib, libcd.lib, libc.lib In the "Source Files" folder of the File View add libboost_thread.lib. We have never tried to do something else than a "Multithreaded Console Application". By the way, the conditional variables doesn't seems to work in the 1.26.0 version of the library. We are using pthreads and boost to make our programs. Hope you find this useful. -- Raúl Huertas Díaz Redes y Comunicaciones Ingeniero de Sistemas TCP Sistemas e Ingenieria Fernández Caro, 7, 3ª planta Tel.: +34 91 367 32 79 (Ext. 535) Fax: +34 91 407 71 39 rhuertas@tcpsi.es http://www.tcpsi.es [Non-text portions of this message have been removed]
--- In Boost-Users@y..., Raul Huertas
We have recently started to use boost in Windows and we have had a similar problem. After some tries, we have sucesfully made a Multithreaded Console Application doing this:
In C/C++ -> Code Generation -> Use run-time library select Debug Multithreaded DLL
I'm 99% sure this was the only problem.
In C/C++ -> C++ Language select Enable RTTI
A good idea in general.
In Link -> Input -> Object/Library modules clean all the entries (leave it blank)
This shouldn't be necessary.
In Link -> Input -> Ignore Libraries set: libcmtd.lib, libcmt.lib, libcd.lib, libc.lib
In the "Source Files" folder of the File View add
I'm also not sure that this should be necessary. libboost_thread.lib.
We have never tried to do something else than a "Multithreaded
Console
Application".
Should be no different.
By the way, the conditional variables doesn't seems to work in the 1.26.0 version of the library. We are using pthreads and boost to make our programs.
The examples and test harness work fine. However, there was a bug that would cause occasional deadlock when calling notify_one() under certain conditions. This has been fixed and is in the CVS repository now. Bill Kempf
Thank you all for your prompt responses. I comment further below:
We have recently started to use boost in Windows and we have had a similar problem. After some tries, we have sucesfully made a Multithreaded Console Application doing this:
In C/C++ -> Code Generation -> Use run-time library select Debug Multithreaded DLL
I'm 99% sure this was the only problem.
I already was using the multithreaded libraries. If I had select single-threaded libraries, the boost::thread hpp files would have generated a compiler error.
In C/C++ -> C++ Language select Enable RTTI
A good idea in general.
I had already enabled RTTI.
In Link -> Input -> Object/Library modules clean all the entries (leave it blank)
This shouldn't be necessary.
This was already blank.
In Link -> Input -> Ignore Libraries set: libcmtd.lib, libcmt.lib, libcd.lib, libc.lib
I'm also not sure that this should be necessary.
This was interesting. On Visual C++ 6.0, it did not make any difference to the linker output. On Visual C++ .NET, it removed all the 'multiply defined symbol' errors except for those relating to three basic_string constructors and basic_string::c_str(). (It solved MOST of the problem, but didn't take care of everything.) However, if I exclude the main C runtime library files from my build as you suggest, it seems like I would run into more problems later on when I try to use standard C functions. Again, my problem when linking with the library in VC6 is that libboost_thread.lib(exceptions.obj) has one unresolved external symbol for basic_string::basic_string(char const *). I'm still flummoxed. If you have more ideas, I would really appreciate them. Thanks, Jonathan
--- In Boost-Users@y..., "Jonathan Brownell"
Thank you all for your prompt responses. I comment further below:
We have recently started to use boost in Windows and we have had a similar problem. After some tries, we have sucesfully made a Multithreaded Console Application doing this:
In C/C++ -> Code Generation -> Use run-time library select Debug Multithreaded DLL
I'm 99% sure this was the only problem.
I already was using the multithreaded libraries. If I had select single-threaded libraries, the boost::thread hpp files would have generated a compiler error.
The key to what I said was _DLL_. There are two multi-threaded libraries, a LIB and a DLL version.
I'm still flummoxed. If you have more ideas, I would really appreciate them.
Insure you're linking against the multithreaded _DLL_ version of the run-time library. If you still have problems Zip up a small example project that's giving you problems and e-mail it to me. Bill Kempf
* Jonathan Brownell (alphaomega@proaxis.com) wrote:
Thank you all for your prompt responses. I comment further below:
[snip]
Again, my problem when linking with the library in VC6 is that libboost_thread.lib(exceptions.obj) has one unresolved external symbol for basic_string::basic_string(char const *).
I'm still flummoxed. If you have more ideas, I would really appreciate them.
Indeed, make sure that all the runtimes are the same. This means that
the selected runtime to build the DLL should match the runtime used to
build the client application. But most of the time this doesn't give any
build errors. It will give you strange runtime errors when trying to
delete some objects allocated by another runtime version.
I remember having a similar problem as the one you described, and the
trouble with the code at hand was mixing different header includes.
Allways #include <string>, NEVER use the deprecated #include
* Jonathan Brownell (alphaomega@p...) wrote:
Thank you all for your prompt responses. I comment further below:
[snip]
Again, my problem when linking with the library in VC6 is that libboost_thread.lib(exceptions.obj) has one unresolved external symbol for basic_string::basic_string(char const *).
I'm still flummoxed. If you have more ideas, I would really appreciate them.
Indeed, make sure that all the runtimes are the same. This means
--- In Boost-Users@y..., Manu Heirbaut
the selected runtime to build the DLL should match the runtime used to build the client application. But most of the time this doesn't give any build errors. It will give you strange runtime errors when trying to delete some objects allocated by another runtime version.
I remember having a similar problem as the one you described, and
trouble with the code at hand was mixing different header includes. Allways #include <string>, NEVER use the deprecated #include
(or at least, don't mix them!). The same goes for other standard
Usually the result will be link errors, actually. One of the few exceptions to this is mixing debug and release versions. the library
header files. Use <iostream> instead
, etc...
I hope this will solve your problem.
His problem has been solved. It was, as I suspected, that he was linking against the static runtime library. Bill Kempf
At 7:57 PM +0000 1/5/02, bill_kempf wrote:
is neither deprecated,
Appendix D.5 Standard C library headers [depr.c.headers] leads me to believe otherwise.
nor in any way related to <string>.
Agreed. -- Jon Kalb Kalb@LibertySoft.com
--- In Boost-Users@y..., Jon Kalb
At 7:57 PM +0000 1/5/02, bill_kempf wrote:
is neither deprecated, Appendix D.5 Standard C library headers [depr.c.headers] leads me to believe otherwise.
Splitting hairs.
--- In Boost-Users@y..., "bill_kempf"
--- In Boost-Users@y..., Jon Kalb
wrote: At 7:57 PM +0000 1/5/02, bill_kempf wrote:
is neither deprecated, Appendix D.5 Standard C library headers [depr.c.headers] leads me to believe otherwise.
Splitting hairs. ...
No. Consider: "These are deprecated features, where deprecated is defined as: Normative for the current edition of the Standard, but not guaranteed to be part of the Standard in future revisions." regards, alexander.
--- In Boost-Users@y..., "terekhov"
--- In Boost-Users@y..., "bill_kempf"
wrote: --- In Boost-Users@y..., Jon Kalb
wrote: At 7:57 PM +0000 1/5/02, bill_kempf wrote:
is neither deprecated, Appendix D.5 Standard C library headers [depr.c.headers] leads me to believe otherwise.
Splitting hairs. ...
No. Consider:
"These are deprecated features, where deprecated is defined as: Normative for the current edition of the Standard, but not guaranteed to be part of the Standard in future revisions."
But the features aren't deprecated, only the header is. In other
words all the features of the deprecated
--- In Boost-Users@y..., "bill_kempf"
--- In Boost-Users@y..., "terekhov"
wrote: --- In Boost-Users@y..., "bill_kempf"
wrote: --- In Boost-Users@y..., Jon Kalb
wrote: At 7:57 PM +0000 1/5/02, bill_kempf wrote:
is neither deprecated, Appendix D.5 Standard C library headers [depr.c.headers] leads me to believe otherwise.
Splitting hairs. ...
No. Consider:
"These are deprecated features, where deprecated is defined as: Normative for the current edition of the Standard, but not guaranteed to be part of the Standard in future revisions."
But the features aren't deprecated, only the header is. In other words all the features of the deprecated
will live on in the non-deprecated <cstring>.
But the code might "suddenly" stop compile (1st: missing
header; 2nd: global->std name space change) in X years
from now and our build/packaging folks just have no idea
what
--- In Boost-Users@y..., "terekhov"
--- In Boost-Users@y..., "bill_kempf"
wrote: --- In Boost-Users@y..., "terekhov"
wrote: --- In Boost-Users@y..., "bill_kempf"
wrote: --- In Boost-Users@y..., Jon Kalb
wrote: At 7:57 PM +0000 1/5/02, bill_kempf wrote:
is neither deprecated, Appendix D.5 Standard C library headers [depr.c.headers] leads me to believe otherwise.
Splitting hairs. ...
No. Consider:
"These are deprecated features, where deprecated is defined as: Normative for the current edition of the Standard, but not guaranteed to be part of the Standard in future revisions."
But the features aren't deprecated, only the header is. In other words all the features of the deprecated
will live on in the non-deprecated <cstring>. But the code might "suddenly" stop compile (1st: missing header; 2nd: global->std name space change) in X years from now and our build/packaging folks just have no idea what
/<cstring> is and even if they would know how to fix this "small" problem, they are not supposed/ allowed to modify my sources... so, do I want to get a call/fix it later? No! ;-)
This thread isn't really worth dragging on. I'll explain once more
and then bow out.
It was splitting hairs not because I'd correctly stated things. I
hadn't. The
--- In Boost-Users@y..., "cadenzajon"
Hi all,
I'm starting to use boost for the first time now, but I'm having problems linking to the thread library (libboost_thread.lib) from within Visual C++.
Using my main compiler, VC++ 6.0, I get the following linker error: libboost_thread.lib(exceptions.obj) : error LNK2001: unresolved external symbol "__declspec(dllimport) public: __thiscall std::basic_string
::basic_string (char const *)"
I'm 99% sure this is caused by not linking against the Multithreaded DLL version of the runtime library. (See another post here for exact directions on changing this.)
I checked the compiler compatibility tables online at the boost site, but they're not recent enough to include any details on the thread library.
Actually, they are recent enough. The problem is that the automated utilities used to generate this table aren't compatible with the structure of Boost.Threads. The Boost.Build system is attempting to address this problem and eventually Boost.Threads will be included in these tables.
When I use Visual C++ .NET (feel free to shrink away in horror) to test it, I get about 8 linker errors complaining that a handful of standard library functions (most dealing with the basic_string and exception classes) are being redefined by libboost_thread.lib.
Also probably caused by not linking against the multithreaded DLL version of the runtime library.
Does anybody have any experience with this or ideas on what I could be doing wrong? I'm just starting to do multi-platform software design, and boost::thread would be a godsend!
I hope this was enough to get you going. If not just ask more questions. Bill Kempf
participants (7)
-
bill_kempf
-
cadenzajon
-
Jon Kalb
-
Jonathan Brownell
-
Manu Heirbaut
-
Raul Huertas
-
terekhov