![](/img/trans.png)
[英]How to install a Library for C++ like Eigen and sharkML at vs code?
[英]How to install Eigen library to IAR c/c++ compiler
是否可以將 Eigen(用於線性代數的 C++ 模板庫)移植到用於 ARM 的 IAR 工作台。 我曾嘗試這樣做,但出現以下編譯錯誤
Error[Pe337]: linkage specification is incompatible with previous "__nounwind __iar_builtin_get_CONTROL" (declared at line 58 of "C:\Program Files (x86)\IAR Systems\Embedded Workbench 8.3\arm\inc\c\iccarm_builtin.h") C:\Program Files (x86)\IAR Systems\Embedded Workbench 8.3\arm\CMSIS\Core\Include\cmsis_gcc.h 151
這是我使用預處理器時遇到的全部錯誤
__GNUC__
__arm__
如果我不使用這些預處理器,我會從 Eigen 文件 Macros.h 的 #error 預處理器中得到一個錯誤
“錯誤請告訴我你的編譯器的屬性((aligned(n))) 的等價物是什么”
#if (defined __CUDACC__)
#define EIGEN_ALIGN_TO_BOUNDARY(n) __align__(n)
#elif EIGEN_COMP_GNUC || EIGEN_COMP_PGI || EIGEN_COMP_IBM || EIGEN_COMP_ARM
#define EIGEN_ALIGN_TO_BOUNDARY(n) __attribute__((aligned(n)))
#elif EIGEN_COMP_MSVC
#define EIGEN_ALIGN_TO_BOUNDARY(n) __declspec(align(n))
#elif EIGEN_COMP_SUNCC
// FIXME not sure about this one:
#define EIGEN_ALIGN_TO_BOUNDARY(n) __attribute__((aligned(n)))
#else
//#define EIGEN_ALIGN_TO_BOUNDARY(n) __declspec(align(n))
#error Please tell me what is the equivalent of __attribute__((aligned(n))) for your compiler
#endif
我讓它適用於視覺 c++ 但不適用於 IAR。 添加所有包含。
這些錯誤會根據我用來嘗試配置 Eigen 的預處理器而變化。 是否可以將 Eigen 與 IAR 一起使用?
要添加到@chtz 答案,以下是我如何讓 EIGEN_ALIGN_TO_BOUNDARY 宏與 IAR 一起使用,其方式與 eigen 庫一致:
1:將此添加到 Macros.h 頂部以識別 IAR ARM 編譯器
/// \internal EIGEN_COMP_ICCARM set to 1 if the compiler is IAR eWARM
#if defined(__ICCARM__)
#define EIGEN_COMP_ICCARM 1
#else
#define EIGEN_COMP_ICCARM 0
#endif
2:將此案例添加到在 Macros.h 中定義 EIGEN_ALIGN_TO_BOUNDARY(n) 的位置
#elif EIGEN_COMP_ICCARM
#define IAR_STRINGIFY(a) #a
#define IAR_ALIGN_STR(n) IAR_STRINGIFY(data_alignment=n)
#define EIGEN_ALIGN_TO_BOUNDARY(n) _Pragma(IAR_ALIGN_STR(n))
EIGEN_ALIGN_TO_BOUNDARY(n) 現在應該正確擴展為 _Pragma("data_alignment=n")
我現在已經可以構建和運行它了。 感謝@chtz 的 EIGEN_DONT_ALIGN 宏建議。 我就是這樣做的。 但是,我不確定這對庫本身有什么影響,例如這可能會帶走哪些功能。 我這樣做了:
這適用於 Eigen 3.3.7
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.