简体   繁体   中英

std::tr1::function gives linking error for x64 configuration in VS2008 SP1

Using std::tr1::function in x64 configuration, I get below linking error in VS2008SP1. The same code works correctly for Win32 configuration. Is this a bug in 64 bit compiler, or am I missing something?

#include <iostream>
#include <functional>

typedef std::tr1::function<void()> FnCallBack;

void test()
{
    std::cout << "Test";
}

int main(int argc, char* argv[])
{
    FnCallBack f = &test;

    f();

    return 0;
}

error LNK2019: unresolved external symbol "__declspec(dllimport) void __cdecl std::tr1:: Xfunc(void)" ( _imp_?_Xfunc@tr1@std@@YAXXZ) referenced in function "public: void __cdecl std::tr1::_Function_impl0::operator()(void)const " (??R?$_Function_impl0@X@tr1@std@@QEBAXXZ)

I met the same issue with you! and I checked my vs2008 version and project settings, looks all are OK. at Win32 configuration , there is no error but X64 I got the link error samed with you.

At last, I install vs2008 sp1 again (note: not re-install, just run vs2008 sp1 setup again). the link error disappeared.

I don't know why, but maybe you could try it to fix this issue.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM