×ðÁú¿­Ê±¹ÙÍøµÇ¼

ʹÓÃCross CompilingÔÚWindowsÉϾÙÐÐLinux³ÌÐò¿ª·¢µÄÉèÖü¼ÇÉ

ʹÓÃcross compilingÔÚwindowsÉϾÙÐÐlinux³ÌÐò¿ª·¢µÄÉèÖü¼ÇÉ

¸ÅÊö£º

Ëæ×ÅLinux²Ù×÷ϵͳµÄÆÕ±éÓ¦Óà £¬Ðí¶à¿ª·¢Õ߶¼Ï£ÍûÄÜÔÚWindowsÉϾÙÐÐLinux³ÌÐòµÄ¿ª·¢¡£¶øʹÓÃCross CompilingÊÖÒÕ¾ÍÄÜʵÏÖÕâһĿµÄ £¬Ëü¿ÉÒÔÈÃÎÒÃÇÔÚWindowsÇéÐÎÏ¿ª·¢Linux³ÌÐò £¬´ó´óÌá¸ßÁË¿ª·¢Ð§ÂÊ¡£±¾ÎĽ«ÏÈÈÝÔÚWindowsÉÏÉèÖÃCross CompilingÇéÐεļ¼ÇÉ £¬²¢¸½´ø´úÂëʾÀý £¬×ÊÖú¿ª·¢ÕßÇáËɵؾÙÐÐLinux³ÌÐò¿ª·¢¡£

ÉèÖÃCross CompilingÇéÐεÄ×¼±¸£º

Ê×ÏÈ £¬ÎÒÃÇÐèҪ׼±¸Ò»Ð©¹¤¾ßºÍ¿âÎļþ £¬ÒÔÈ·±£Äܹ»ÔÚWindowsÉϾÙÐÐLinux³ÌÐòµÄ±àÒëºÍµ÷ÊÔ¡£ÒÔÏÂÊÇһЩÐëÒªµÄ×¼±¸ÊÂÇ飺

×°Öý»Ö¯±àÒ빤¾ßÁ´£ºÎÒÃÇÐèÒª´Ó¹Ù·½ÍøÕ¾ÏÂÔز¢×°Öý»Ö¯±àÒ빤¾ßÁ´ £¬¸Ã¹¤¾ßÁ´°üÀ¨ÁËLinux²Ù×÷ϵͳËùÐèµÄ±àÒëÆ÷ºÍ¿âÎļþ¡£

ÉèÖÃÇéÐαäÁ¿£ºÎÒÃÇÐèÒª½«½»Ö¯±àÒ빤¾ßÁ´µÄ·¾¶Ìí¼Óµ½ÏµÍ³µÄÇéÐαäÁ¿ÖÐ £¬ÒÔ±ãÔÚʹÓÃÏÂÁîÐбàÒë³ÌÐòʱÄܹ»ÕÒµ½ÐèÒªµÄ¹¤¾ß¡£

ÉèÖõ÷ÊÔÆ÷£ºÔÚWindowsÉϵ÷ÊÔLinux³ÌÐòʱ £¬ÎÒÃÇÐèÒªÉèÖÃÒ»¸öÊÊÓÃÓÚLinuxµÄµ÷ÊÔÆ÷ £¬ÒÔ±ãÄܹ»×¼È·µØ¼ì²éºÍÐÞ¸´³ÌÐòÖеĹýʧ¡£

ÉèÖÃCross CompilingÇéÐεİ취£º

Ò»µ©×¼±¸ÊÂÇéÍê³É £¬ÎÒÃÇ¿ÉÒÔƾ֤ÒÔÏ°취À´ÉèÖÃCross CompilingÇéÐΣº

½¨ÉèÒ»¸ö¿ÕµÄÊÂÇéĿ¼£ºÎÒÃÇ¿ÉÒÔÔÚWindowsÉϽ¨ÉèÒ»¸ö¿ÕµÄÊÂÇéĿ¼ £¬ÓÃÓÚ´æ·ÅÎÒÃǵĴúÂëºÍ±àÒëЧ¹û¡£

±àдMakefileÎļþ£ºMakefileÎļþÓÃÓÚ±àÒëºÍÁ´½Ó³ÌÐò £¬ÎÒÃÇÐèҪƾ֤ÏîÄ¿µÄÐèÇóÀ´±àдһ¸öÊʺϵÄMakefileÎļþ¡£

ÒÔÏÂÊÇÒ»¸ö¼òÆÓµÄMakefileÎļþʾÀý£º

CC = arm-linux-gnueabihf-gcc
CFLAGS = -Wall -O2

.PHONY: all clean

all: my_program

my_program: main.o utils.o
    $(CC) $(CFLAGS) $^ -o $@

main.o: main.c
    $(CC) $(CFLAGS) -c $^ -o $@

utils.o: utils.c
    $(CC) $(CFLAGS) -c $^ -o $@

clean:
    rm -f *.o my_program

µÇ¼ºó¸´ÖÆ

ÔÚÕâ¸öʾÀýÖÐ £¬ÎÒÃÇʹÓÃarm-linux-gnueabihf-gcc×÷Ϊ½»Ö¯±àÒ빤¾ßÁ´µÄ±àÒëÆ÷ £¬Ö¸¶¨Á˱àÒëÑ¡Ïî-WallºÍ-O2¡£ÎÒÃÇͨ¹ý½ç˵all¡¢cleanµÈαĿµÄÀ´ÖÎÀí±àÒëºÍÕûÀíÊÂÇ顣ͬʱ £¬ÎÒÃÇÐèÒª±àдmain.cºÍutils.cÎļþÀ´Íê³É³ÌÐòµÄ¹¦Ð§ÊµÏÖ¡£

±àÒë³ÌÐò£ºÔÚÏÂÁîÌáÐÑ·ûϽøÈëµ½ÊÂÇéĿ¼²¢Ö´ÐÐmakeÏÂÁî £¬¼´¿É×Ô¶¯±àÒë³ÌÐò¡£±àÒëÍê³Éºó £¬ÎÒÃǾͿÉÒÔ»ñµÃ¿ÉÔÚLinuxÉÏÔËÐеĿÉÖ´ÐÐÎļþÁË¡£

µ÷ÊÔCross CompilingÇéÐεÄÉèÖãº

Ò»µ©³ÌÐò±àÒëÍê³É £¬ÎÒÃǾͿÉÒÔÔÚLinuxÇéÐÎÖÐÔËÐк͵÷ÊÔËü¡£ÒÔÏÂÊÇһЩ½¨ÒéµÄÉèÖð취£º

ÉèÖÃsshЧÀÍÆ÷£ºÎÒÃÇ¿ÉÒÔÔÚLinuxÉÏÉèÖÃÒ»¸össhЧÀÍÆ÷ £¬ÕâÑùÎÒÃǾͿÉÒÔͨ¹ýÍøÂçÅþÁ¬µ½Linuxϵͳ £¬Àû±ãµØ¶Ô³ÌÐò¾ÙÐе÷ÊÔ¡£

ÉèÖÃGDBµ÷ÊÔÆ÷£ºÎÒÃÇÐèÒªÔÚWindowsÉÏ×°ÖÃÒ»¸öÊÊÓÃÓÚLinuxµÄGDBµ÷ÊÔÆ÷ £¬ÒÔ±ãÄܹ»ÅþÁ¬µ½Linuxϵͳ £¬¼ì²é³ÌÐòµÄÔËÐÐ״̬ºÍÐÞ¸´¹ýʧ¡£

µ÷ÊÔ³ÌÐò£ºÉèÖúÃsshЧÀÍÆ÷ºÍGDBµ÷ÊÔÆ÷ºó £¬ÎÒÃǾͿÉÒÔͨ¹ýGDBÏÂÁîÀ´ÅþÁ¬µ½Linuxϵͳ £¬²¢¶Ô³ÌÐò¾ÙÐе÷ÊÔ¡£Ê¹ÓÃGDBµÄÖÖÖÖÏÂÁî £¬ÎÒÃÇ¿ÉÒÔÉó²é±äÁ¿µÄÖµ¡¢ÉèÖöϵãÒÔ¼°µ¥³ÌÐòÊÔ³ÌÐòµÈ¡£

´úÂëʾÀý£º

ΪÁ˸üºÃµØ˵Ã÷Cross CompilingÇéÐεÄÉèÖÃÒªÁì £¬ÎÒÃÇÌṩһ¸ö¼òÆӵĴúÂëʾÀý¡£ÒÔÏÂÊÇÒ»¸ö¼òÆÓµÄHello World³ÌÐòµÄMakefileÎļþʾÀý£º

CC = arm-linux-gnueabihf-gcc
CFLAGS = -Wall -O2

.PHONY: all clean

all: hello_world

hello_world: hello_world.c
    $(CC) $(CFLAGS) $^ -o $@

clean:
    rm -f hello_world

µÇ¼ºó¸´ÖÆ

È»ºóÎÒÃÇÔÚͳһĿ¼Ï½¨ÉèÒ»¸öhello_world.cÎļþ £¬Ð´ÈëÒÔÏ´úÂ룺

#include <stdio.h>

int main(void) {
    printf("Hello, World!
");
    return 0;
}

µÇ¼ºó¸´ÖÆ

½ÓÏÂÀ´ £¬ÔÚÏÂÁîÌáÐÑ·ûϽøÈëµ½¸ÃĿ¼ £¬²¢Ö´ÐÐmakeÏÂÁî¡£ÀֳɱàÒëºó £¬ÎÒÃÇ»áÔÚͳһĿ¼Ï»ñµÃÒ»¸öÃûΪhello_worldµÄ¿ÉÖ´ÐÐÎļþ¡£½«¸Ã¿ÉÖ´ÐÐÎļþ´«Ë͵½Linuxϵͳ £¬²¢ÔÚLinuxϵͳÉÏÖ´ÐÐ £¬¼´¿É¿´µ½Êä³öЧ¹û£º¡°Hello, World!¡±

½áÂÛ£º

±¾ÎÄÏÈÈÝÁËÔÚWindowsÉÏÉèÖÃCross CompilingÇéÐεļ¼ÇÉ £¬²¢¸½´øÁË´úÂëʾÀý £¬×ÊÖú¿ª·¢ÕßÇáËɵؾÙÐÐLinux³ÌÐò¿ª·¢¡£Í¨¹ýÕâÖÖÉèÖ÷½·¨ £¬ÎÒÃÇÄܹ»ÔÚWindowsÉϱàдºÍµ÷ÊÔLinux³ÌÐò £¬´ó´óÌá¸ßÁË¿ª·¢Ð§ÂÊ¡£Ï£Íû±¾ÎĶԳõѧÕßÓÐËù×ÊÖú £¬²¢ÄÜÔö½ø¸ü¶àÈ˼ÓÈëµ½Linux³ÌÐò¿ª·¢ÖÐÀ´¡£

ÒÔÉϾÍÊÇʹÓÃCross CompilingÔÚWindowsÉϾÙÐÐLinux³ÌÐò¿ª·¢µÄÉèÖü¼ÇɵÄÏêϸÄÚÈÝ £¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡

ÃâÔð˵Ã÷£ºÒÔÉÏչʾÄÚÈÝȪԴÓÚÏàÖúýÌå¡¢ÆóÒµ»ú¹¹¡¢ÍøÓÑÌṩ»òÍøÂçÍøÂçÕûÀí £¬°æȨÕùÒéÓë±¾Õ¾ÎÞ¹Ø £¬ÎÄÕÂÉæ¼°¿´·¨Óë¿´·¨²»´ú±í×ðÁú¿­Ê±¹ÙÍøµÇ¼ÂËÓÍ»úÍø¹Ù·½Ì¬¶È £¬Çë¶ÁÕß½ö×ö²Î¿¼¡£±¾ÎĽӴýתÔØ £¬×ªÔØÇë˵Ã÷À´ÓÉ¡£ÈôÄúÒÔΪ±¾ÎÄÇÖÕ¼ÁËÄúµÄ°æȨÐÅÏ¢ £¬»òÄú·¢Ã÷¸ÃÄÚÈÝÓÐÈκÎÉæ¼°ÓÐÎ¥¹«µÂ¡¢Ã°·¸Ö´·¨µÈÎ¥·¨ÐÅÏ¢ £¬ÇëÄúÁ¬Ã¦ÁªÏµ×ðÁú¿­Ê±¹ÙÍøµÇ¼ʵʱÐÞÕý»òɾ³ý¡£

Ïà¹ØÐÂÎÅ

ÁªÏµ×ðÁú¿­Ê±¹ÙÍøµÇ¼

18523999891

¿É΢ÐÅÔÚÏß×Éѯ

ÊÂÇéʱ¼ä£ºÖÜÒ»ÖÁÖÜÎå £¬9:30-18:30 £¬½ÚãåÈÕÐÝÏ¢

QR code
ÍøÕ¾µØͼ