0

I have installed fltk library on MSYS2 using the pacman. However, I am currently facing problem in compiling simple example code in C++ which is given below along with the error message.

  C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/9.2.0/../../../../x86_64-w64- 
  mingw32/bin/ld.exe: 
  C:\msys64\tmp\ccKVc9rm.o:hello_windows.cpp:(.text+0x30): undefined reference to 
 `Fl_Window::Fl_Window(int, int, char const*)

I feel that this error is because g++ is unable to find the fltk library The above mentioned c++ source code(taken from Programming and Principle):

        #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, "Hey, I mean, Hello, World!");     
         window.show();           
         return Fl::run(); 
         }  

Please help me in compiling this program.

denisssj
  • 79
  • 5
  • How exactly are you building? Can you show make file or the IDE configuration? – Yunnosch Mar 26 '20 at 06:42
  • @Yunnosch Nothing,I was just trying to check if the fltk libraries are correctly build by the example code given above.I was using command g++ filename.c to compile the code and got the error.I am using Msys2 64bit . – denisssj Mar 26 '20 at 09:37
  • I see. That is the problem. You need to tell compiler+linker that you want to use the lib, but you only told them to include the header. – Yunnosch Mar 26 '20 at 09:38
  • The link in the close notification should help you. – Yunnosch Mar 26 '20 at 09:39
  • @Yunnosch how do I specify that for my installed library?. I have installed the library using pacman.So ,should I specify the installation path? – denisssj Mar 26 '20 at 09:40
  • @Yunnosch Can you help me achieve the functionality of |g++ Hello_win.cpp -l fltk" on cmake?I used this to compile an ftk project . – denisssj Mar 27 '20 at 07:43
  • Please read the provided information link. If something is unclear there ask specifically. – Yunnosch Mar 27 '20 at 07:45
  • @Yunnosch which information. – denisssj Mar 27 '20 at 07:47
  • Do you see the link in the close notification? – Yunnosch Mar 27 '20 at 07:48
  • Yes,the above issued command is taken from one of post mentioned.Can you tell me to acheive the above command functionality in cmake? – denisssj Mar 27 '20 at 07:49
  • With cmake you are introducing a completely new topic to the question. You should ask a separate new one. – Yunnosch Mar 27 '20 at 07:51
  • @Yunnosch Sorry.Let me put it up in new question. – denisssj Mar 27 '20 at 07:52

0 Answers0