0

how to install FLTK for VS CODE I have configured vs code for c++ and I want to use vs code for FLTK also, there is no good guideline for the process and I did not manage to install it according to FLTK help documents, I do ./configure make, and after make install but I cannot run the code. I will list down what I did here:

  1. download and unzip file on c:/dev/flsk/

  2. I had mysys2 but when I tried to run the command like ./configure to configure FLTK it gave me some errors, so i downloaded MingGW with dev toolkit and after run MinGW shell.

  3. run commands: ./configure, make, make install that was all, now I want to compile my c++ code but it cannot access FLSK Libraries what can I doo? I want to run the code from the book of Bjarne Stroustrup name Programming - Principles and Practice Using C++ chapter 12 thank you;

     #include "Simple_window.h" 
     #include "Graph.h"
    
     int main()
     {
         using namespace Graph_lib; 
         Point tl {100,100}; 
         Simple_window win {tl,600,400,"Canvas"};
         Polygon poly; 
         poly.add(Point{300,200});
         poly.add(Point{350,100});
         poly.add(Point{400,200});
         poly.set_color(Color::red);
         win.attach (poly);
     }
    
  • Can you link to "flsk library"? Google doesn't give me anything. Also link where you downloaded mingw from. – HolyBlackCat Jan 29 '23 at 16:45
  • SoRry I modified it is FLTK typing mistake – Beka Tchigladze Jan 29 '23 at 16:47
  • Ok. What error exactly did you get? – HolyBlackCat Jan 29 '23 at 16:50
  • It would be easier to install it from MSYS2 ([guide](https://stackoverflow.com/q/30069830/2752075)) instead of building it yourself, but since you're already done with that part, it shouldn't really matter. – HolyBlackCat Jan 29 '23 at 16:51
  • I downlaoded Mingw from this link and check necessary installers '"C++ Compiler", "MSYS Basic System" "MinGW Developer Toolkit" ' Link: `https://sourceforge.net/projects/mingw/files/Installer/` – Beka Tchigladze Jan 29 '23 at 16:52
  • error is that I cannot ectually compile the file or run demo projects which included in fltk source – Beka Tchigladze Jan 29 '23 at 16:53
  • Please add the exact error message you got when trying to compile. – HolyBlackCat Jan 29 '23 at 16:54
  • C:\MinGW\bin\g++.exe -fdiagnostics-color=always -g C:\dev\fltk-1.3.8\test\adjuster.cxx -o C:\dev\fltk-1.3.8\test\adjuster.exe C:\dev\fltk-1.3.8\test\adjuster.cxx:20:19: fatal error: FL/Fl.H: No such file or directory #include ^ compilation terminated. Build finished with error(s). – Beka Tchigladze Jan 29 '23 at 17:04
  • 1
    My advice is to do what VSCode tells you with the official instructions and install msys2 and use that to install MinGW and fltk. The official instructions are here: [https://code.visualstudio.com/docs/cpp/config-mingw](https://code.visualstudio.com/docs/cpp/config-mingw) – drescherjm Jan 29 '23 at 17:33
  • 1
    To install 64 bit fltk with msys the instructions are [here](https://packages.msys2.org/package/mingw-w64-x86_64-fltk?repo=mingw64) and are `pacman -S mingw-w64-x86_64-fltk` in the mingw64 terminal. – drescherjm Jan 29 '23 at 17:36
  • 1
    I concur, you should be using MSYS2. For manual solution, add `-Ipath` to compiler flags, where `path` is a path to the directory containing the `FL` directory, which in turn should contain `Fl.H`. This should fix this error. After that, you should get `undefined reference` errors: `-Lpath` for the directory where `libfltk.a` is, and `-lfltk` to use that file. – HolyBlackCat Jan 29 '23 at 17:36
  • it gives me this error for every header file VS code doesn't do any read underline any more under the library but this is error when try to compile C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/Users/ASUS/Desktop/C++/Classes/Test_output.cpp:10: undefined reference to Fl_Window::~Fl_Window() – Beka Tchigladze Jan 30 '23 at 05:38
  • 1
    Didn't I explain how to fix those in my previous comment? – HolyBlackCat Jan 30 '23 at 09:49
  • Hello, @HolyBlackCat I did not understand your answer properly (my bad) I think but, this was my steps, installed msys2 from scratch, with the toolchain, after reinstall `fltk` with the command provided above `pacman -S mingw-w64-x86_64-fltk` , and add the c:/msys64/mingw/bin path as system environment variable, everything worked perfect apart from `FLTK` later I added `-lfltk` in the tasks before `-o` and it compiles properly now ,do I have to consider anything else? – Beka Tchigladze Jan 30 '23 at 19:55
  • 1
    Nice to hear that. "do I have to consider anything else?" No, I think not. – HolyBlackCat Jan 31 '23 at 03:34
  • 1
    When building manually, in addition to `-lfltk` you would add `-Lpath` to specify the directory where you installed `libfltk.a`. In this case it was unnecessary, because it was installed in some directory searched by default. – HolyBlackCat Jan 31 '23 at 03:50

0 Answers0