=)C++에서 "undefined refence to"에 대해
C++에서 "정의되지 않은 참조"에 대한 질문이 있습니다.
다음은이 코드에서 나는 다음이 : 또 다른 C++ 파일에서
#include "HelloWorldAgent/helloworldagent.hh"
int main()
{
HelloWorldAgent agent;
agent.run();
}
다음 코드입니다 : 나는 g ++
함께 컴파일하려고
#ifndef _HELLOWORLDAGENT_HH_
#define _HELLOWORLDAGENT_HH_
#include "../../HumanoidAgent/humanoidagent.hh"
/**
* A friendly robot
*/
class HelloWorldAgent : public bats::HumanoidAgent
{
/**
* Initialize agent
*
* Called a single time when starting up the agent. Put all your initialization stuff
here.
*/
virtual void init();
/**
* Think cycle
*
* Called at each cycle after a message from the server is received and parsed.
Put all your thinking and acting stuff here.
*/
virtual void think();
public:
/**
* The Constructor
*
* Sets this agent's teamname to "Hello". Consider putting initialization stuff in
init() instead of here.
*/
HelloWorldAgent()
: HumanoidAgent(std::string("Hello"))
{
}
};
#endif
$ g ++ - I/usr/include/eigen -I /usr/include/sigc++-2.0 -I /usr/lib/sigc++-2.0/include helloworld.cc
그리고
파일에서 /usr/lib/gcc/i486-slackware-linux/4.5.2/../../../../include/c++/4.5.2에 포함되어 있습니다./ext/hash_map : 60 : 0, from HelloWorldAgent /../../ HumanoidAgent /../ WorldModel /../ Hashclasses/hashclasses.hh : 25, from HelloWorldAgent /../../ 휴머노이드 에이전트 /. ./WorldModel/worldmodel.hh:54, from HelloWorldAgent /../../ HumanoidAgent/humanoidagent.hh : 46, from HelloWorldAgent/helloworldagent.hh : 44, helloworld.cc에서 : 1 : /usr/lib/gcc/i486-slackware-linux/4.5.2 /../../../../ include/C++/4.5.2/backward/backward_warning.h : 28 : 2 : 경고 : #warning이 파일 futur에서 추후 통지없이 제거 될 수있는 적어도 하나의 비추천 또는 구식 헤더 포함 날짜. 동일한 기능을 가진 비 비추천 인터페이스를 대신 사용하십시오. 대체 헤더 및 인터페이스 목록은 backward_warning.h 파일을 참조하십시오. 이 경고를 사용하지 않으려면 -Wno-deprecated를 사용하십시오. /tmp/cc1cjIEs.o : 기능에서 main': helloworld.cc:(.text+0x29): undefined reference to
박쥐 :: HumanoidAgent :: 실행() ' /tmp/cc1cjIEs.o : HelloWorldAgent에 대한 기능 HelloWorldAgent::HelloWorldAgent()': helloworld.cc:(.text._ZN15HelloWorldAgentC2Ev[_ZN15HelloWorldAgentC5Ev]+0xfd): undefined reference to
의 vtable에서' /tmp/cc1cjIEs.o : HelloWorldAgent에 대한 기능 HelloWorldAgent::~HelloWorldAgent()': helloworld.cc:(.text._ZN15HelloWorldAgentD2Ev[_ZN15HelloWorldAgentD5Ev]+0xb): undefined reference to
의 vtable에서 ' collect2 : ld가 1 개의 종료 상태를 반환했습니다.
나는 무엇이 될 수 있는지 모르지만 어쩌면 내가 잘못하고 있습니다. 어떤 아이디어?
미리 감사드립니다. =)
PS : 아니, 당신은 HelloWorldAgent
에서 가상 기능 구현 (정의)를 포함하지 않은)
가능한 중복 [링크 오류 : 'vtable for XXX'에 대한 정의되지 않은 참조] (http://stackoverflow.com/questions/7720205/linking-error-undefined-reference-to-vtable-for-xxx) – bdonlan