code块,MinGW的,升压和静态连接问题 [英] Code Blocks, MinGW, Boost, and static linking issues
问题描述
我使用的使用MinGW code块,我试图得到一个简单的程序来编译静态链接。我已经建立了使用这些路线 Boost库。一切工作正常,我能够成功编译这个简单的程序(汇编,我知道这是行不通的,因为它是退出发送到控制台的消息之前,但我只是希望它编译)。
如果我在链接库中有一个DLL,它编译罚款,但是当我有相同内容的静态.A库打开它,我得到了一个未定义的引用,如未定义参考`_imp ___ ZN5boost6threadD1Ev|
我不知道是什么问题,不能找到解决方案。我想这可能与连接器设置做的,但我不能找到如何更改这些信息。我将是可以提供的任何帮助非常感激。
的#include<&iostream的GT;
#包括LT&;升压/ thread.hpp>无效MyFunction的()
{
性病::法院LT&;< 这是一个线程<<的std :: ENDL;
返回;
}诠释的main()
{
提高::线程MyThread的(安培; MyFunction的);
返回0;}
这是一个从尝试时,头被配置为一个动态链接静态链接。我解释一下这个在<一个libssh href=\"http://stackoverflow.com/questions/3704374/linking-error-lnk2019-in-msvc-unresolved-symbols-with-imp-$p$pfix-but-should/3714112#3714112\">this问题。在升压/线程/细节/ config.hpp
闲逛让我觉得你应该的#define BOOST_THREAD_USE_LIB
,或使用 -D
标记来这样做。
I am using Code Blocks with MinGW and am trying to get a simple program to compile with static linking. I have built the Boost libraries using these directions. 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 can't find the solution. I think it might have to do with linker settings but I can't find information on how to change them. I would be extremely grateful 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;
}
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.
这篇关于code块,MinGW的,升压和静态连接问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!