1626 views|0 replies

253

Posts

0

Resources
The OP
 

How to write arm-poky mixed Makefile [Copy link]

The cross-compilation tool uses ARM-poky-linux-gnueabi-g++ and arm-poky-linux-gnueabi-gcc for mixed compilation
1. Create new main.c Makefile myinclude.h test.cpp
vim main.c
//filename main.c
#include <stdlib.h>
#include <stdio.h>

#include "myinclude.h"

int main()
{
test_fun();
return 0;
}

vim test.cpp
//filename test.cpp
#include <iostream>

#include " myinclude.h"

void test_fun()
{
std::cout<<"hello, this is a c++ test"<<std::endl;
}

vim myinclude.h
//filename myinclude.h
#ifndef MYINCLUDE_H
#define MYINCLUDE_H

#ifdef __cplusplus
extern "C"{ //When using g++ to compile, this will be recognized by the compiler, and when using gcc to compile, it will be skipped, so that this public header file generates different codes for different compilers
#endif

void test_fun();

#ifdef __cplusplus
}
# endif

#endif //MYINCLUDE_H

vim Makefile
SRCFILES := test.cpp myinclude.h main.c
OBJFILES := test.o main.o
TARGET=my_cpp

$(TARGET)(OBJFILES)
$(CXX) $(OBJFILES) -o $ @
$(OBJFILES)(SRCFILES)
$(CXX) test.cpp -c\
$(CC ) main.c -c

.PHONY:
clean:.PHONY
rm -rf $(OBJFILES) $(TARGET)

2. Set up cross compilation Tools
A9 series cross-compilation tool settings
source /opt/fsl-imx-fb-glibc-x86_64-meta-toolchain-qt5-cortexa9hf-neon-toolchain-4.1.15-2.1.0/environment-setup-cortexa9hf-neon-poky-linux-gnueabi
A7 series cross compilation Tool settings
source /home/myzr/my-work/03_toolchain/fsl-imx-x11-glibc-x86_64-meta-toolchain-qt5-cortexa7hf-neon-toolchain-4.1.15-2.1.0/environment-setup-cortexa7hf- neon-poky-linux-gnueabi
Note: Just set the cross-compilation tool according to the CPU model.
After setting, CC and CXX are set by default.
echo $CC
echo $CXX
3. Compile
make

图1.jpg (59.87 KB, downloads: 0)

图1.jpg

图2.jpg (79.69 KB, downloads: 0)

图2.jpg

图3.jpg (77.83 KB, downloads: 0)

图3.jpg
This post is from Linux and Android

Find a datasheet?

EEWorld Datasheet Technical Support

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京B2-20211791 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号
快速回复 返回顶部 Return list