IT数码 购物 网址 头条 软件 日历 阅读 图书馆
TxT小说阅读器
↓语音阅读,小说下载,古典文学↓
图片批量下载器
↓批量下载图片,美女图库↓
图片自动播放器
↓图片自动播放器↓
一键清除垃圾
↓轻轻一点,清除系统垃圾↓
开发: C++知识库 Java知识库 JavaScript Python PHP知识库 人工智能 区块链 大数据 移动开发 嵌入式 开发工具 数据结构与算法 开发测试 游戏开发 网络协议 系统运维
教程: HTML教程 CSS教程 JavaScript教程 Go语言教程 JQuery教程 VUE教程 VUE3教程 Bootstrap教程 SQL数据库教程 C语言教程 C++教程 Java教程 Python教程 Python3教程 C#教程
数码: 电脑 笔记本 显卡 显示器 固态硬盘 硬盘 耳机 手机 iphone vivo oppo 小米 华为 单反 装机 图拉丁
 
   -> 游戏开发 -> Adding Fortran support to a Yocto build -> 正文阅读

[游戏开发]Adding Fortran support to a Yocto build

Jumpnow Technologies

home

Adding Fortran support to a Yocto build

Adding Fortran support to a Yocto build

02 Apr 2014

Being asked to add support for Fortran is a rare thing. I am not a Fortran developer.

Here are some notes while it’s still fresh.

This is was done using tools from the Yocto Project version 1.5.1, the [dora] branch.

Build

local.conf

Add the following line to your build/conf/local.conf

# Enable fortran
FORTRAN_forcevariable = ",fortran"

gcc-runtime.bbappend

Add this one-liner bbappend to the gcc-runtime recipe

scott@octo:~/<project>$ cat meta-<project>/recipes-devtools/gcc/gcc-runtime_4.8.bbappend
RUNTIMETARGET += "libgfortran"

Add packages

Add these to your image recipe

...
FORTRAN_TOOLS = " \
    gfortran \
    gfortran-symlinks \
    libgfortran \
    libgfortran-dev \
 "
...
IMAGE_INSTALL += " \
    ...
    ${FORTRAN_TOOLS} \
    ...
 "
 ...

You should do this before building the first time or you’ll just have to wait for it a second time. The gcc-runtime modification will force a recompile of gcc leading to a rebuild of almost everything else.

Testing

I grabbed some Fortran test code from the WikiBooks Fortran/Fortran examples page.

I’m using the Summations with a DO loop example.

Native compile and run

Copy the example code to the target board (I’m using a Gumstix Overo) and compile it with this command

root@overo:~# ls
sum.f90
root@overo:~# gfortran -o fsum sum.f90
root@overo:~# ls
fsum  sum.f90

Here’s a run

root@overo:~# ./fsum
 This program performs summations. Enter 0 to stop.
 Add:
1
 Add:
2
 Add:
3
 Add:
4
 Add:
0
 Summation =          10

root@overo:~# ls
SumData.DAT  fsum  sum.f90

Cross-compile

Setup an environment pointed at the cross-build tools. A script like this will work.

--- set-fortran-env.sh ---
export STAGEDIR=$OETMP/sysroots/`uname -m`-linux/usr

# soft-float
export PATH=${STAGEDIR}/bin:${STAGEDIR}/bin/armv7a-vfp-neon-poky-linux-gnueabi:${PATH}

# hard-float
# export PATH=${STAGEDIR}/bin:${STAGEDIR}/bin/cortexa8hf-vfp-neon-poky-linux-gnueabi:${PATH}

unset CFLAGS CPPFLAGS CXXFLAGS LDFLAGS

export ARCH="arm"
export CROSS_COMPILE="arm-poky-linux-gnueabi-"
--- end set-fortran-env.sh ---

Before sourcing that file, export an OETMP environment variable that is the same as the Yocto build/conf/local.conf TMPDIR variable.

export OETMP=/oe8/tmp-poky-dora-build

The default location for TMPDIR is <project>/build/tmp. But local.conf is where it comes from.

After that, a Makefile like the following will work

--- Makefile ---
# Use Yocto cross-tools to compile a Fortran program
# Source the setup-fortran-env.sh script first

CC = arm-poky-linux-gnueabi-gfortran

SRC = sum.f90
TARGET = fsum

$(TARGET): $(SRC)
        $(CC) $(SRC) -o $(TARGET)
--- end Makefile ---

So it goes like this

scott@octo:~/<project>/fortran$ ls -l
total 8
drwxrwxr-x 2 scott scott 4096 Apr  2 11:06 fsum
-rwxrwxr-x 1 scott scott  270 Apr  2 10:56 set-fortran-env.sh

scott@octo:~/<project>/fortran$ export OETMP=/oe8/tmp-poky-dora-build

scott@octo:~/<project>/fortran$ source set-fortran-env.sh

scott@octo:~/<project>/fortran$ cd fsum
scott@octo:~/<project>/fortran/fsum$ ls -l
total 8
-rw-rw-r-- 1 scott scott 215 Apr  2 10:58 Makefile
-rw-rw-r-- 1 scott scott 460 Apr  2 10:13 sum.f90

scott@octo:~/<project>/fortran/fsum$ make
arm-poky-linux-gnueabi-gfortran sum.f90 -o fsum

scott@octo:~/<project>/fortran/fsum$ ls -l
total 20
-rwxrwxr-x 1 scott scott 12098 Apr  2 11:08 fsum
-rw-rw-r-- 1 scott scott   215 Apr  2 10:58 Makefile
-rw-rw-r-- 1 scott scott   460 Apr  2 10:13 sum.f90

Copy the fsum executable to the target board and it should run.

Jumpnow Technologies, LLC - Privacy Policy

  游戏开发 最新文章
6、英飞凌-AURIX-TC3XX: PWM实验之使用 GT
泛型自动装箱
CubeMax添加Rtthread操作系统 组件STM32F10
python多线程编程:如何优雅地关闭线程
数据类型隐式转换导致的阻塞
WebAPi实现多文件上传,并附带参数
from origin ‘null‘ has been blocked by
UE4 蓝图调用C++函数(附带项目工程)
Unity学习笔记(一)结构体的简单理解与应用
【Memory As a Programming Concept in C a
上一篇文章      下一篇文章      查看所有文章
加:2021-10-21 12:43:55  更:2021-10-21 12:46:28 
 
开发: C++知识库 Java知识库 JavaScript Python PHP知识库 人工智能 区块链 大数据 移动开发 嵌入式 开发工具 数据结构与算法 开发测试 游戏开发 网络协议 系统运维
教程: HTML教程 CSS教程 JavaScript教程 Go语言教程 JQuery教程 VUE教程 VUE3教程 Bootstrap教程 SQL数据库教程 C语言教程 C++教程 Java教程 Python教程 Python3教程 C#教程
数码: 电脑 笔记本 显卡 显示器 固态硬盘 硬盘 耳机 手机 iphone vivo oppo 小米 华为 单反 装机 图拉丁

360图书馆 购物 三丰科技 阅读网 日历 万年历 2024年11日历 -2024/11/28 0:58:03-

图片自动播放器
↓图片自动播放器↓
TxT小说阅读器
↓语音阅读,小说下载,古典文学↓
一键清除垃圾
↓轻轻一点,清除系统垃圾↓
图片批量下载器
↓批量下载图片,美女图库↓
  网站联系: qq:121756557 email:121756557@qq.com  IT数码