2012-11-16 2 views
3

여기에 있습니다. 필자는 Mac에서 LLVM을 성공적으로 컴파일했지만 Linux 서버에 가서 g ++을 사용하여 컴파일하려고 시도했을 때 링커 오류가 발생했습니다.컴파일 프로그램이 "정의되지 않은 참조"를 제공합니다

여기 발췌입니다 :

/tmp/ccGbgd6T.o: In function `Scene::setBackgroundImage(String)': 
Project.cpp:(.text+0x166): undefined reference to `Graph_lib::Image::Image(Point, String, Graph_lib::Suffix::Encoding)' 
/tmp/ccGbgd6T.o: In function `Graph_lib::Window::~Window()': 
Project.cpp:(.text._ZN9Graph_lib6WindowD2Ev[_ZN9Graph_lib6WindowD5Ev]+0xc): undefined reference to `vtable for Graph_lib::Window' 
/tmp/ccGbgd6T.o: In function `Graph_lib::Shape::~Shape()': 
Project.cpp:(.text._ZN9Graph_lib5ShapeD2Ev[_ZN9Graph_lib5ShapeD5Ev]+0xb): undefined reference to `vtable for Graph_lib::Shape' 
/tmp/ccGbgd6T.o: In function `Graph_lib::Text::Text(Point, String const&)': 
Project.cpp:(.text._ZN9Graph_lib4TextC2E5PointRK6String[_ZN9Graph_lib4TextC5E5PointRK6String]+0xe): undefined reference to `Graph_lib::Shape::Shape()' 
Project.cpp:(.text._ZN9Graph_lib4TextC2E5PointRK6String[_ZN9Graph_lib4TextC5E5PointRK6String]+0x17): undefined reference to `vtable for Graph_lib::Text' 
Project.cpp:(.text._ZN9Graph_lib4TextC2E5PointRK6String[_ZN9Graph_lib4TextC5E5PointRK6String]+0x67): undefined reference to `Graph_lib::Shape::add(Point)' 
/tmp/ccGbgd6T.o: In function `Graph_lib::Button::Button(Point, int, int, String const&, void (*)(void*, void*))': 
Project.cpp:(.text._ZN9Graph_lib6ButtonC2E5PointiiRK6StringPFvPvS5_E[_ZN9Graph_lib6ButtonC5E5PointiiRK6StringPFvPvS5_E]+0x40): undefined reference to `vtable for Graph_lib::Button' 

이 나를 깜짝 놀라게했다, 그러나 나는 모든 오류는 같은 클래스에서 오는 것으로 나타났습니다 : Graph_lib. (참고,이 내 수업 없음)

#ifndef GRAPH_GUARD 
#define GRAPH_GUARD 1 

#include <...system stuff...> 

namespace Graph_lib { 
// lots of other classes in here 
// this is just one 
    struct Image : Shape { 
     Image(Point xy, string file_name, Suffix::Encoding e = Suffix::none); 
    //rest of class 
    } 
} 

잘못 무슨 갈 수있다 : 여기 Graph.h 같은 모습의 매우 잘라 버전입니까?

편집 : 당신이 Graph.cpp와 프로젝트를 연결하는 잊어 버린 것처럼

g++-4.6 -std=c++0x *.cpp -lfltk -lfltk_images 

답변

2

그것은 나타나거나 어떤 파일 (들) Graph_lib의 구현을 개최 : 이것은 내가 컴파일 사용하고 명령입니다 클래스 메서드.

+0

을 사용하여 연결하는 경우 의미가 있습니다. 나는'include'라는 이름의 폴더에 Graph.cpp를 넣었고 다른 파일들은 하나의 디렉토리입니다. 이 파일을 어떻게 연결할 수 있습니까? 나는 현재 편집하고있는 방법을 보여주기 위해 원래 게시물을 편집했습니다. – Yep

+0

일반적으로,'include' 디렉토리는 단지'.h' 파일을 포함합니다. 그러나 어쨌든, 당신은 다음과 같은 것을 할 수 있습니다 :'g ++ - 4.6 -std = C++ 0x * .cpp include/Graph.cpp -lfltk -lfltk_images' –

+1

당신은 알고 있습니다, 나는 단지 include 디렉토리를 없애 버렸습니다. 일했다. 당신은 저에게 좋은 회색 머리카락을 거기에서 얻지 못하게했습니다. 포스가 함께하길. – Yep

1

그래프 라이브러리가 누락 된 것 같습니다.

g++, use -l <Graph lib>

관련 문제