2017-11-01 6 views
2

FLTK을 시도하기 위해, 나는 다음과 같은 파일 구조 않은 : 나는 지금 실행링크 FLTK는

#include <FL/Fl.H> 
#include <FL/Fl_Box.H> 
#include <FL/Fl_Window.H> 

int main() 
{ 
    Fl_Window window(200, 200, "Window title"); 
    Fl_Box box(0,0,200,200,"Hello, World!"); 
    window.show(); 
    return Fl::run(); 
} 

때 :

project 
|--main.cc 
|--include 
| |--FL 
| | |--all FLTK header files 
|--lib 
| |--libfltk.a 
| |--other fltk libraries 

main.cc에서 다음과 같은 내용을

g++ -std=c++11 -c -o main.o main.cc -I include 
g++ -std=c++11 -o main.exe main.o -L lib -lfltk 

나는 두 번째 호출 후 오류의 모두를 얻을 g ++ :

lib/libfltk.a(Fl.o):Fl.cxx:(.text$_ZL13image_to_iconPK12Fl_RGB_Imagebii+0xf3): undefined reference to `[email protected]' 
lib/libfltk.a(Fl.o):Fl.cxx:(.text$_ZL13image_to_iconPK12Fl_RGB_Imagebii+0x1cf): undefined reference to `[email protected]' 
lib/libfltk.a(Fl.o):Fl.cxx:(.text$_ZL13image_to_iconPK12Fl_RGB_Imagebii+0x258): undefined reference to `[email protected]' 
lib/libfltk.a(Fl.o):Fl.cxx:(.text$_ZL13image_to_iconPK12Fl_RGB_Imagebii+0x2a6): undefined reference to `[email protected]' 
lib/libfltk.a(Fl.o):Fl.cxx:(.text$_ZL13image_to_iconPK12Fl_RGB_Imagebii+0x2b1): undefined reference to `[email protected]' 
lib/libfltk.a(Fl.o):Fl.cxx:(.text$__tcf_1+0x5b): undefined reference to `[email protected]' 
lib/libfltk.a(Fl.o):Fl.cxx:(.text$__tcf_1+0x83): undefined reference to `[email protected]' 
etc ... 

다른 FLTK 라이브러리를 연결하려고하면 결과가 동일합니다. 누구든지 저를 도울 수 있습니까?

Windows에서 gcc를 사용하며 MingW와 함께 사용합니다.

+1

FLTK 프로그램을 컴파일하기위한 라이브러리와 컴파일러 플래그를 파악할 수 있도록 모든 FLTK 릴리즈에 포함 된 'fltk-config'라는 편리한 도구가 있습니다. 그래서 터미널에서'fltk-config --libs'를 실행하십시오. 나는 당신이 "- lwindows"또는 이와 비슷한 것을 추가했다고 생각한다. (나는 창문이 없다.) – Andy

답변

1

fltk-config 스크립트의 도움을 받으려면 이러한 종류의 문제를 해결해야합니다. 따라서 컴파일러에 링커 오류가 발생하지 않도록 라인 fltk-config --ldflags을 추가하는 것으로 충분합니다. 이 명령은 스크립트이고 실행되어야하므로 ""기호를 사용해야합니다.