![](/img/trans.png)
[英]Cross-Compile of Boost for GCC ARM (Linux) from Windows building .o but not .a
[英]Building gcc plugin for windows on linux
尝试使用 mingw 交叉编译器在 linux 上为 windows 构建以下 gcc 插件。 这些插件来自同样适用于 Windows 的内置 avr 编译器。 改编了以下插件https://github.com/jcmvbkbc/avr-flash-vtbl 。
#include <gcc-plugin.h>
#include <cp/cp-tree.h>
#ifdef _WIN32
__declspec(dllexport)
#endif
int plugin_is_GPL_compatible = 1;
void fn(void *gcc_data, void *user_data)
{
TYPE_ADDR_SPACE (TREE_TYPE (vtbl_type_node)) = 1;
TYPE_ADDR_SPACE (TREE_TYPE (vtbl_ptr_type_node)) = 1;
}
#ifdef _WIN32
__declspec(dllexport)
#endif
int plugin_init (struct plugin_name_args *plugin_info,
struct plugin_gcc_version *version)
{
register_callback("", PLUGIN_START_UNIT, fn, NULL);
return 0;
}
编译和链接期间的输出:
i686-w64-mingw32-g++ -shared -I/home/andreas/omgwtfbbq/win64/bin/../lib/gcc/avr/9.2.0/plugin/include -Wl,--export-all-symbols /home/andreas/
omgwtfbbq/win64/bin/../lib/gcc/avr/9.2.0/plugin/cc1plus.exe.a avr-flash-vtbl.c -o avr-flash-vtbl.so -I./
/usr/bin/i686-w64-mingw32-ld: /tmp/cc28ZVde.o:avr-flash-vtbl.c:(.text+0x4): undefined reference to `cp_global_trees'
/usr/bin/i686-w64-mingw32-ld: /tmp/cc28ZVde.o:avr-flash-vtbl.c:(.text+0x10): undefined reference to `cp_global_trees'
/usr/bin/i686-w64-mingw32-ld: /tmp/cc28ZVde.o:avr-flash-vtbl.c:(.text+0x44): undefined reference to `register_callback'
collect2: error: ld returned 1 exit status
make: *** [Makefile:11: avr-flash-vtbl.so] Fehler 1
编译器标志改编自https://gcc.gnu.org/onlinedocs/gccint/Plugins-building.html 。 有没有人遇到过这样的问题?
问题解决了。 将主机编译器从 i686-w64-mingw32-g++ 更改为 x86_64-w64-mingw32-g++ 并更改了选项的顺序。 /home/andreas/omgwtfbbq/win64/bin/../lib/gcc/avr/9.2.0/plugin/cc1plus.exe.a 必须在 avr-flash-vtbl.c 之后。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.