我正尝试使用https://medium.com/@sourabhjigjinni/install-opencv-4-0-0-for-c-windows-7-10-code-blocks-tdm-gcc-64-dff65addf162此处提供的步骤为代码块安装OpenCV。
在构建过程中,进入第四步之后,我遇到了一个错误,而CodeBlock正在构建alloc.cpp文件
谷歌搜索问题,我发现一个不起作用的解决方案:将#include stdlib.h移到#include malloc.h之前
// Copyright (C) 2018 Intel Corporation
//
//
// SPDX-License-Identifier: Apache-2.0
//
#include "ade/memory/alloc.hpp"
#if defined(_WIN32) || defined(__ANDROID__) || defined(ANDROID)
#include <malloc.h>
#else
#include <algorithm>
#include <stdlib.h>
#endif
#include "ade/util/math.hpp"
#include "ade/util/assert.hpp"
namespace ade
{
void* aligned_alloc(std::size_t size, std::size_t alignment)
{
ADE_ASSERT(util::is_pow2(alignment));
#if defined(_WIN32)
return _aligned_malloc(size, alignment);
#elif defined(__ANDROID__) || defined(ANDROID)
return memalign(alignment, size);
#else
void* ret = nullptr;
auto res = posix_memalign(&ret, std::max(sizeof(void*), alignment), size);
(void)res;
return ret;
#endif
}
void aligned_free(void* ptr)
{
#if defined(_WIN32)
return _aligned_free(ptr);
#else
return free(ptr);
#endif
}
}
出现以下错误:
||=== Build: install in OpenCV (compiler: GNU GCC Compiler) ===|
C:\opencv\build\3rdparty\ade\ade-0.1.1d\sources\ade\source\alloc.cpp||In function 'void* ade::aligned_alloc(std::size_t, std::size_t)':|
C:\opencv\build\3rdparty\ade\ade-0.1.1d\sources\ade\source\alloc.cpp|26|error: '_aligned_malloc' was not declared in this scope|
C:\opencv\build\3rdparty\ade\ade-0.1.1d\sources\ade\source\alloc.cpp||In function 'void ade::aligned_free(void*)':|
C:\opencv\build\3rdparty\ade\ade-0.1.1d\sources\ade\source\alloc.cpp|40|error: '_aligned_free' was not declared in this scope|
C:\opencv\build\3rdparty\ade\ade-0.1.1d\sources\ade\source\alloc.cpp|40|error: return-statement with a value, in function returning 'void' [-fpermissive]|
modules\CMakeFiles\ade.dir\build.make|62|recipe for target 'modules/CMakeFiles/ade.dir/__/3rdparty/ade/ade-0.1.1d/sources/ade/source/alloc.cpp.obj' failed|
CMakeFiles\Makefile2|822|recipe for target 'modules/CMakeFiles/ade.dir/all' failed|
C:\opencv\build\Makefile|161|recipe for target 'all' failed|
||=== Build failed: 6 error(s), 0 warning(s) (0 minute(s), 7 second(s)) ===|