error C1083: Cannot open include file: 'FL/Fl.h': No such file or directory
Asked Answered
A

4

7

First of all I'm still new here and therefore have no idea how to format the code so it looks neat in this question, I hope this is acceptable. I am following the programming principles and practice from Stroustrup. You might guess what the problem is...yes FLTK instalation. I have followed all the steps carefully to build the project in VS C++ 2013; pages 1204-1206. (I've done appendix C successfully, having to do with std_lib_facilities.h).

I was trying to build the following win32 project, as shown in the book:

#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();
}

After building solution, I receive an error which reads: Error 1 error C1083: Cannot open include file: 'FL/Fl.h': No such file or directory

I have also followed the steps to copy across some lib files from the FLTK lib directory into c:\users\pablo\desktop\c++ course files\visual c++\win32project1\source.cpp which is the file I created for Visual Studio Express 2013. Can somebody help me? Where do I find this missing file? Is the problem perhaps having to do with the fact that the FLTK version is a bit outdated to be used in VS 2013? (When I compiled the FLTK library, I got some errors having to do with backup file and some warnings.) I have researched this long an hard. I found some questions having to do with this in this forum but not exactly related to the above mentioned problem. Thanks very much in advance.

PS Well, there was one question having to do with the same error. I've followed some of the tricks mentioned as an answer to the same question but to no avail.

("A neat trick you can do for these types of errors is to place your cursor into the file name of the #include statement and press Ctrl+Shift+G. It will fail and display a message box showing what the include paths are. The solution is to simply add additional include paths to the SDK by right clicking your project and going to Properties>C/C++>General and setting "Additional Include Directories".")

The other suggestion shown didn't work either: ("Make sure the include directory is not the FL directory, but its parent. The reason for this is when you say #include "FL/Fl.h", you're asking the compiler to step into a folder called FL to find Fl.h, which will reside in FL's parent. If you specify FL as an include directory then you need only say #include "Fl.h"").

Alfaro answered 27/10, 2014 at 1:29 Comment(0)
C
3

The other answer isn't remotely true (I have literally just compiled an FLTK program with all headers in the form #include <FL/xxx.H>). When you download FLTK you get a directory (say fltk-1.3.2) which has this structure

/fltk-1.3.2/
    FL/
    GL/
    src/
    lib/
    examples/
    + other stuff

The sub directory FL contains all the header files. As such if wherever you've placed the fltk-1.3.2 directory is located at \foo\ then you need to add \foo\fltk-1.3.2\ to your additional include headers field. Do be careful, you might have accidentally chosen the wrong directory (it happens) or you might have extracted the contents of a zipped version of the file into a nested version of itself meaning you might have something like \foo\fltk-1.3.2\fltk-1.3.2\ So have a look.

If it can't find the headers you almost certainly have got the additional include directories field looking in the wrong place or in the wrong format. Click on the drop down button, click edit and manually click the new folder button and navigate to it.

What you will find next is that you have to point the linker in the right direction. In the above the default place to install the library files (.lib static should be default for FLTK) so you need to add \foo\fltk-1.3.2\lib\ to configuration properties -> Linker -> General -> Additional library directories

THEN you need to link to the specific libraries. Since the linker now knows where to look you down need to specify the path, but just name them. To do so go to configuration properties -> Linker -> Input -> Additional dependencies, click the drop down option, click edit and add on separate lines (and without these commas) fltkd.lib, fltkformsd.lib, fltkzlib.lib,wsock32.lib

Chickweed answered 27/10, 2014 at 16:56 Comment(3)
Ok guys thanks for those answers. I think there's something fundamentally wrong in what I'm doing since FLTK just doesn't want to play ball in spite of trying to implement all your suggestions. I might have to delete the FLTK files and reinstall them. I think it might have to do with the fact that I installed version 1.1.10, as it shows a .zip file. I'll install 1.3.2 .gz and unzip it with 7-zip.Alfaro
Try following some online instructions like: c-jump.com/bcc/common/Talk2/Cxx/FltkInstallVC/… You can either do explicitly what it says and copy the FL and GL directories to the VS include folder and the .lib files to the lib folder which means you only have to add the libs in the 'input' field Or you can do what I said, not copy them and tell the compiler where to look for them. BE CAREFUL: when you compile/install FLTK, if in debug mode it makes fltkd.lib files, if in release it makes fltk.lib files. Check which you have done and link appropriately.Chickweed
To build FLTK under windows, go to the IDE directory, use the vc.net solution. It may need converting to VS2013. Do not use the vc6 solution.Boredom
S
1

This is because there is no header file named #include <FL/Fl.h> what they mean by this is to include either #include <FL> or #include <FL.h> depending on what program your making, but the former is most likely what you want to do since it's the standard version. #include <FL.h> is an old library, and is not even included in the standard. It is also not even included in every platform. You should not use the .h version in this example.

The same can be said for the other two header files as well.

Spermicide answered 27/10, 2014 at 1:32 Comment(3)
hmmm. Still struggling; it doesn't make any difference. Perhaps it has to do with the environmental varieables and path, since sometime ago I installed Netbeans and was using MingW compiler to work with the IDE. I'm not sure if I should mess with the path though. Very frustrating indeed. Getting the same error.Alfaro
This answer is NOT true. It FL/Fl.h is written because it expects you to maintain this structure in your include directory. You should keep GL directory with it too as some headers in the FL directory look for other includes in the GL directory which it expects to be there.Chickweed
The key here is to add the parent directory of the FL directory to the include header path, whatever it's called in MS Visual Studio (maybe "additional include header path", I'm not sure).Provocative
P
0

The original question was about Windows, and the direct answer to the question is to add the directory above the FL directory (note: uppercase) to the include paths of the Visual Studio settings.

Since this is about windows, spelling of the header files may not matter, but such programs as shown by the OP are not portable because other systems use case sensitive file systems. For portability almost all FLTK header files must be written with uppercase ".H" to be found on case sensitive file systems (there are some exceptions). The correct example program - tested on case sensitive Linux with current development version FLTK 1.4.0 - would be:

#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();
}

Note that this still needs the correct include path to compile and build.

Provocative answered 6/2, 2023 at 16:53 Comment(0)
X
-1

this works !!! On your own Linux/Mac: Download the source for fltk 1.1.10 and unpack it in a directory of your choice. You should be able to execute "configure", "make", and "sudo make install" to install fltk in /usr/local/lib and /usr/local/include.

Xavier answered 5/2, 2023 at 20:21 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.