Boost libs 1.64.0 and Eclipse Luna - c++

I'm trying to make Boost libs to work with Eclipse Luna (I know it's an old version but I'm tied to work with it).
My system is a Linux Mint 18.1.
I downloaded, unpacked and installed the libraries following this guide.
I ended up with unpacked libraries in my home folder and compiled ones in usr/local/include/boost folder.
Next I added the latter to the LD LIBRARY PATH and resetted the ldconfig.
At this point I copied some code on an empty C++ project.
The header I'm using is "share_ptr.hpp" so I set the #include .
After that I added the include path to the included headers under Project -> Properties -> C/C++ General -> Paths and Symbols.
I added the path /usr/local/include as included directory.
When I build I get the error: "No such file or directory".
If I #include the header with the absolute path, I can find the file but I get another error cause this .hpp file has references to the "relative" path /boost/smart_ptr/share_ptr, so it doesn't find all those headers:
#ifndef BOOST_SMART_PTR_HPP_INCLUDED
#define BOOST_SMART_PTR_HPP_INCLUDED
#include <boost/config.hpp>
#include <boost/scoped_ptr.hpp>
#include <boost/scoped_array.hpp>
#include <boost/shared_ptr.hpp>
#include <boost/shared_array.hpp>
#if !defined(BOOST_NO_MEMBER_TEMPLATES) || defined(BOOST_MSVC6_MEMBER_TEMPLATES)
# include <boost/weak_ptr.hpp>
# include <boost/intrusive_ptr.hpp>
# include <boost/enable_shared_from_this.hpp>
# include <boost/make_shared.hpp>
#endif
#endif // #ifndef BOOST_SMART_PTR_HPP_INCLUDED
Looks like to me that Eclipse can't get the include path correctly.
Another thing that I tried was adding the -L for the linker, but it doesn't work either.
This is what I'm including:
#include <vector>
#include <boost/shared_ptr.hpp>
Could you help me to understand what it's going on ?
Adding informations:
CODE:
#include <boost/lambda/lambda.hpp>
#include <iostream>
#include <iterator>
#include <algorithm>
int main()
{
using namespace boost::lambda;
typedef std::istream_iterator<int> in;
std::for_each(
in(std::cin), in(), std::cout << (_1 * 3) << " " );
}
CONSOLE:
08:13:11 **** Incremental Build of configuration Build (GNU) for project TESTCODE ****
make all
make all-recursive
make[1]: Entering directory '/home/daniele/workspace/TESTCODE'
Making all in src
make[2]: Entering directory '/home/daniele/workspace/TESTCODE/src'
arm-poky-linux-gnueabi-g++ -march=armv7ve -mfpu=neon -mfloat-abi=hard -mcpu=cortex-a7 --sysroot=/opt/fsl-imx-fb/4.1.15-2.0.1/sysroots/cortexa7hf-neon-poky-linux-gnueabi -DHAVE_CONFIG_H -I. -I.. --sysroot=/opt/fsl-imx-fb/4.1.15-2.0.1/sysroots/cortexa7hf-neon-poky-linux-gnueabi -g -O0 --sysroot=/opt/fsl-imx-fb/4.1.15-2.0.1/sysroots/cortexa7hf-neon-poky-linux-gnueabi -MT TESTCODE.o -MD -MP -MF .deps/TESTCODE.Tpo -c -o TESTCODE.o TESTCODE.cpp
TESTCODE.cpp:11:35: fatal error: boost/lambda/lambda.hpp: No such file or directory
compilation terminated.
make[2]: *** [TESTCODE.o] Error 1
Makefile:398: recipe for target 'TESTCODE.o' failed
make[1]: *** [all-recursive] Error 1
make[2]: Leaving directory '/home/daniele/workspace/TESTCODE/src'
make: *** [all] Error 2
Makefile:403: recipe for target 'all-recursive' failed
make[1]: Leaving directory '/home/daniele/workspace/TESTCODE'
Makefile:335: recipe for target 'all' failed
08:13:11 Build Finished (took 84ms)
ERRORS:
Description Resource Path Location Type fatal error:
boost/lambda/lambda.hpp: No such file or
directory TESTCODE.cpp /TESTCODE/src line 11 C/C++ Problem make: *
[all] Error 2 TESTCODE C/C++ Problem make1: * [all-recursive]
Error 1 TESTCODE C/C++ Problem make[2]: *** [TESTCODE.o] Error
1 TESTCODE C/C++ Problem recipe for target 'all-recursive'
failed Makefile /TESTCODE line 403 C/C++ Problem recipe for target
'all' failed Makefile /TESTCODE line 335 C/C++ Problem recipe for
target 'TESTCODE.o' failed Makefile /TESTCODE line 398 C/C++ Problem

Related

"No such file or directory" when including SFML/Graphics.hpp from a header file

Everything compiles fine when I include this particular .hpp in a header in a test project I made with identical (copy-pasted) project settings (include path, linker path etc.). For some reason however, my project won't compile when trying to include it from a file deep in my header hierarchy. Headers have guards.
Here's the log:
C:\WINDOWS\system32\cmd.exe /C ""C:/Program Files (x86)/CodeBlocks/MinGW/bin/mingw32-make.exe" -j4 SHELL=cmd.exe -e -f Makefile"
"----------Building project:[ Rogue - Debug ]----------"
mingw32-make.exe[1]: Entering directory 'E:/CPP/Rogue/Rogue'
codelite-cc "C:/Program Files (x86)/CodeBlocks/MinGW/bin/g++.exe" -g -O0 -std=c++17 -std=c++14 -std=c++11 -Wall Char.cpp -o Char
In file included from Item.h:7:0, //this says ' #include "Entity.h" '
from Char.h:12, //this says ' #include "Item.h" '
from Char.cpp:1:
Entity.h:5:29: fatal error: SFML/Graphics.hpp: No such file or directory
compilation terminated.
mingw32-make.exe[1]: *** [Char] Error 1
<builtin>: recipe for target 'Char' failed
mingw32-make.exe[1]: Leaving directory 'E:/CPP/Rogue/Rogue'
mingw32-make.exe: *** [All] Error 2
Makefile:4: recipe for target 'All' failed
====3 errors, 1 warnings====
And here is my header "hierarchy". (A.h -> B.h means that A #includes B)
defs.h and utils.h are irrelevant class-wise (they contain #defines and utility functions respectively.)
My compiler settings:
Compiler
Linker
SFML is installed in E:/CPP/Libs/SFML
The project is in E:/CPP/Rogue
No enviroment variable as far as I'm aware.

Armadillo : Can not find clapack.h

I am trying to install Armadillo link.
However, make command complains about "clapack.h" which does exists at location /usr/include/atlas/clapack.h. Some help would be appreciated.
Note, I can run it if I copy that file to /usr/include/ and then make:
$ sudo cp /usr/include/atlas/clapack.h /usr/include/
$ make
But, I am not comfortable in making copies of same file in multiple location. Could it be dangerous?
This is what I did so far:
1) I downloaded and tar the armadillo library. After that, I changed following lines in CMakeLists.txt (I have Lapack, Blas, Atlas):
set(ARMA_USE_LAPACK true)
set(ARMA_USE_BLAS true)
set(ARMA_USE_ATLAS true)
set(ARMA_USE_HDF5_ALT false)
set(ARMA_USE_ARPACK false)
set(ARMA_USE_CXX11_RNG false)
set(ARMA_USE_WRAPPER true )
then "$cmake ." runs successfully and finds Lapack, Blas and Atlas.
However, when I run "make" it gives following error (line 26 marked in the code include_atlas.hpp):
$ make
Scanning dependencies of target armadillo
[100%] Building CXX object CMakeFiles/armadillo.dir/src/wrapper.cpp.o
In file included from /home/dkumar/Downloads/armadillo-4.600.3/src/wrapper.cpp:10:0:
/home/dkumar/Downloads/armadillo-4.600.3/tmp/include/armadillo_bits/include_atlas.hpp:26:47: fatal error: /usr/include/clapack.h: No such file or directory
#include ARMA_INCFILE_WRAP(ARMA_CLAPACK)
^
compilation terminated.
make[2]: *** [CMakeFiles/armadillo.dir/src/wrapper.cpp.o] Error 1
make[1]: *** [CMakeFiles/armadillo.dir/all] Error 2
make: *** [all] Error 2
When I look at include_atlas.hpp, it seems that ARMA_USE_ATLAS is still set false:
// Copyright (C) 2008-2011 Conrad Sanderson
// Copyright (C) 2008-2011 NICTA (www.nicta.com.au)
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
#if defined(ARMA_USE_ATLAS)
#if !defined(ARMA_ATLAS_INCLUDE_DIR)
extern "C"
{
#include <cblas.h>
#include <clapack.h>
}
#else
#define ARMA_STR1(x) x
#define ARMA_STR2(x) ARMA_STR1(x)
#define ARMA_CBLAS ARMA_STR2(ARMA_ATLAS_INCLUDE_DIR)ARMA_STR2(cblas.h)
#define ARMA_CLAPACK ARMA_STR2(ARMA_ATLAS_INCLUDE_DIR)ARMA_STR2(clapack.h)
extern "C"
{
#include ARMA_INCFILE_WRAP(ARMA_CBLAS)
#include ARMA_INCFILE_WRAP(ARMA_CLAPACK) // This is line no 26
}
#undef ARMA_STR1
#undef ARMA_STR2
#undef ARMA_CBLAS
#undef ARMA_CLAPACK
#endif
#endif
If I replace ARMA_CLAPACK with "/usr/include/atlas/clapack.h", it still complains:
$ make
Scanning dependencies of target armadillo
[100%] Building CXX object CMakeFiles/armadillo.dir/src/wrapper.cpp.o
In file included from /home/dkumar/Downloads/armadillo-4.600.3/src/wrapper.cpp:10:0:
/home/dkumar/Downloads/armadillo-4.600.3/tmp/include/armadillo_bits/include_atlas.hpp:26:89: fatal error: "/usr/include/atlas/clapack.h": No such file or directory
#include ARMA_INCFILE_WRAP("/usr/include/atlas/clapack.h") // This is line no 26
^
compilation terminated.
make[2]: *** [CMakeFiles/armadillo.dir/src/wrapper.cpp.o] Error 1
make[1]: *** [CMakeFiles/armadillo.dir/all] Error 2
make: *** [all] Error 2
I was having same problem while running make after cmake . when I check the cmake output it was pointing to wrong atlas directory i.e. it was pointing to ATLAS_INCLUDE_DIR = /usr/include/ where as it should have been pointing to ATLAS_INCLUDE_DIR = /usr/include/atlas.
-- Found ATLAS: /usr/lib/libatlas.so
-- Found BLAS: /usr/lib/libblas.so
-- Found LAPACK: /usr/lib/liblapack.so
-- MKL_FOUND = NO
-- ACMLMP_FOUND = NO
-- ACML_FOUND = NO
-- OpenBLAS_FOUND = NO
-- ATLAS_FOUND = YES
-- BLAS_FOUND = YES
-- LAPACK_FOUND = YES
-- ATLAS_INCLUDE_DIR = /usr/include/
-- ARPACK_FOUND = NO
--
-- *** Armadillo wrapper library will use the following libraries:
-- *** ARMA_LIBS = /usr/lib/libatlas.so;/usr/lib/libblas.so;/usr/lib/liblapack.so
I correct this by adding correct path in CmakeCache.txt file. After that it make and make install run fine.
But I am having this error while running after compiling example using
g++ -O2 -o example1 example1.cpp -larmadillo
the error is
./example1: error while loading shared libraries: libarmadillo.so.4: cannot open shared object file: No such file or directory
Note: The above error can be solved by creating a symbolic link of libarmadillo.so and libarmadillo.so.4 in /usr/lib directory.

Using Netbeans with Cygwin and SDL, including SDL.h creates strange error

I've got Netbeans C/C++ set up, Cygwin installed, configured and running correctly. SDL was installed from the sources using the Cygwin terminal. I've confirmed that Cygwin, Netbeans and SDL are all running correctly, I can write and compile C++ projects just fine with Netbeans and Netbeans can see SDL without having to include any files or anything, it just works like the default libraries.
#include <cstdlib>
#include <sdl2/SDL.h>
using namespace std;
int main(int argc, char** argv) {
return 0;
}
That's the code I'm trying to compile, Netbeans doesn't highlight the include for sdl.h, but when I go to build I get this:
"/usr/bin/make" -f nbproject/Makefile-Debug.mk QMAKE= SUBPROJECTS= .build-conf
make[1]: Entering directory '/home/Cally/Projects/Test'
"/usr/bin/make" -f nbproject/Makefile-Debug.mk dist/Debug/Cygwin_4.x-Windows/test.exe
make[2]: Entering directory '/home/Cally/Projects/Test'
mkdir -p build/Debug/Cygwin_4.x-Windows
rm -f "build/Debug/Cygwin_4.x-Windows/main.o.d"
g++ -c -g -MMD -MP -MF "build/Debug/Cygwin_4.x-Windows/main.o.d" -o build/Debug/Cygwin_4.x-Windows/main.o main.cpp
mkdir -p dist/Debug/Cygwin_4.x-Windows
g++ -o dist/Debug/Cygwin_4.x-Windows/test build/Debug/Cygwin_4.x-Windows/main.o
/usr/lib/gcc/x86_64-pc-cygwin/4.8.3/../../../../lib/libcygwin.a(libcmain.o): In function `main':
/usr/src/debug/cygwin-1.7.30-1/winsup/cygwin/lib/libcmain.c:39: undefined reference to `WinMain'
/usr/src/debug/cygwin-1.7.30-1/winsup/cygwin/lib/libcmain.c:39:(.text.startup+0x7e): relocation truncated to fit: R_X86_64_PC32 against undefined symbol `WinMain'
collect2: error: ld returned 1 exit status
nbproject/Makefile-Debug.mk:62: recipe for target 'dist/Debug/Cygwin_4.x-Windows/test.exe' failed
make[2]: *** [dist/Debug/Cygwin_4.x-Windows/test.exe] Error 1
make[2]: Leaving directory '/home/Cally/Projects/Test'
nbproject/Makefile-Debug.mk:59: recipe for target '.build-conf' failed
make[1]: *** [.build-conf] Error 2
make[1]: Leaving directory '/home/Cally/Projects/Test'
nbproject/Makefile-impl.mk:39: recipe for target '.build-impl' failed
make: *** [.build-impl] Error 2
BUILD FAILED (exit value 2, total time: 1s)
The build is successful when I don't include SDL. Anybody know what I'm doing wrong?
The error message looks really evil - but it just tells you it can't find a WinMain.
This is a known issue with SDL. Please add those libraries to your linker (order is mandatory!):
mingw32
SDLmain
SDL
You can either add -lmingw32 -lSDLmain -lSDL to linker options or add them through the library menu of linker config.
It's possible you need SDL_mixer too - if so, just add it last.
Please see also: http://content.gpwiki.org/index.php/SDL%3aTutorials%3aSetup
As a "dirty workaround" you can do this: undefine main.
SDL redefines main() as a macro with some additional stuff. You can verify this by egl. Ctrl + click on main / go to declaration / definition or check if it's formatted as makro.
#include <cstdlib>
#include <sdl2/SDL.h>
using namespace std;
/*
* If 'main' is defined we clear that definition
* to get our default 'main' function back.
*/
#ifdef main
# undef main
#endif /* main */
int main(int argc, char** argv) {
return 0;
}
Please see source of SDL_main.h (line 103+).

SDL MinGW Netbeans. <SDL/SDL.h> no such file or directory

PROBLEM SOLVED
Go to bottom to see the solution.
Hello everybody i've been googling' looooong time and I didn't find anythinig, so, here we go:
I have this setup:
Compiler: MinGW IDE: Netbeans Library: SDL Language:
C++
Okey, so, i have included this folder: "C:/SDL_1.2.15/include"
And Linked those libraries in this order:
-lmingw32
-lSDL_main
-lSDL
Then if I use a normal program without the #include "SDL/SDL.h" then compiles okeey.
So if i include the SDL header file the IDE gives me greenlight to compile an then, i get this output:
"C:/WinAVR-20090313/utils/bin/make" -f nbproject/Makefile-Debug.mk QMAKE= SUBPROJECTS= .build-conf
make[1]: Entering directory `C:/Users/pablo/Documents/NetBeansProjects/SDL_Test'
"C:/WinAVR-20090313/utils/bin/make" -f nbproject/Makefile-Debug.mk dist/Debug/MinGW-Windows/sdl_test.exe
make[2]: Entering directory `C:/Users/pablo/Documents/NetBeansProjects/SDL_Test'
mkdir -p build/Debug/MinGW-Windows
rm -f build/Debug/MinGW-Windows/main.o.d
g++.exe -c -g -Wall -I/C/MinGW/include -I/C/SDL-1.2.15/include -MMD -MP -MF build/Debug/MinGW-Windows/main.o.d -o build/Debug/MinGW-Windows/main.o main.cpp
make[2]: Leaving directory `C:/Users/pablo/Documents/NetBeansProjects/SDL_Test'
make[1]: Leaving directory `C:/Users/pablo/Documents/NetBeansProjects/SDL_Test'
main.cpp:11:21: error fatal: SDL/SDL.h: No such file or directory
compilaci�n terminada.
make[2]: *** [build/Debug/MinGW-Windows/main.o] Error 1
make[1]: *** [.build-conf] Error 2
make: *** [.build-impl] Error 2
BUILD FAILED (exit value 2, total time: 2s)
So! Here is the source code of my application, it only has a 'main.cpp' file:
/*
* File: main.cpp
* Author: pablo
*
* Created on 1 de septiembre de 2013, 23:20
*/
#include <cstdlib>
#include <windows.h>
#include <SDL/SDL.h>
using namespace std;
/*
*
*/
int main(int argc, char** argv) {
return 0;
}
I've found new issues; When I remove the #include (comment //) then the console throws me this errors instead the 'no such file or directory':
c:/mingw/bin/../lib/gcc/mingw32/4.6.2/../../../../mingw32/bin/ld.exe: cannot find -lSDLmain
c:/mingw/bin/../lib/gcc/mingw32/4.6.2/../../../../mingw32/bin/ld.exe: cannot find -lSDL.dll
When I compile without #include using Cygwin compiler, the project builds correctly.
Found another issue:
make[2]: *** No rule to make target `/C/SDL-1.2.15/lib/libSDLmain.a', needed by `dist/Debug/MinGW-Windows/sdl_test.exe'. Stop.
this happens when I add the full path to the SDL libraries instead of -lSDL.dll and -lSDL_main
SOLUTION:
The problem solves coping c:/SDL-1.15/include/SDL/ folder to c:/MinGW/include/ directory, and libraries from lib on c:/SDL-1.15/lib/SDL to MinGW/lib
You have to add the headers separately.
It's not enough to do the include, you have to do multiple things to add a thing like SDL in your project.

How to add lua5.1 to CMakeLists.txt? error: lua.hpp is not found

I added the following lines to my CMakeLists.txt:
find_package(Lua51 REQUIRED)
include_directories(${LUA_INCLUDE_DIRS})
target_link_libraries(cmqhd ${LUA_LIBRARIES} ${Boost_LIBRARIES} ${GOBJECT_LIBRARIES} -lntl -lm -lgmp )
and I still get an error:
In file included from /home/kirill/Dropbox/work/dev/cmqhd/source/main.cc:10:0:
/home/kirill/Dropbox/work/dev/cmqhd/source/lua_read.h:9:17: fatal error: lua.h: No such file or directory
compilation terminated.
make[2]: *** [CMakeFiles/cmqhd.dir/source/main.cc.o] Error 1
make[1]: *** [CMakeFiles/cmqhd.dir/all] Error 2
make: *** [all] Error 2
the file lua_read.h has the following header:
#ifndef LUA_READ_H
#define LUA_READ_H
#include <stdio.h>
#include <string.h>
#include <iostream>
#include <lua.hpp>
...
update (1)
g++ main.C -I/usr/include/lua5.1/ -llua5.1
compiles
${LUA_INCLUDE_DIR} instead of ${LUA_INCLUDE_DIRS} (dir, not dirS)