4

I'm developing a project with boost and the preproc doesn't find the boost header files for a mysterious reason.

I'm on a xUbuntu 32 bits and I use g++ and boost 1.55.0


The error: main.cpp:1:26: fatal error: boost/bind.hpp: No such file or directory

If I comment this include, it's the next include who is not found so the problem isn't one file in particular.


The code:

#include "boost/bind.hpp" // just to be sure I test with "" and <>
#include <boost/asio.hpp>
#include <sys/types.h>


The makefile:

NAME            = myProject

INSTALL_DIR     = /usr/local/bin

FILES_DIR       = /etc/myProject

RC_FILE         = ./scripts/myproject.rc

SRC             = main.cpp

OBJ             = $(SRC:.cpp=.o)

CC              = g++

IFLAGS          = -I./boost/

LFLAGS          = -pthread -L./boost/stage/lib/ -lboost_system-mt -lboost_regex-mt -lboost_filesystem-mt

RM              = rm -f

all     :  $(OBJ)
           $(CC) -o $(NAME) $(OBJ) $(IFLAGS) $(LFLAGS)

install :
          mkdir -p $(INSTALL_DIR)
          mkdir -p $(FILES_DIR)
          cp $(NAME) $(INSTALL_DIR)
          cp $(RC_FILE) /etc/init.d/
          insserv $(RC_FILE)

remove  :
          insserv --remove $(RC_FILE)

clean   :
          find . -name "*~" -exec rm {} \;
          find . -name "*.o" -exec rm {} \;

fclean  : clean
          $(RM) $(NAME)

re      : clean all

.PHONY  : install remove clean fclean


The main.cpp and the makefile are in whatever/myproject/

The boost library is in whatever/myproject/boost/

The boost libs (.a and .so) are in whatever/myproject/boost/stage/lib/

The boost headers are in whatever/myproject/boost/boost/


I've searched for about 2 hours, tried everything I can think of without success, so thank you very much in advance to the person who can resolve this problem.


Edit:

Bidule0hm make -n
g++ -c -o main.o main.cpp
g++ -o myProject main.o -I./boost/ -pthread -L./boost/stage/lib/ -lboost_system-mt -lboost_regex-mt -lboost_filesystem-mt
Biduleohm
  • 734
  • 2
  • 10
  • 19

2 Answers2

2

I've finally solved the problem by installing boost with apt-get instead of using it locally in the project folder.

Other answer that helped me here

Community
  • 1
  • 1
Biduleohm
  • 734
  • 2
  • 10
  • 19
1

Can you run make -n or make V=1 and post the output?

Second Post:

I think the include folders have to come before the -o on g++. Can you replace $(CC) -o $(NAME) $(OBJ) $(IFLAGS) $(LFLAGS)

with $(CC) -c $(IFLAGS) -o $(NAME) $(OBJ) $(LFLAGS)

A sample line from my project looks like:

g++ -c -g -I.. -I/usr/include/boost -std=c++11 "build/Debug/main.o.d" -o build/Debug/main.o main.cpp

First post:

For laughs, try doing -I/full/path/to/boost.

Often with these issues, its more of a case of the "." not being the directory you think it is.

Please also post up what platform you're on(windows, Linux), and the makefile :)

Caladain
  • 4,801
  • 22
  • 24
  • I've just tried with the absolute path, it doesn't work either. I've added the requested details. – Biduleohm Aug 01 '14 at 19:37
  • Doesn't work with the include before, sorry. This makefile is copied and modified from another project (but in C) which works like a charm so I don't understand why it doesn't work here. – Biduleohm Aug 01 '14 at 20:31
  • I've edited with the result of `make -n`, and `make V=1` output the same error as `make` – Biduleohm Aug 01 '14 at 21:24