Using MTL/Boost Library Mac Terminal C++ - c++

To be precise, I'm attempting to run this excellent project: https://github.com/ppwwyyxx/panorama
I'm using a modern mac.
The issue is that I can't seem to get my computer to properly include the MTL library. I'm stuck with the endless error of:
$ make
[cc] matrix.cc ...
matrix.cc:5:10: fatal error: 'boost/numeric/mtl/mtl.hpp' file not found
#include <boost/numeric/mtl/mtl.hpp>
^
1 error generated.
make: *** [obj/matrix.o] Error 1
I've tried cmake. I've downloaded both the boost and mtl4 libraries. I've put them in my /usr/local/include directory. Nothing seems to be working.
Any advice would be excellent, thank you!

Try to modify the Makefile in src and add this on the line 7 of the Makefile:
-I/usr/local/include

Related

Can't build SSDL from the source code of the book C++ for the Lazy Programmers

I can't compile the SSDL source code from the book C++ for the Lazy Programmers (2019) by Will Briggs on my ubuntu 20x so could you please tell me what goes wrong? I installed SDL2 and it's working but most of the cases I get the following error when I compile an SSDL code;
cpp-for-lazy-programmers/ch1/hello$ make -f Makefile.unix
g++ -c -g sdl2-config --cflags -I…/…/external/SSDL/include main.cpp -o main.o
In file included from …/…/external/SSDL/include/SSDL.h:27,
from main.cpp:7:
…/…/external/SSDL/include/SSDL_display.h:28:10: fatal error: SDL_ttf.h: No such file or directory
28 | #include <SDL_ttf.h>
| ^~~~~~~~~~~
compilation terminated.
make: *** [Makefile.unix:60: main.o] Error 1
I just can't understand why SDL_ttf is a big issue as I see many posts regards to SDL_ttf?
Just because they both have "SDL" in the name does not mean they are part of the same library.
If you search for SDL_ttf.h on packages.ubuntu.com ("contents of packages"), it will tell you that you want the libsdl2-ttf-dev package
This is also mentioned in the accompanying documentation.

"fatal error: boost/regex.hpp: No such file or directory" when trying to compile C++ program using a makefile

I am trying to compile a piece of open source software called "SPECIES
Identification of Taxonomic Mentions in Text". I am on MacOS.
I downloaded the source code (which can be found here), moved into the directory and used the command make to compile. This is the error returned:
g++ -fpic -pthread -Wall -O3 -o organisms organisms.cxx -lm -lboost_regex
In file included from batch_tagger.h:5:0,
from organisms.cxx:3:
tagger.h:7:27: fatal error: boost/regex.hpp: No such file or directory
compilation terminated.
make: *** [organisms] Error 1
I installed the C++ boost library using brew install boostand tried the above steps again (it did not work).
I tried dropping the boost directory into the directory containing the source code (it did not work).
Any suggestions/help?
You need to tell the compiler where to find boost headers.
You need to use the include path option to specify where the boost headers can be find, use -I/path/to/boost/include.
Then include the file using #include <boost/regex.hpp> from your code.

g++ #include file not found compiler error

I'm currently trying to simply link a file called main.cpp with boost in order to do asio(asynchronous input and output). I'm using a makefile in order to compile the C++ code into executable form. However, despite using the -I modifier on my terminal command in Mac OS X, it still cannot find the appropriate directory to search in. Here is my code in Main
#include <asio.hpp>
int main(){
return 1;
}
and here is the makefile command that I am using
all:
g++ -Iboost_1_60_0/boost/ -o main main.cpp
In my file structure, boost_1_60_0, main.cpp, and makefile are all on the top level, where asio is in the folder boost which is in the folder boost_1_60_0. I'm very confused about this and any help would be appreciated! Thanks!
EDIT: Full error is
1 error generated.
make: *** [all] Error 1
iMats-2:SerialC++ wfehrnstrom$ make
g++ -Iboost_1_60_0 -o main main.cpp
main.cpp:2:10: fatal error: 'asio.hpp' file not found
You should use -Iboost_1_60_0 (or, better still, install Boost properly so that it's found automatically under /usr/include/), and write #include <boost/asio.hpp>.
The include directives inside Boost itself will assume this form, so…
BTW, this has nothing to do with exceptions. Presumably it's a compiler error you've seen.

RccpGSL, installing/using GSL from R on windows 7

I'm used to R but I'm a complete beginner in C++. I'm having a hard time installing GSL to use it with RcppGSL in R in order to refine a package comprising C++ code. I downloaded the latest GSL version, unpacked it to C:/GSL, set the environmental variable LIB_GSL to C:/GSL and the PATHtoC:/GSL/bin.
Like I said, I want to refine an existing package. I've forked and pulled the latest version of the package in question from github. My primary goal is simply to be able to use and refine the package. However, when I'm trying to make a source package out of the source files I get the following Error:
Installing to library 'C:/Users/Simon/Documents/R/win-library/3.1'
* installing *source* package 'Rflim' ...
** libs
g++ -m64 -I"C:/PROGRA~1/R/R-31~1.2/include" -DNDEBUG -I"C:/Users/Simon/Documents/R/win-library/3.1/Rcpp/include" -I"d:/RCompile/CRANpkg/extralibs64/local/include" -IC:/Users/Simon/Documents/R/win-library/3.1/Rcpp/include -I/usr/local/include -I C:/Users/Simon/Documents/R/win-library/3.1/RcppGSL/include -O2 -Wall -mtune=core2 -c flim.cpp -o flim.o
In file included from C:/Users/Simon/Documents/R/win-library/3.1/RcppGSL/include/RcppGSL.h:23:0,
from flim.cpp:1:
C:/Users/Simon/Documents/R/win-library/3.1/RcppGSL/include/RcppGSLForward.h:26:29: fatal error: gsl/gsl_vector.h: No such file or directory
compilation terminated.
make: *** [flim.o] Error 1
Warnung: Ausf�hrung von Kommando 'make -f "Makevars" -f "C:/PROGRA~1/R/R-31~1.2/etc/x64/Makeconf" -f "C:/PROGRA~1/R/R-31~1.2/share/make/winshlib.mk" SHLIB_LDFLAGS='$(SHLIB_CXXLDFLAGS)' SHLIB_LD='$(SHLIB_CXXLD)' SHLIB="Rflim.dll" WIN=64 TCLBIN=64 OBJECTS="flim.o"' ergab Status 2
ERROR: compilation failed for package 'Rflim'
* removing 'C:/Users/Simon/Documents/R/win-library/3.1/Rflim'
Exited with status 1.
Sorry, there are a couple of german words in there:
Warnung: Ausf�hrung von Kommando==Warning:executing command
What I realize is that R is trying to access the GSL library via the RcppGSL path. Is that correct? Shouldn't it go directly to C:/GSL instead? I also realized that R is trying to go to paths from both Rcpp as well as RcppGSL and I don't see why...
I would appreciate any clarification or suggestions on how to solve the problem.
Thank you!!!
Please install the prebuild GSL version for R on Windows from the support site provided by Prof Ripley and then set these values accordingly in src/Makevars.win
## This assumes that the LIB_GSL variable points to working GSL libraries
PKG_CPPFLAGS=-I$(LIB_GSL)/include -I../inst/include
PKG_LIBS=-L$(LIB_GSL)/lib -lgsl -lgslcblas
either directly, or set LIB_GSL accordingly.
This is how CRAN builds the package, and it evidently works.

Adding Boost Library to a C++ project in OS X Eclipse

I am have been attempting to get a C++ project setup using boost file system library using eclipse. I followed these directions to install boost on my system. The directions where pretty much
download
extract
run bootstrap.sh
run ./bjam architecture=combined
That seemed to go fine, no errors. I then fired up eclipse and created a new test project called test with a single file called test.cpp. The code in it is:
#include <stdio.h>
#include <boost/filesystem.hpp>
int main() {
boost::filesystem::path path("/Users/schoen"); // random pathname
bool result = boost::filesystem::is_directory(path);
printf("Path is a directory : %d\n", result);
return 0;
}
This is just something simple to make sure it is all set up correctly. Of course I tried to compile at this point and it failed. Did some googling and found this site. It said to add the boost library to the linker by going to project properties and adding "boost_filesystem". I tried this, and well it didn't work.
Can someone point me in the right direction or give me a hint to how to set up Boost in an Eclipse project?
I am new to C++ and Eclipse, and most my experience is in Java with Netbeans. So I am pretty lost at the moment.
UPDATE
I just wanted to update on what I have tried based on the answers given.
Based on Alex's suggestion I added boost_system and boost_filesystem to the linker list. I was still getting the same compiler errors.
Following the suggestion from rve I added the path to the boost libraries to the Library search path. When this did not work. I cleared out the linker list and tried it with just the library search path. This also did not work.
I then cleared the Library search path. I then manually edited the command on the linker window to be 'g++ -L/Users/jacobschoen/Library/boost_1_45_0/stage/lib -lboost -lboost_filesystem'. This also did not work.
In all of these I tried setting the path to boost to be '/Users/jacobschoen/Library/boost_1_45_0' and '/Users/jacobschoen/Library/boost_1_45_0/stage/lib'. Neither worked.
As requested the comiler error for the above code is:
**** Build of configuration Debug for project test ****
make all
Building file: ../src/test.cpp
Invoking: GCC C++ Compiler
g++ -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"src/test.d" -MT"src/test.d" -o"src/test.o" "../src/test.cpp"
../src/test.cpp:10:32: warning: boost/filesystem.hpp: No such file or directory
../src/test.cpp: In function 'int main()':
../src/test.cpp:13: error: 'boost' has not been declared
../src/test.cpp:13: error: expected `;' before 'path'
../src/test.cpp:14: error: 'boost' has not been declared
../src/test.cpp:14: error: 'path' was not declared in this scope
make: *** [src/test.o] Error 1
If any one has any further suggestions I am still trying.
Second Update
On a suggestion by rholmes I added an include library along with the linker list and library search path. So now the compile error is:
**** Build of configuration Debug for project test ****
make all
Building target: test
Invoking: MacOS X C++ Linker
g++ -L/Users/jacobschoen/Library/boost_1_45_0 -o "test" ./src/test.o -lboost_system -lboost_filesystem
ld: library not found for -lboost_system
collect2: ld returned 1 exit status
make: *** [test] Error 1
Any ideas?
Just wanted to be clear on what actually worked, since it was kinda pieced together from a few answers.
Download the boost files and extract them to where you want to put them.
In your terminal navigate to the directory and run ./bootstrap.sh
When that is done run ./bjam (this takes a while so go smoke and get a cup of coffee)
Open up your eclipse Project and go to Project > Properties > C/C++ Build > Settings
Click on MacOS X C++ Linker > Libraries.
You should see a split window with the top being for 'Libraries (-l)'. In this section add both boost_system and boost_filesystem. In the bottom section it should be for 'Library Search Path (-L)'. Here you want to put the path to the stage/lib directory inside where you extracted the boost download. It should look similar to below:
Click GCC C++ Compiler > Includes. This will be a single pane where it says 'Include Paths (-I)', well I think it is an I as he font is weird and could be a lower case l also. Anyway in that section add the path to where you put boost without the stage/lib part. It should look like below:
Everything should compile now with out a problem, and if you need to use any other boost libraries it should be just a matter of adding it to the linker section where boost_filesystem and boost_system are. Enjoy.
Not sure where you do this in Eclipse these days, but under the include paths for Eclipse should be the path to the main boost directory (/Users/jacobschoen/Library/boost_1_45_0?). The compiler line should have something like the following in it, I would think:
Invoking: GCC C++ Compiler
g++ -I/Users/jacobschoen/Library/boost_1_45_0 -O0 -g3 -Wall -c -fmessage-length=0 -MMD (etc..)
Update: Looking at my system, the linker path on yours might be more appropriately:
-I/Users/jacobschoen/Library/boost_1_45_0/stage/lib
Depending, of course, upon how you've installed and built boost -- this is with my most recent attempt with a full source build. Depending upon how you obtained boost, this may or may not be different. I recently redid the boost on my Mac for 64 bit and haven't had much time to try it yet....
Add boost_system to the linker list, together with boost_filesystem.
I had recently uninstalled the boost rpm and installed Boost like how you did. I had no problems running Boost programs in Eclipse. I didn't add any extra parameters. Just installed boost and ran Boost programs. It works fine.
Tried your program in the vi editor. Commented out everything in main
#include <cstdio>
#include <boost/filesystem.hpp>
int main() {
/*boost::filesystem::path path("/Users/schoen"); // random pathname
bool result = boost::filesystem::is_directory(path);
printf("Path is a directory : %d\n", result);*/
return 0;
}
and it still gave this error:
/tmp/cc7TAIYS.o: In function `__static_initialization_and_destruction_0(int, int)':
test.cpp:(.text+0x29): undefined reference to `boost::system::get_system_category()'
test.cpp:(.text+0x35): undefined reference to `boost::system::get_generic_category()'
test.cpp:(.text+0x41): undefined reference to `boost::system::get_generic_category()'
test.cpp:(.text+0x4d): undefined reference to `boost::system::get_generic_category()'
test.cpp:(.text+0x59): undefined reference to `boost::system::get_system_category()'
collect2: ld returned 1 exit status
I'm puzzled. Boost programs work on my system, but your program's header files itself are giving a problem. I doubt it's a problem with Eclipse. It has to be something else.
I just ran into something very similar to this using eclipse and CDT... It turns out, using ubuntu and apt-get, libboost_system installs as libboost_system.1.40.0 in /usr/lib
If you try to add it via the library tab in Helios it will complain because it is looking for *.so and *.s0.1.40.0 clearly doesn't match that. However after looking closely at what the linker was trying to doo, I just typed the raw string "boost_system" into the include path adder. This resulted in the linker doing a " -lboost_system" which is a format the linker knows how to deal with in resolving version dependency... If you instead put in the full path to the .so file, the linker will just complain because it tries to do a " -l/usr/lib/libboost_system.so.1.40.0" .
So take my advice and just type in the simple " boost_system" after doing an apt-get install.. It will make it all very easy.