views:

116

answers:

1

I am using Code Blocks with mingw and am trying to get a simple program to compile with static linking. I have build the boost libraries using these directions, here. Everything worked out fine and i was able to successfully compile this simple program (it compiles, i know it doesn't work because it exits before the message is sent to the console, but i just want it to compile). If i have a DLL in my linker libraries, it compiles fine, but when i switch it with the static .a libraries of the same contents, I get undefined references such as "undefined reference to `imp__ZN5boost6threadD1Ev'|". I have no idea what the problem is and cant find the solution. I think i might have to do with linker settings but i cant find information on how to change them. I would be extremely great full for any help that could be provided.

#include <iostream>
#include <boost/thread.hpp>

void myfunction()
{
    std::cout << "this is a thread" << std::endl;
    return;
}

int main()
{
    boost::thread mythread(&myfunction);
    return 0;

}
A: 

It's from trying to link statically when the headers are configured for a dynamic link. I explain this for libssh in this question. Poking around in boost/thread/detail/config.hpp makes me think you should #define BOOST_THREAD_USE_LIB, or use the -D flag to do the same.

Jack Kelly