find_all_callback link error
От: Аноним  
Дата: 14.01.09 12:57
Оценка:
Привет,

test.cpp
#include "include/htmlayout.h"
#include "include/htmlayout_dom.hpp"

using namespace htmlayout::dom;

void test()
{
  element q(0);

  std::vector<element> zzz;
  q.find_all(zzz,"*");
}


main.cpp
#include "include/htmlayout.h"
#include "include/htmlayout_dom.hpp"

using namespace htmlayout::dom;

#pragma comment(lib,"lib/htmlayout.lib")

void test();

int main()
{
  element q(0);

  test();

  std::vector<element> zzz;
  q.find_all(zzz,"*");

  return 0;
}


cl /Zc:forScope /EHsc test.cpp main.cpp
Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 14.00.50727.762 for 80x86
Copyright (C) Microsoft Corporation.  All rights reserved.

test.cpp
main.cpp
Generating Code...
Microsoft (R) Incremental Linker Version 8.00.50727.762
Copyright (C) Microsoft Corporation.  All rights reserved.

/out:test.exe 
test.obj 
main.obj 
main.obj : error LNK2005: "public: __thiscall `public: void __cdecl htmlayout::dom::element::find_all<char>(class std::vector<class htmlayout::dom::element,class std::allocator<class htmlayout::dom::element> > &,char const *,...)const '::`2'::find_all_callback::find_all_callback(class std::vector<class htmlayout::dom::element,class std::allocator<class htmlayout::dom::element> > &)" (??0find_all_callback@?1???$find_all@D@element@dom@htmlayout@@QBAXAAV?$vector@Velement@dom@htmlayout@@V?$allocator@Velement@dom@htmlayout@@@std@@@std@@PBDZZ@QAE@0@Z) already defined in test.obj
main.obj : error LNK2005: "public: virtual __thiscall `public: void __cdecl htmlayout::dom::element::find_all<char>(class std::vector<class htmlayout::dom::element,class std::allocator<class htmlayout::dom::element> > &,char const *,...)const '::`2'::find_all_callback::~find_all_callback(void)" (??1find_all_callback@?1???$find_all@D@element@dom@htmlayout@@QBAXAAV?$vector@Velement@dom@htmlayout@@V?$allocator@Velement@dom@htmlayout@@@std@@@std@@PBDZZ@UAE@XZ) already defined in test.obj
main.obj : error LNK2005: "public: virtual bool __thiscall `public: void __cdecl htmlayout::dom::element::find_all<char>(class std::vector<class htmlayout::dom::element,class std::allocator<class htmlayout::dom::element> > &,char const *,...)const '::`2'::find_all_callback::on_element(void *)" (?on_element@find_all_callback@?1???$find_all@D@element@dom@htmlayout@@QBAXAAV?$vector@Velement@dom@htmlayout@@V?$allocator@Velement@dom@htmlayout@@@std@@@std@@PBDZZ@UAE_NPAX@Z) already defined in test.obj
test.exe : fatal error LNK1169: one or more multiply defined symbols found


Если вынести определение find_all_callback на уровень класса — всё ок.

Версия 3.3.1.8
 
Подождите ...
Wait...
Пока на собственное сообщение не было ответов, его можно удалить.