Subject: Re: [Boost-bugs] [Boost C++ Libraries] #2226: boost::thread 1.36.0 /clr Link Error LNK2022
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2008-12-13 16:50:04
#2226: boost::thread 1.36.0 /clr Link Error LNK2022
-----------------------------------------+----------------------------------
Reporter: benjamin.sternlieb_at_[hidden] | Owner: anthonyw
Type: Bugs | Status: new
Milestone: Boost 1.36.0 | Component: thread
Version: Boost 1.37.0 | Severity: Showstopper
Resolution: | Keywords: clr dummy thread LNK2022
-----------------------------------------+----------------------------------
Changes (by Tom Kent <teeks99_at_[hidden]>):
* cc: teeks99_at_[hidden] (added)
* version: Boost 1.36.0 => Boost 1.37.0
Comment:
I have an update, and a somewhat more complicated example....
http://www.teeks99.com/BoostManagedTest.zip
I found that some parts of the boost library (like sleep()) can be used
(but only when linked dynamically! with a .dll, no static libs). Also,
this bug verified to be still present in 1.37.0.
Here's my code:
{{{
// This demonstrates where boost's thread library is incompatible with
Visual
// Studio 2005's (and presumably the other versions as well) /clr option.
// This project was created with the Visual Studio wizard for a native
console
// application. The path to the boost folder was added to all
configurations'
// "Additional Include Directories" and the path to the boost libraries
was
// added to all configurations' "Additional Library Directories".
// The Configuration manager was then used to copy the Debug and Release
// configurations to the Debug-CLR and Release-CLR configurations. Then
the
// "Common Language Runtime Support" option for these two new
configurations
// was set to /clr.
// Finally I copied the boost_thread-vc80-mt-1_37.dll and
// boost_thread-vc80-mt-gd-1_37.dll to both configurations output
directories.
// I have setup several test cases (listed below) to outline a couple
issues
// where there are incompatabilities. All cases run fine in the Debug and
// Release configurations, when in the Debug-CLR or Release-CLR
configurations
// the following issues are found.
// Define one of these cases to see the test
// CASE1 - No use of boost threadding...everything works
// CASE2 - Use boost threadding for the sleep() function, static
link...fails at
// runtime "The application failed to initialize properly
(0xc000007b).
// Click on OK to terminate the application." in both Debug and
Release.
// CASE3 - Use boost threadding for the sleep() function, dynamic
link....works
// CASE4 - Use boost threadding for thread creation/rejoin, static
link...fails
// at compile time "BoostManagedTest.obj : error LNK2022: metadata
// operation failed (8013119F) : A TypeRef exists which should,
but does
// not, have a corresponding TypeDef: (dummy): (0x01000019)." in
both
// Debug and Release.
// CASE5 - Use boost threadding for thread creation/rejoin, dynamic
link...fails
// at compile time "BoostManagedTest.obj : error LNK2022: metadata
// operation failed (8013119F) : A TypeRef exists which should,
but does
// not, have a corresponding TypeDef: (dummy): (0x01000019)." in
both
// Debug and Release.
#define CASE1
// ----------- CASE SETUP -----------
#ifdef CASE2
# define THREAD_ENABLED
#endif
#ifdef CASE3
# define THREAD_ENABLED
# define DYNAMIC_LINK
#endif
#ifdef CASE4
# define THREAD_ENABLED
# define THREAD_CREATION
#endif
#ifdef CASE5
# define THREAD_ENABLED
# define THREAD_CREATION
# define DYNAMIC_LINK
#endif
// ----------- CASE SETUP -----------
#ifdef THREAD_ENABLED
# ifdef DYNAMIC_LINK
#define BOOST_THREAD_USE_DLL
# endif //DYNAMIC_LINK
#include <boost/thread.hpp>
#else if
#include <windows.h>
#endif // THREAD_ENABLED
#include <iostream>
class Spinner{
public:
void operator() () {
int threadSleepLength = 100;
for(int counter=0; counter < 5; ) {
std::cout << "tick " << ++counter << std::endl;
#ifdef THREAD_ENABLED
boost::this_thread::sleep(boost::posix_time::millisec(threadSleepLength));
#else if // Use window's sleep
Sleep(threadSleepLength);
#endif // THREAD_ENABLED
}
}
};
int main(int argc, char* argv[]){
Spinner spin;
#ifdef THREAD_CREATION
boost::thread spnThread(spin);
spnThread.join();
#else if
spin ();
#endif //THREAD_CREATION
return 0;
}
}}}
-- Ticket URL: <https://svn.boost.org/trac/boost/ticket/2226#comment:1> Boost C++ Libraries <http://www.boost.org/> Boost provides free peer-reviewed portable C++ source libraries.
This archive was generated by hypermail 2.1.7 : 2017-02-16 18:49:59 UTC