gpt4 book ai didi

c++ - 在 Linux Mint 17.1 64 位(未声明/不是类型)上尝试 "make"C++ 项目时从 cstdlib 编译错误和类似错误

转载 作者:塔克拉玛干 更新时间:2023-11-03 00:52:59 24 4
gpt4 key购买 nike

我有点卡在这上面了。我刚刚安装了一个带有 Linux Mint 的虚拟盒子,设置了我需要的各种库/包,并且在尝试“制作”时遇到错误

因为我的项目需要 OpenCV,所以我按照以下说明进行包安装等: http://docs.opencv.org/doc/tutorials/introduction/linux_install/linux_install.html

构建 OpenCV 本身没有任何问题,这就是为什么以下错误代码让我感到非常惊讶......

在项目上使用 cmake 后,我尝试“制作”它并得到以下错误(为了清楚起见,只选择了几个示例 - 完整的错误日志可以在这里找到:http://pastebin.com/Ekn3szTb):

    /usr/include/x86_64-linux-gnu/bits/mathcalls.h:112:1: error: ‘log10’ was not declared in this scope
__MATHCALL (log10,, (_Mdouble_ __x));
^
/usr/include/x86_64-linux-gnu/bits/mathcalls.h:112:1: error: ‘__CONCAT’ cannot be used as a function
__MATHCALL (log10,, (_Mdouble_ __x));
^
/usr/include/x86_64-linux-gnu/bits/mathcalls.h:112:1: error: expected primary-expression before ‘)’ token
__MATHCALL (log10,, (_Mdouble_ __x));

[...]

/usr/include/x86_64-linux-gnu/bits/mathcalls.h:195:1: error: expected primary-expression before ‘)’ token
__MATHDECL_1 (int,__finite,, (_Mdouble_ __value)) __attribute__ ((__const__));
^
/usr/include/x86_64-linux-gnu/bits/mathcalls.h:196:1: error: ‘__END_NAMESPACE_STD’ does not name a type
_Mdouble_END_NAMESPACE
^
In file included from /usr/local/include/opencv2/core/types_c.h:94:0,
from /usr/local/include/opencv2/core/core_c.h:47,
from /usr/local/include/opencv/cv.h:63,
from /home/appuru/desktop/test/build/include/demo.h:4,

[...]

/usr/include/stdio.h:46:1: error: ‘__BEGIN_NAMESPACE_STD’ does not name a type
__BEGIN_NAMESPACE_STD
^
/usr/include/stdio.h:49:1: error: ‘__END_NAMESPACE_STD’ does not name a type
__END_NAMESPACE_STD

[..]

/usr/include/stdio.h:237:20: error: ‘FILE’ was not declared in this scope
extern int fclose (FILE *__stream);
^
/usr/include/stdio.h:237:26: error: ‘__stream’ was not declared in this scope
extern int fclose (FILE *__stream);
[...]

等等……

大多数(如果不是全部)错误似乎来自通过“cv.h”(包含在我的头文件中)对标准 C++ 库的调用。

我已经用谷歌搜索了一段时间,尝试了几乎所有似乎与我的问题相关的东西,但没有任何解决办法。

我错过了什么?我是 Linux 的新手,这就是为什么我不太确定我还需要研究什么的原因。我是否缺少某些包或我需要指定额外的东西吗?

/编辑:

这是 cmake 调用:

appuru@appuru-VirtualBox ~/desktop/test/build $ cmake ..
jsoncpp_FOUND = 1
jsoncpp_INCLUDES = /usr/local/include/json
jsoncpp_LIBRARIES = /usr/local/lib/libjsoncpp.a
OpenCV_LIBS = opencv_videostab;opencv_video;opencv_ts;opencv_superres;opencv_stitching;opencv_photo;opencv_ocl;opencv_objdetect;opencv_nonfree;opencv_ml;opencv_legacy;opencv_imgproc;opencv_highgui;opencv_gpu;opencv_flann;opencv_features2d;opencv_core;opencv_contrib;opencv_calib3d
OpenCV_INCLUDE_DIRS = /usr/local/include/opencv;/usr/local/include
-- Configuring done
-- Generating done
-- Build files have been written to: /home/appuru/desktop/test/build

/编辑2:

详细:

appuru@appuru-VirtualBox ~/desktop/test/build $ make VERBOSE=1
/usr/bin/cmake -H/home/appuru/desktop/test -B/home/appuru/desktop/test/build --check-build-system CMakeFiles/Makefile.cmake 0
/usr/bin/cmake -E cmake_progress_start /home/appuru/desktop/test/build/CMakeFiles /home/appuru/desktop/test/build/CMakeFiles/progress.marks
make -f CMakeFiles/Makefile2 all
make[1]: Entering directory »/home/appuru/desktop/test/build«
make -f CMakeFiles/test.dir/build.make CMakeFiles/test.dir/depend
make[2]: Entering directory »/home/appuru/desktop/test/build«
cd /home/appuru/desktop/test/build && /usr/bin/cmake -E cmake_depends "Unix Makefiles" /home/appuru/desktop/test /home/appuru/desktop/test /home/appuru/desktop/test/build /home/appuru/desktop/test/build /home/appuru/desktop/test/build/CMakeFiles/test.dir/DependInfo.cmake --color=
make[2]: Quitting directory »/home/appuru/desktop/test/build«
make -f CMakeFiles/test.dir/build.make CMakeFiles/test.dir/build
make[2]: Entering directory »/home/appuru/desktop/test/build«
/usr/bin/cmake -E cmake_progress_report /home/appuru/desktop/test/build/CMakeFiles 1
[ 11%] Building CXX object CMakeFiles/test.dir/src/testDetector.cpp.o
/usr/bin/c++ -O3 -DNDEBUG -I/home/appuru/desktop/test/build/include -I/home/appuru/desktop/test/include -I/usr/local/include/opencv -I/usr/local/include -I/usr/local/include/json -o CMakeFiles/test.dir/src/testDetector.cpp.o -c /home/appuru/desktop/test/src/testDetector.cpp

之后就和我之前发的一样了..?

CMakeLists.txt:

    CMAKE_MINIMUM_REQUIRED (VERSION 2.8)



PROJECT (test)


SET (LIBRARY_OUTPUT_PATH "${PROJECT_BINARY_DIR}/lib")
SET (EXECUTABLE_OUTPUT_PATH "${PROJECT_BINARY_DIR}/bin")


# The version number
SET (test_VERSION_MAJOR 1)
SET (test_VERSION_MINOR 0)
SET (DEBUG false)


# configure a header file to pass some of the CMake settings to the source code
CONFIGURE_FILE (
"${PROJECT_SOURCE_DIR}/include/testConfig.h.in"
"${PROJECT_BINARY_DIR}/include/testConfig.h"
)


FILE(GLOB INCLUDES "${PROJECT_SOURCE_DIR}/include/*.h")
INCLUDE_DIRECTORIES ("${PROJECT_BINARY_DIR}/include")
INCLUDE_DIRECTORIES ("${PROJECT_SOURCE_DIR}/include")


SET (CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${PROJECT_SOURCE_DIR}/cmake")
FIND_PACKAGE (OpenCV REQUIRED)
FIND_PACKAGE (jsoncpp REQUIRED)


INCLUDE_DIRECTORIES ("${OpenCV_INCLUDE_DIRS}")
INCLUDE_DIRECTORIES ("${jsoncpp_INCLUDES}")


FILE (GLOB SOURCES "${PROJECT_SOURCE_DIR}/src/*.c*")
SET (SOURCES ${SOURCES})


SET (CMAKE_BUILD_TYPE Release)
ADD_LIBRARY (test STATIC ${SOURCES} ${INCLUDES})
FILE(COPY ${INCLUDES} DESTINATION "${PROJECT_BINARY_DIR}/include")

TARGET_LINK_LIBRARIES (test ${OpenCV_LIBS})
MESSAGE ("OpenCV_LIBS = ${OpenCV_LIBS}")
MESSAGE ("OpenCV_INCLUDE_DIRS = ${OpenCV_INCLUDE_DIRS}")
TARGET_LINK_LIBRARIES (test ${jsoncpp_LIBS})

INSTALL (TARGETS test ARCHIVE DESTINATION lib LIBRARY DESTINATION lib COMPONENT library)
INSTALL (FILES ${INCLUDES} DESTINATION include/test)


#PROJECT (testDemo)

FILE (GLOB MARKERC_SRC "${PROJECT_SOURCE_DIR}/tools/testDemo.cpp")
SET (MARKER_SRC ${MARKERC_SRC})
ADD_EXECUTABLE (testDemo ${MARKER_SRC})
TARGET_LINK_LIBRARIES (testDemo ${OpenCV_LIBS})
TARGET_LINK_LIBRARIES (testDemo ${jsoncpp_LIBS})
TARGET_LINK_LIBRARIES (testDemo ${LIBRARY_OUTPUT_PATH}/libtest.a)

最佳答案

再设置 linux 2 次后,在构建项目的不同阶段仍然出现相同的错误,我找到了原因。

jsoncpp 使用名为 features.h 的 header ,而标准 C++ 库也包含另一个 features.h。

无论出于何种原因,它对其他人都有效,但让我的计算机在构建库时选择了错误的头文件。我之前已经搜索过这个错误,发现它已被 jsoncpp 人员修复,但猜测不是所有可能的设置。

我现在使用 jsoncpp 的合并版本,不再将其与 cmake 链接。

关于c++ - 在 Linux Mint 17.1 64 位(未声明/不是类型)上尝试 "make"C++ 项目时从 cstdlib 编译错误和类似错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29345640/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com