I am currently using Visual C++ 10.0(2010) on a win7 32bit OS.
When I tried to build the basic examples of libigl github tutorials:
libigl tutorials
The following installation code works fine:
#include <igl/cotmatrix.h>
#include <Eigen/Dense>
#include <Eigen/Sparse>
#include <iostream>
int main()
{
Eigen::MatrixXd V(4,2);
V<<0,0,
1,0,
1,1,
0,1;
Eigen::MatrixXi F(2,3);
F<<0,1,2,
0,2,3;
Eigen::SparseMatrix<double> L;
igl::cotmatrix(V,F,L);
std::cout<<"Hello, mesh: "<<std::endl<<L*V<<std::endl;
return 0;
}
which indicates there is basically no problem per the tutorials.
However, I cannot get the tutorial 102 through:
#include <igl/readOFF.h>
#include <igl/viewer/Viewer.h>
Eigen::MatrixXd V;
Eigen::MatrixXi F;
int main(int argc, char *argv[])
{
// Load a mesh in OFF format
igl::readOFF("../shared/bunny.off", V, F);
// Plot the mesh
igl::viewer::Viewer viewer;
viewer.data.set_mesh(V, F);
viewer.launch();
}
After getting a series of building error message of missing some special headers, and then adding the corresponding directory containing the header into the including directory of VS, there is still some header missing which cannot be found in my computer.
Except for the include directory which is required per the tutorial:
x:\Program\libigl-master\include; $(IncludePath);
I already added others as follows:
x:\Program\libigl-master\external\glfw\include;
x:\Program\libigl-master\external\AntTweakBar\src;
x:\Program\libigl-master\external\AntTweakBar\include;
x:\Program\libigl-master\external\glew\include;
Error message is still there:
x:\Program\libigl-master\external\glfw\include\glfw\glfw3.h(163): fatal error C1083: Cannot open include file: 'GL/glcorearb.h': No such file or directory
1>
So I added:
x:\Program\libigl-master\external\glfw\include\GLFW
D:\Program\libigl-master\external\glfw\include\
and got:
x:\program\libigl-master\external\glfw\include\glfw\glfw3.h(163): fatal error C1083: Cannot open include file: 'GL/glcorearb.h': No such file or directo
which does not exist in my computer.
What should I do?
I had the exact same issue, and the thing is that simply adding their include paths won't make it work - as they said it would. That is because LIBIGL itself is just an auxiliary library to help manipulate 3D shapes, but their examples use much more than that (their matrix system comes from Eigen, their graphical system uses GLFW+GLEW, among many others).
But you can get most of the examples working on MSVS setting up the essential libraries. Download the following:
Eigen: This is for the basic matrix/vector arithmetics etc.
GLFW: This is used to create and handle windows for OpenGL.
GLEW: This library has the actual OpenGL function bindings to use OpenGL functions.
Note that these libraries are essential to compile the examples jut because when the examples were made, the creators had the enviroment set up with them (otherwise they would have to code by hand those OpenGL and Windows/Linux windows handling etc. In case you're interested, this is what "pure OpenGL" code looks like). So what you have to do is: set the enviroment for these libraries. This is how to do it:
After creating an empty project in MSVS, go to Solution explorer > right click the project > Properties. You've opened the Property Pages, where all the project configurations are done. We need to specify 3 things: where the compiler can find the headers, the libraries we're using and where it can find these libraries.
First we set up the headers: on the left menu expand C/C++ > General, and on the right, select Aditional Include Directories, click on the down arrow and click edit. A window will open with blank fields, click them twice to add items. Add the eigen header path, the libigl folder path, the glew folder path and the glfw folder path in each line (this is a very confusing interface).
Ok, now we need to specify which libraries we're going to use. Again, in the left menu, go to Linker > Input > Aditional Dependencies (almost the same kind of interface). Add glew32s.lib, glfw3.lib and opengl32.lib (one for each line). Finally, specify where those libraries are. Go to Linker > General > Aditional Library Directories, and specify the path where the downloaded glew32s.lib and glfw3.lib are. (something like "C:\Users...\glfw-3.2.1.bin.WIN32\lib-vc2010") - make sure you're specifying the path to the right compiler - for instance, if you're using MSVS 32 bits 2010 you should select vc2010 and not mingw-64.
If you create a source file in the project using the tutorial 2012 source code it should compile, but you might have to specify the paths to the dll's such as OpenGL32.dll if it's not already in your system path.
Finally, one last thing that might go wrong has to do with something called Runtime Library - it's in C/C++ > Code Generation > Runtime Library. Basically it describes a method to compile code, and each library we're using was compiled using a different one, so we might get errors... Honestly I don't know a lot about that, I just know that mine wasn't working with the default one, so I changed to /MD and it worked. Go figure.
PS: You might as well need to update your graphics card for OpenGL to work.
The only thing that worked for me was creating a visual studio project with cmake-gui. Here is what I did:
Download and install cmake https://cmake.org/download/.
Open cmake-gui.
In 'where is the source code', put the path to the tutorials: .../libigl/tutorial.
In 'where to build the binaries', put whatever your like (I used .../libigl/tutorial/build).
You will also see a bunch of options in red. Select/deselect as desired. I had to deselect Matlab as it couldn't find it for some reason.
Configure and generate (when asked, choose whichever version of Visual Studio you are using).
You should now have a Visual Studio solution in the build folder. Open and build.
I had the same problem in Visual Studio 2013. And the head file I was trying to use was igl/sort.h which cannot be opened.
In the tutorial , they said
Simply add libigl/include to your include path and include relevant headers.
And the include path they were referring here is actually the include directories which can be found under project>properties>Configuration Properties>VC++ Directories, not the Additional Include Directories.
Related
I am a C# developer, and spoiled rotten when it comes to references and dependencies. I am working on a small project now in Visual C++ (Visuial Studio 2017), where I want to use the libtomcrypt and libtommath libraries. I've created a small project and added the 2 projects to my solution:
I have also added my includes:
And I added the dependencies:
However, I still can't build:
Error C1083 Cannot open include file: 'tomcrypt.h': No such file or directory
I am not sure what else I need to do to get the references working and the code to compile. Any pointers is appreciated!
The error message indicates that the compiler can't find the file tomcrypt.h while compiling one of your source files. From the message I would guess that you have a line like the following in your source file:
#include <tomcrypt.h>
(...or perhaps with quotes instead of brackets.) From your screenshot I can see that you've added "...\repos\libtomcrypt-develop\src\headers" to your include path. Is the file tomcrypt.h found directly in that folder, or is it perhaps in a subfolder instead?
Your #include directive will basically append whatever path you give it to each entry in your include path when looking for the file, so if there are subfolders in between, you'll have to expand your #include directive to include those folders.
If this doesn't solve your problem, perhaps try posting the actual full path of where this header file exists on your filesystem, as well as your complete include path value! (The full compiler command from the build log would be useful, as well as the complete error message(s) related to this source file.)
Edit:
The original poster posted a separate answer indicating that the actual problem was that the Visual Studio Project Properties were set correctly, but that he was accidentally trying to build a different Configuration. :(
I was building the project under x86. Once I changed it to x64, it built just fine.
OS : Ubuntu 14.04
SDK : Qt 5.5
library : "ion.h" [ I have built ion-dtn 3rd party library from source and it has ion.h file which I am using in my 2 projects ]
I am using ion.h in my 2 projects in same development system. Both projects are based on Qt. On including ion.h One project runs without any compilation error , other complains about MAXPATHLEN.
/usr/local/include/ion.h:60: error: 'MAXPATHLEN' was not declared in this scope
char pathName[MAXPATHLEN + 1];.
On project where it's running fine , I can click on ion.h and found MAXPATHLEN is highlighted with blue, obviously means qt can find it and on clicking "follow under symbol" I found its declared in param.h under sys directory.
I cant do the same in my other project. On clicking ion.h MAXPATHLEN is in black colour and couldnt able to find param.h when I click follow under symbol.
I have compared and my .pro files are same in both projects. Can soemone please guide me what I am doing wrong.
Thanks
MAXPATHLEN is declared in <sys/param.h>. One project must include it (or another header file including it...like <QDir> for instance, it's hard to tell) while the other does not.
Simply include <sys/param.h> before you include ion.h yourself to solve the problem.
If you really want to figure out who's including this file and then identify why MAXPATHLEN is defined in one project, there are compiler options for that (like /showIncludes for g++).
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"").
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
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.
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.
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.
I want to include a header file. I am working in a C++ environment, (C++11, Windows OS, Netbeans 7.3.1 IDE, Cygwin_4.x tool collection). I do not know how I setup the environment/IDE (I did it 6 months ago). I do not understand the fundamentals of the C++ build process or Cygwin related issues either, so I might have to fill in the gaps with some other references/documentation (on what specifically, I'm not sure).
My ultimate objective is to be able to include header files using a syntax that does not require the full file path. I want to write something terse, like:
#include "src\stuff\blah.h" //or even better: #include "blah.h"
The only way I can get my program to compile at all is by using the full file path, like this:
#include "C:\NetBeansProjects\Project1\src\stuff\blah.h"
And, I can only compile once using the full path. If I try to rebuild, it will bomb with the *** multiple target patterns. Stop. error. There are workarounds for this error; those being either 1) deleting the build and dist folders between each rebuild (yikes?), or 2) following this 16 step setup process.
I do not want to follow either of those workarounds because they do not appear to deliver what I want. How can I setup my environment to achieve what I want...of being able to include header files without using full paths?
Thanks to DanielKO for this answer.
In my case, I was able to include with the syntax:
#include "../stuff/blah.h"
I did not have to configure anything under the "Code Assistance" section for the C++ compiler.
All of my code is under "src" as the parent directory in my NetBeans project. It seems that the full path of the file is not required, and the only directory that must be referenced is the lowest level subdirectory (in my case, "stuff").
In NetBeans I've added the path to the list of libraries:
Go to Properties->Select C++->Select 'include libraries'->'Add'
Now: Add the path of the project folder with option "absolute"
Go to Properties->Select C++->Select 'Additional library directories'->'Add'
Now: Add the path of the project folder with option "absolute"
It's very obscure to me why the project doesn't recognize "own" header files.
I am trying to link FMOD to my project, which I did very easily in the past in Visual Studio 2008.... So I have placed the fmodex_vc.lib and the fmodex.dll file in my project directory, added them to my project's solution explorer, then created a SoundMgr.h file which includes the fmod.h file
#include "include\fmod\fmod.h"
Where fmod has been placed in the include\fmod folder and opens ok if i right click on the above code and click "Open Document"...
But if I try to write any code at all, including a simple "using namespace FMOD" it tells me that it FMOD is undeclared or unidentified.... am I missing any step?
EDIT:
What the class looks like so far is:
#pragma once
#include "main.h"
#include "include\fmod\fmod.hpp"
#include "include\fmod\fmod_errors.h"
#include "include\fmod\fmod.h"
class SoundMgr{
void init();
};
void SoundMgr::init(){
FSOUND_Init (44100, 32, 0);
}
And the error is:
Error 1 error C3861: 'FSOUND_Init': identifier not found
And that's for any line of the sample code that I try import from this quick guide:
GameDev FMOD quick guide
I tried adding the library as an additional dependency in the Input section of the Properties/Linker and I get
1. fatal error LNK1181: cannot open input file 'fmodex_vc.lib'
Any of these errors ring a bell?
Don't you want fmod.hpp to get the c++ features?
you can include the headers path in C/C++ > General and library path to Linker properties and include the dll's in you project. In this case you have the files in you release/debug dir
Right so I eventually fixed it by removing the Additional Dependency in the Input section of the Linker and instead adding Include and Library directories in in Configuration Properties\VC++ directories.... Most articles I found advise to use the actual full path to the FMOD installation folder, but since I want this project to be portable and self contained, i created a "lib" and "include" folder in my project and put those files in them... (used the directories "\lib" and "\include" in the project properties which I am assuming links to the project folder, have never done this before but am hoping it won't cause dependency issues if I compile this on a different machine)...