So far I have downloaded the boost libraries using brew and found their location and copied them to my home folder.
I've tried to follow closely how to add these libraries from windows tutorials, but I seem to be missing something. Upon compiling this...
#include <iostream>
#include <string>
#include <boost/regex.hpp>
using namespace std;
using namespace boost;
int main() {
string s = "This is my simple sample text, really.";
regex re(",|:|-|\s+");
sregex_token_iterator my_iter(s.begin( ), s.end( ), re, -1);
sregex_token_iterator my_end;
while (my_iter != my_end)
cout << *my_iter++ << 'n';
return (EXIT_SUCCESS);
}
I simply get an error stating that #include <boost/regex.hpp> file not found
Using
Netbeans 8.0.1
Mac OS 10.9.5
Most tutorials show how to set up using cygwin, which doesn't apply to me since I'm on windows and there are no helpful or easy to follow tutorials for Mac OS.
Please and Thank you for any help on this matter.
After trial and error i have figured it out!
So in Netbeans 8.0.1 what you want to do to set up for regex is:
Under Netbeans>Preferences select the C/C++ tab, then in this window tap on "Code Assistance" then "C++ Compiler"
In the "Include Directories" you are going to add the location where you saved your boost libraries and header files, on my machine it install to
/usr/local/Cellar/boost/1.56.0
yours may be different.
Once you've done that, hit "Apply" and you can close this window.
I then used the code from my original post to create a new c++ project.
Once you can compile a "Hello World" go ahead and replace your code with the once from my original post.
On the left hand side (default) where your project folder is, right-click the folder and select "Properties". You should then get this window. Navigate to "C++ Compiler" under the "Build" option.
Remember how we located the folder where both the include files and library files? Do the same in the "Include Directories" section, except this time you will select the folder which contains the .hpp files. In my case it was "/usr/local/Cellar/boost/1.56.0/include"
Hit "Apply".
So that takes care of out header files. Now lets do the library files!
Once that is done, navigate to the "Linker" option within the same option window. We are/were in.
Under the "Addition Library Directories" Locate the folder that contains your dynamic and static libraries. These filetypes should end in .a or .dylib.
Mine were located in "/usr/local/Cellar/boost/1.56.0/lib"
Now all you have to do is select the "Libraries" and the "..." on the right which will give you a new window.
Here you will select "Add Library File" and add the following...
they should be labelled:
"libboost_program_options-mt.dylib"
"libboost_regex-mt.dylib"
Once this is done, build and run and your result when using the code above should be:
"Thin in my nimple nample textn really.n"
Hope this help anyone else!
Related
Windows 10
Eclipse IDE for C/C++ Developers
Version: Kepler Service Release 2
Build id: 20140224-0627
I'm trying to use imgui. Unfortunately, documentation is pretty shady about how to get it working.
So, in order to get it working, I think I need something called "glad". Whatever it is, the only source of it seems to be some shady-looking one-pager that generates the files for you (found a link to it here).
Anyway, I checked all the boxes I needed (copied from the screenshot from the provided link). I don't understand much about what it is (very roughly), I simply want to get imgui running (ha-ha on me, imgui also needs some other stuff scattered around internet, but it's my next problem, not current).
Anyway, in my new C++ project in eclipse I created a folder "include" and added its path into "C/C++ General -> Paths and Symbols". So when I write "#include "glad/glad.h" in my "test3.cpp" (file with main function, project called test3), I'm ok. But I can't build it because glad.c, which is located in the SAME folder as test3.cpp, has the identical include line, but it gives an error that it can't find it. Sounds like some nonsense to me.
#include "glad/glad.h"
#include <iostream>
using namespace std;
//for those who wanted to copy default hello world program
int main() {
cout << "!!!Hello World!!!" << endl; // prints !!!Hello World!!!
return 0;
}
How is this even possible? Looks like a total nonsense to me. They're in the same folder. Test3 sees the file, glad.c doesn't. I tried replacing "<>" in include in glad.c with quotes like in test3.c, same thing. One file works, another doesn't.
What can I do about it?
Eclipse separates the include paths for C and C++ files. If you have a program combining both C and C++ files, the correct include paths need to be set for both languages.
Navigate to the C/C++ General -> Paths and Symbols -> Includes tab. You will see both languages (and probably Assembly) listed under Languages. Pick the correct language or when adding the path, check the Add to all languages box.
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.
i'm trying to get GMP working with Xcode. So far I have untared the file in the home directory, ran all the necessary commands to have it configure, make, and install
./configure --prefix=/usr/local --enable-cxx
make
make check
sudo make install
Both the gmp.h and gmpxx.h are in the usr/local/include, however I still am getting an error when trying to include the files. I believe I need to add a complier flag but for this version of Xcode I do not know how to do that. If that is not the case and I need to do something else please advise and I would very much appreciate it.
My code looks like the following:
#include <iostream>
#include <gmp.h>
int main(int argc, const char * argv[]) {
// insert code here...
std::cout << "Hello, World!\n";
return 0;
}
Can I code with GMP in c++ ? Or do I need code in c? Any help getting this to work would be very much appreciated, thanks a ton in advance!
Sorry if this seems like a DUPLICATE question, i did look at the other questions and I was not able to get it to work following answers from previous questions.
UPDATE
Added the libgmp.la and libgmpxx.la to Xcode, also added /usr/local/include to header file search and it is still not working! I see the library files in my project and if I put "gmp.h" instead of it works but when I go to use GMP it fails telling me to chnange the in other GMP files to "gmp.h" which doesn't seem right.
ANY IDEAS?
this is the fix according to another SO question:
1) Open the left panel,
goto "ProjectName", Targets, Build phases, Link binary with libraries
and select your library.
2) Open the left panel,
goto "ProjectName", Project, Header Search Paths,
write the path where the headers of your library are
(the .h files, usually in /usr/local/include).
3) Open the left panel,
goto "ProjectName", Project, Library Search Paths,
write the path where your libraries are
(the .a or .dylib files, usually in /usr/local/lib)
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'm relatively new to programming in C++ and while I have some experience in general coding practices, conventions etc... Recently I have come to precipice of my (limited) knowledge.
Basically I wish to write a program that will allow me to extract the annotations from a PDF file. With some research I discovered that the Poppler library would allow me to do this. So I downloaded it and began the arduous process of building it for CodeBlocks (MinGW) on Windows Vista.
For those interested, the following site provided invaluable information with regards to the building of Poppler with Cmake:
http://www.seppemagiels.com/blog/building-poppler-windows-using-mingw>
Anyway, onto my current dilemma. Having followed the out of source conventions of Cmake I have a file structure like so:
...\Work\
..............poppler-0.22.2
..............poppler-0.22.2_Build
In the "poppler-0.22.2_Build" folder there is a " libpoppler.dll.a " file which i have been led to believe is a Library folder. I have then followed the instructions as described here:
http://www.learncpp.com/cpp-tutorial/a3-using-libraries-with-codeblocks/
I then linked to the libpoppler.dll.a file in the "poppler-0.22.2_Build" directory and the .h files which were in the original source directory (i.e. poppler-0.22.2).
Now my question is what do i need to write in my main.cpp such that i can use the Poppler functionality. At first i just wrote:
#include "poppler.h"
However, this returned with a "No such file or directory" error.
Then i tried:
#include "poppler-qt4.h"
This then executed however I was informed later in my code that "poppler" has not been declared.
Then I tried:
#include "poppler-qt4.h"
#include "C:\Users\...\poppler-0.22.2\cpp\poppler-document.h"
Which then returned a "undefined reference to 'imp_ZN7poppler8document14load_from_fileERKsS2_S2_'" error...
So that's where I am right now, I have absolutely no idea how I should continue and I was hoping someone could walk me through the steps I need to take to get Poppler to work i.e. as in how do I get the library to link, if that is indeed the problem, or how do I overcome the "imp_" error. I really am at my wits end with this problem...
Thanks in advance for any help you can supply.
P.S. My main.cpp so far:
#include <iostream>
//#include "poppler.h"
#include "poppler-qt4.h"
#include "C:\Users\...\poppler-0.22.2\cpp\poppler-document.h"
using namespace std;
int main()
{
const string dir = "C:\\Users\\...\\TestPDF.pdf";
poppler::document *doc = poppler::document::load_from_file(dir)
return 0;
}
In Code::Blocks, right-click the name of your project and select "Build Options...". Select the option in the left-most menu that says the name of your project (should be the first option) and click "Linker Settings". Now press the "Add" button and browse to your DLL file, then press "Ok".
To allow including the header files of your library (without writing down the full path in your source code), you should tell add their location to the compiler's include path. You can do this on the "Search Directories" tab in the same window. Make sure the "Compiler" sub-tab is selected and press "Add". Browse to the the directory containing the header files and press "Ok".
Hope this helps.