c++ - 找不到头文件 (boost/bind.hpp)

标签 c++ include header-files

我正在开发一个带有 boost 的项目,preproc 出于某种神秘原因找不到 boost 头文件。

我在 xUbuntu 32 位上,我使用 g++boost 1.55.0


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

如果我评论这个包含,它是未找到的下一个包含,所以问题不在于一个文件。


代码:

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


生成文件:

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


ma​​in.cpp 和 makefile 在 whatever/myproject/

boost库在whatever/myproject/boost/

boost 库(.a 和 .so)位于 whatever/myproject/boost/stage/lib/

boost header 位于 whatever/myproject/boost/boost/


我已经搜索了大约 2 个小时,尝试了所有我能想到的方法但都没有成功,所以非常感谢能解决这个问题的人。


编辑:

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

最佳答案

我终于通过使用 apt-get 安装 boost 而不是在项目文件夹中本地使用它来解决了这个问题。

其他对我有帮助的答案here

关于c++ - 找不到头文件 (boost/bind.hpp),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25087163/

相关文章:

c++ - QStandardItemModel 最有效的行删除策略

c++ - 在 C++ 中使用#ifndef 和#define 是否过时了?

c 双参数作为错误值传递

C 头文件问题 : #include and "undefined reference"

c++ - 如何为 OpenGL ES 重写 2D OpenGL 应用程序?

php - 在 VS15 中编译 PHP7 时找不到 bison.exe

c++ - 在 cuda 设备代码中使用 boost 等库

PHP include_once 添加尾随 1 到页面

c++ - 使用包含文件(自己的类)编译时出错

c++ - 头文件中的常量指针