我有一个我最初在 linux 中编写的程序,它使用 objcopy 在可执行文件中嵌入一些图像以在运行时使用。我在linux中对此完全没有问题,并且运行良好。
但是,当我尝试交叉编译 Windows 程序时,我在链接阶段得到一个未定义引用的列表,这表明 objcopy 失败了。有人可以指出我正确的方向以使其正确交叉编译。我知道这不是代码问题,因为代码是可移植的。
用于与 objcopy 交叉编译的命令
i586-mingw32msvc-objcopy --input binary --output=pe-i386 --binary-architecture i386 images/HD44780.bmp HD44780_bmp.o
链接阶段产生的错误
HDxx780.o:HDxx780.cpp:(.text+0xbe2): undefined reference to `__binary_images_HD44780_bmp_end'
HDxx780.o:HDxx780.cpp:(.text+0xbef): undefined reference to `__binary_images_HD44780_bmp_start'
HDxx780.o:HDxx780.cpp:(.text+0xc04): undefined reference to `__binary_images_HD44780_bmp_start'
我在代码中访问数据的宏
extern char _binary_images_HD44780_bmp_start, _binary_images_HD44780_bmp_end;
#define HD44780_DATA ((void *) &_binary_images_HD44780_bmp_start)
#define HD44780_SIZE ((size_t) (&_binary_images_HD44780_bmp_end - &_binary_images_HD44780_bmp_start))
i586-mingw32-objcopy 支持的格式
me@mypc:~/ > i586-mingw32msvc-objcopy --info
BFD header file version (GNU Binutils) 2.20
pe-i386
(header little endian, data little endian)
i386
pei-i386
(header little endian, data little endian)
i386
elf32-i386
(header little endian, data little endian)
i386
elf32-little
(header little endian, data little endian)
i386
elf32-big
(header big endian, data big endian)
i386
srec
(header endianness unknown, data endianness unknown)
i386
symbolsrec
(header endianness unknown, data endianness unknown)
i386
verilog
(header endianness unknown, data endianness unknown)
i386
tekhex
(header endianness unknown, data endianness unknown)
i386
binary
(header endianness unknown, data endianness unknown)
i386
ihex
(header endianness unknown, data endianness unknown)
i386
pe-i386 pei-i386 elf32-i386 elf32-little elf32-big srec
i386 pe-i386 pei-i386 elf32-i386 elf32-little elf32-big srec
symbolsrec verilog tekhex binary ihex
i386 symbolsrec verilog tekhex binary ihex
我正在尝试编译到 Windows (x86)。我编译的机器是Linux(x86)。