简体   繁体   English

从Windows到Linux的交叉编译源代码

[英]Cross compiling source from windows to linux

This is my make file 这是我的make文件

EXE     = signsrch
CFLAGS  += -s -O2
PREFIX  = /usr/local
BINDIR  = $(PREFIX)/bin
SRC     = $(EXE).c

all:
    $(CC) $(CFLAGS) -c disasm.c
    $(CC) $(CFLAGS) -c asmserv.c
    $(CC) $(SRC) $(CFLAGS) -o $(EXE) *.o

install:
    install -m 755 -d $(BINDIR)
    install -m 755 $(EXE) $(BINDIR)/$(EXE)

.PHONY:
    install

I want to cross compile it for my ubuntu and I tried: 我想为我的ubuntu交叉编译它,我试过:

make ARCH=arm CROSS_COMPILE=arm-none-linux-gnueabi-

but I get unknown type name errors with a bunch of âDWORDâ 但是我用一堆'DWORD'得到了未知的类型名称错误

Help? 救命?

to cross compile you need a toolchain for the target platform, not just a Makefile. 要交叉编译,你需要一个目标平台的工具链,而不仅仅是一个Makefile。 Check this tutorial and also Cygwin 查看本教程以及Cygwin

We also need to see some code, but.... 我们还需要看一些代码,但....

Windows has its own types for basic things above the vanilla C ones, as does Linux. Windows拥有自己的基本类型,类似于vanilla C,Linux也是如此。 It sounds like DWORD as a type is not known in Linux (likely). 它听起来像DWORD,因为Linux中可能不知道类型(可能)。 You'll probably have to create a mytypes.h file that redefines Windows standards like DWORD into Linux speak when building for a Linux platform. 您可能必须创建一个mytypes.h文件,在构建Linux平台时,将DWORD等Windows标准重新定义为Linux。 Linux has types.h that defines things like int32_t which is the equivalent. Linux有types.h定义类似int32_t的东西。 See this thread for more about this. 有关详细信息,请参阅此主题

I've assumed you have a working cross compiler set up and you're fighting just with the port. 我假设你有一个有效的交叉编译器设置,你只是在与端口战斗。 If you haven't, that's your first job. 如果你还没有,这是你的第一份工作。 You could have a windows based compiler that targets Linux (the cygwin option, mentioned in another post) or go for a Linux based compiler and targetting windows (crosstool will help here). 您可以使用基于Windows的编译器来定位Linux(cygwin选项,在另一篇文章中提到)或者使用基于Linux的编译器和目标窗口(crosstool将在这里提供帮助)。 Though since you seem to be targetting arm, I'm expecting that that Ubuntu install isn't the place you wish to build! 虽然你似乎是瞄准手臂,但我期待Ubuntu安装不是你想要建造的地方! :-) :-)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM