如果没有主电话,pthread就无法链接

时间:2014-06-25 02:04:09

标签: c++

我一直在尝试使用angelscript而且我一直在收到链接器错误,但是如果我在main函数的末尾添加对pthread_exit(NULL)的引用,它会构建,链接并正常运行。

以下是相关代码:

#include <iostream>
#include <angelscript.h>
#include <cassert>

// This is used for AngelScript error messages
void MessageCallback(const asSMessageInfo &msg)
{
    const char *type = "ERR ";
    if( msg.type == asMSGTYPE_WARNING )
    {
        type = "WARN";
    }
    else if( msg.type == asMSGTYPE_INFORMATION )
    {
        type = "INFO";
    }

    std::cout << msg.section << " (" << msg.row << ", " << msg.col << ") : " << type << " : " << msg.message << std::endl;
}

int main(void)
{
    asIScriptEngine* engine = asCreateScriptEngine(ANGELSCRIPT_VERSION);

    int r = engine->SetMessageCallback(asFUNCTION(MessageCallback), 0, asCALL_CDECL);
    assert(r >= 0);

    std::cout << "Testing" << std::endl;

    engine->Release();
    pthread_exit(NULL);
    return 0;
}

这是命令行:

g++ -Wl,-O1,--sort-common,--as-needed,-z,relro -Wl,-O1 -o fib main.o   -langelscript -lpthread 

任何想法?

0 个答案:

没有答案