Boost logo

Boost Users :

Subject: [Boost-users] [Boost::Thread] Unable to declare boost::thread in a dll problem
From: kmdarkmaster (kmdarkmaster_at_[hidden])
Date: 2011-06-09 10:48:04


Hello,

Please help me I have a weird problem while testing Boost::Thread. I can
create threads and do stuffs without problem when compiled as an exe, but
unable to declare even a single thread when compiled as a dll. (I'm using MS
Visual Studio 2010 pro).

In fact, when I create a win32 console application and use this code, it
compiles perfectly :

/*********************coooooode*********************/

#include "stdafx.h"
#include <boost\thread.hpp>

int _tmain(int argc, _TCHAR* argv[])
{
        boost::thread myThread;
        return 0;
}

/**************************************************/

Now I create a DLL application, create a cpp, and write the same simple code
:

/********************coooooodddeee***********************/
#include "stdafx.h"
#include <boost\thread.hpp>

void testDLL_Thread(){
        boost::thread myThread;
}
/*******************************************************/

My DLL has the same boost configuration as the console app, and it doesn't
even export anything.
Now during compilation, i get those Linker error :

/************RAAAAGGGEE***************/

LNK1169: un ou plusieurs symboles définis à différentes reprises ont été
rencontrés
LNK2005: "public: __thiscall boost::thread::~thread(void)"
(??1thread_at_boost@@QAE_at_XZ) déjà défini(e) dans
boost_thread-vc100-mt-gd-1_46_1.lib(boost_thread-vc100-mt-gd-1_46_1.dll)
LNK2005: "public: __thiscall boost::thread::thread(void)"
(??0thread_at_boost@@QAE_at_XZ) déjà défini(e) dans
boost_thread-vc100-mt-gd-1_46_1.lib(boost_thread-vc100-mt-gd-1_46_1.dll)

/**************************************/

Sorry for the French stuffs but you guys know those errors for sure
I know that many people have already created threads in DLL, so please help
me understand why it didn't work in this simple case.

Thank you very much,

kmdarkmaster

--
View this message in context: http://boost.2283326.n4.nabble.com/Boost-Thread-Unable-to-declare-boost-thread-in-a-dll-problem-tp3585777p3585777.html
Sent from the Boost - Users mailing list archive at Nabble.com.

Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net