0

I'm trying to compile a small c++ project with one file only. The 5 first lines of BoostRegex.cpp are:

#include <iostream>
#include <string>
#include <regex.hpp>

int main() { ....

I run the following ./configure line (it's a cross compile):

cmake -DCMAKE_TOOLCHAIN_FILE=/home/vitor/bin/raspi/cmaketoolchain/toolchain.cmake ../src/

This line works with the following output:

[vitor@archlinux bin]$ cmake -DCMAKE_TOOLCHAIN_FILE=/home/vitor/bin/rasp/cmaketoolchain/toolchain.cmake ../src/
-- The C compiler identification is GNU 4.7.3
-- The CXX compiler identification is GNU 4.7.3
-- Check for working C compiler: /home/vitor/local/x-tools/arm-unknown-linux-gnueabi/bin/arm-unknown-linux-gnueabi-gcc
-- Check for working C compiler: /home/vitor/local/x-tools/arm-unknown-linux-gnueabi/bin/arm-unknown-linux-gnueabi-gcc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: /home/vitor/local/x-tools/arm-unknown-linux-gnueabi/bin/arm-unknown-linux-gnueabi-g++
-- Check for working CXX compiler: /home/vitor/local/x-tools/arm-unknown-linux-gnueabi/bin/arm-unknown-linux-gnueabi-g++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Boost version: 1.49.0
-- Found the following Boost libraries:
--   system
--   regex
--   unit_test_framework
status ** Boost Root: /home/vitor/local/usr/lib **
status ** Boost Include: /home/vitor/local/usr/include **
status ** Boost Libraries Dirs:  **
status ** Boost Librraries: /home/vitor/local/usr/lib **
-- Configuring done
-- Generating done
-- Build files have been written to: /home/vitor/tmp/boost-regex/bin

But when I run the make command:

[vitor@archlinux bin]$ make
Scanning dependencies of target BoostRegex
[100%] Building CXX object CMakeFiles/BoostRegex.dir/BoostRegex.cpp.o
In file included from /home/vitor/local/usr/include/features.h:323:0,
             from /home/vitor/local/x-tools/arm-unknown-linux-gnueabi/lib/gcc/arm-unknown-linux-gnueabi/4.7.3/../../../../arm-unknown-linux-gnueabi/include/c++/4.7.3/arm-unknown-linux-gnueabi/bits/os_defines.h:40,
             from /home/vitor/local/x-tools/arm-unknown-linux-gnueabi/lib/gcc/arm-unknown-linux-gnueabi/4.7.3/../../../../arm-unknown-linux-gnueabi/include/c++/4.7.3/arm-unknown-linux-gnueabi/bits/c++config.h:414,
             from /home/vitor/local/x-tools/arm-unknown-linux-gnueabi/lib/gcc/arm-unknown-linux-gnueabi/4.7.3/../../../../arm-unknown-linux-gnueabi/include/c++/4.7.3/iostream:39,
             from /home/vitor/tmp/boost-regex/src/BoostRegex.cpp:1:
/home/vitor/local/x-tools/arm-unknown-linux-gnueabi/arm-unknown-linux-gnueabi/sysroot/usr/include/bits/predefs.h:23:3: error: #error "Never use <bits/predefs.h> directly; include <stdc-predef.h> instead."
/home/vitor/tmp/boost-regex/src/BoostRegex.cpp:3:21: fatal error: regex.hpp: No such file or directory
compilation terminated.
make[2]: *** [CMakeFiles/BoostRegex.dir/BoostRegex.cpp.o] Error 1
make[1]: *** [CMakeFiles/BoostRegex.dir/all] Error 2
make: *** [all] Error 2

I have to indicate once again the headers of boost lib? How can I do it?

Fraser
  • 74,704
  • 20
  • 238
  • 215
Vitor Carvalho
  • 335
  • 1
  • 5
  • 11

1 Answers1

0

This looks like an error in your CMakeLists.txt

Are you including the correct dirs as per the FindBoost module?

include_directories(${Boost_INCLUDE_DIRS})
Fraser
  • 74,704
  • 20
  • 238
  • 215
  • Hi! I made some changes on CMakeLists.txt, the lines 7, 8 and 18, 19 (commented) are lines written before your answer (https://gist.github.com/vitorcarvalhoml/5748911). The following gist, shows the output of cmake command: https://gist.github.com/vitorcarvalhoml/5748943 look at lines 17-19. The make command will look for boost libs in my /usr/lib. But I want to make a cross compile. Thanks! – Vitor Carvalho Jun 10 '13 at 14:03
  • I've forked your Gist [here](https://gist.github.com/Fraser999/5753224) - can you give that a go? – Fraser Jun 10 '13 at 23:11
  • I tested your CMakeLists.txt and it works but I have another problem this time with another libs. I change the approach to make command. It's fine until know. Thanks for your answer. – Vitor Carvalho Jul 02 '13 at 18:01