0

我正在尝试编译从此链接获得的 luabind 。在我做之后

mkdir build
cmake ..
make VERBOSE=1

“cmake ..” 产生这些行,

-- The C compiler identification is GNU
-- The CXX compiler identification is GNU
-- Check for working C compiler: /usr/bin/gcc
-- Check for working C compiler: /usr/bin/gcc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/g++-4.7
-- Check for working CXX compiler: /usr/bin/g++-4.7 -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Boost version: 1.53.0
-- Found Lua52: /usr/lib/i386-linux-gnu/liblua5.2.so;/usr/lib/i386-linux-gnu/libm.so 
-- Configuring done
-- Generating done
-- Build files have been written to: /home/mwh/Desktop/Downloads/luabind-master/build

“make VERBOSE=1”会产生以下错误。

/usr/bin/cmake -H/home/mwh/Desktop/Downloads/luabind-master -B/home/mwh/Desktop/Downloads/luabind-master/build --check-build-system CMakeFiles/Makefile.cmake 0
/usr/bin/cmake -E cmake_progress_start /home/mwh/Desktop/Downloads/luabind-master/build/CMakeFiles /home/mwh/Desktop/Downloads/luabind-master/build/CMakeFiles/progress.marks
make -f CMakeFiles/Makefile2 all
make[1]: Entering directory `/home/mwh/Desktop/Downloads/luabind-master/build'
make -f src/CMakeFiles/luabind.dir/build.make src/CMakeFiles/luabind.dir/depend
make[2]: Entering directory `/home/mwh/Desktop/Downloads/luabind-master/build'
cd /home/mwh/Desktop/Downloads/luabind-master/build && /usr/bin/cmake -E cmake_depends "Unix Makefiles" /home/mwh/Desktop/Downloads/luabind-master /home/mwh/Desktop/Downloads/luabind-master/src /home/mwh/Desktop/Downloads/luabind-master/build /home/mwh/Desktop/Downloads/luabind-master/build/src /home/mwh/Desktop/Downloads/luabind-master/build/src/CMakeFiles/luabind.dir/DependInfo.cmake --color=
make[2]: Leaving directory `/home/mwh/Desktop/Downloads/luabind-master/build'
make -f src/CMakeFiles/luabind.dir/build.make src/CMakeFiles/luabind.dir/build
make[2]: Entering directory `/home/mwh/Desktop/Downloads/luabind-master/build'
/usr/bin/cmake -E cmake_progress_report /home/mwh/Desktop/Downloads/luabind-master/build/CMakeFiles 2
[  1%] Building CXX object src/CMakeFiles/luabind.dir/class.cpp.o
cd /home/mwh/Desktop/Downloads/luabind-master/build/src && /usr/bin/g++-4.7    -I/usr/local/include -I/usr/include/lua5.2 -I/home/mwh/Desktop/Downloads/luabind-master    -o CMakeFiles/luabind.dir/class.cpp.o -c /home/mwh/Desktop/Downloads/luabind-master/src/class.cpp
In file included from /home/mwh/Desktop/Downloads/luabind-master/luabind/object.hpp:38:0,
                 from /home/mwh/Desktop/Downloads/luabind-master/luabind/scope.hpp:28,
                 from /home/mwh/Desktop/Downloads/luabind-master/luabind/class.hpp:92,
                 from /home/mwh/Desktop/Downloads/luabind-master/src/class.cpp:30:
/home/mwh/Desktop/Downloads/luabind-master/luabind/detail/policy.hpp: In member function ‘T luabind::detail::enum_converter::apply(lua_State*, luabind::detail::by_value<T>, int)’:
/home/mwh/Desktop/Downloads/luabind-master/luabind/detail/policy.hpp:498:21: error: ‘underlying_type’ in namespace ‘std’ does not name a type
/home/mwh/Desktop/Downloads/luabind-master/luabind/detail/policy.hpp:499:47: error: expected type-specifier before ‘integral_t’
/home/mwh/Desktop/Downloads/luabind-master/luabind/detail/policy.hpp:499:47: error: expected ‘&gt;’ before ‘integral_t’
/home/mwh/Desktop/Downloads/luabind-master/luabind/detail/policy.hpp:499:47: error: expected ‘(’ before ‘integral_t’
/home/mwh/Desktop/Downloads/luabind-master/luabind/detail/policy.hpp:499:47: error: ‘integral_t’ was not declared in this scope
/home/mwh/Desktop/Downloads/luabind-master/luabind/detail/policy.hpp:499:83: error: expected ‘)’ before ‘;’ token
make[2]: *** [src/CMakeFiles/luabind.dir/class.cpp.o] Error 1
make[2]: Leaving directory `/home/mwh/Desktop/Downloads/luabind-master/build'
make[1]: *** [src/CMakeFiles/luabind.dir/all] Error 2
make[1]: Leaving directory `/home/mwh/Desktop/Downloads/luabind-master/build'
make: *** [all] Error 2

我该怎么做才能纠正这个问题?我在 Ubuntu 12.04 中使用 gcc 4.7.3、boost 1.53、Lua 5.2。请帮忙。

4

1 回答 1

0

我刚刚检查了修订版 05c84a034e 的项目,并在 Mac OS X 上构建了它。这是 CMake 在配置时告诉我的内容:

-- The CXX compiler identification is GNU 4.7.3
-- Checking whether CXX compiler has -isysroot - yes
-- Checking whether CXX compiler supports OSX deployment target flag - yes
-- Check for working CXX compiler: /opt/local/bin/g++ -- works
-- Detecting CXX compiler ABI info - done
-- Boost version: 1.53.0
-- Found Lua52: /opt/local/lib/liblua.dylib;  

所以我有 GCC 4.7.3、Boost 1.53 和 Lua 5.2。我看到你也有 GCC 4.7.3,但是 Boost 和 Lua 呢?

make VERBOSE=1编辑:这是我的第一个文件的编译行:

g++ -Wall -std=c++11 -pedantic -Wall -Wextra -Wcast-align -Wcast-qual -Wctor-dtor-privacy -Wdisabled-optimization -Wformat=2 -Winit-self -Wlogical-op -Wmissing-declarations -Wmissing-include-dirs -Wnoexcept -Wold-style-cast -Woverloaded-virtual -Wredundant-decls -Wshadow -Wsign-conversion -Wsign-promo -Wstrict-null-sentinel -Wstrict-overflow=5 -Wno-deprecated-declarations -o CMakeFiles/luabind.dir/class.cpp.o -c class.cpp

另一方面,你展示了这一点:

g++-4.7 -o CMakeFiles/luabind.dir/class.cpp.o -c class.cpp

所以问题是,你所有的编译器标志都到哪里去了?顶级 CMakeLists.txt 应包含以下内容:

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -std=c++11")

还有更多。由于您没有设置这些标志,因此您需要找出原因。您可以尝试message("I am here")在 CMakeLists.txt 中添加一些调试语句并从头开始再次运行 cmake 以查看配置的预期部分是否正在执行。这里的关键是你的编译行缺少-std=c++11——这就是你得到错误的原因。

于 2013-07-06T10:47:55.567 回答