yocto project runqemu: command not found - linux-kernel

I am setting up my yocto project, for that i have followed these below steps:
download the Poky Source code (ubuntu: /yocto/source)
$ git clone git://git.yoctoproject.org/poky
Checkout the latest branch/release (zeus)
$ git checkout zeus
Step 3: Prepare the build environment (ubuntu: /yocto/source/poky)
$ source oe-init-build-env ../../build
The above script will move in a build folder and create two files in conf folder ( local.conf, bblayers.conf ) inside conf folder
Building Linux Distribution (unbuntu: /yoctu/build)
$ bitbake core-image-minimal
Checking the runqemu (ubuntu: /yocto/source/poky/scripts)
$ ls runqemu // and it is there
Run generated image in qemu (ubuntu: /yocto/build)
$ runqemu qemux86-64 core-image-minimal
other window open for qemu and image runs well.
Problem
After using first time when i close the terminal, and use it again by running $ runqemu qemux86-64 core-image-minimal in (ubuntu: /yocto/build) error pops up runqemu: command not found and if i write bitbake in poky directory same error pops up bitbake: command not found.
NOTE: i have repeat this whole process 3 times to check if the installation is not correct but i have done everything fine from my side.
yocto project hierarchy:

If you close your poky environment terminal you always MUST re-source the environment.
The poky's oe-init-build-env setups up all commands for you, for instance:
runqemu* commands which are present in poky/scripts.
The script also export bitbake* commands from poky/bitbake/bin.
The line responsible for that is in:
poky/scripts/oe-buildenv-internal (line 99):
# Make sure our paths are at the beginning of $PATH
for newpath in "$BITBAKEDIR/bin" "$OEROOT/scripts"; do
# Remove any existences of $newpath from $PATH
PATH=$(echo $PATH | sed -re "s#(^|:)$newpath(:|$)#\2#g;s#^:##")
# Add $newpath to $PATH
PATH="$newpath:$PATH"
done
So, always if you open new terminal:
source /yocto/source/poky/oe-init-build-env /yoctu/build
EDIT
If you already have a build folder, make sure to provide the right path for that folder to the oe-init-build-env script.
If you provide new path to non-existing folder, than the script will create another build for you.
EDIT2
To source poky environment according to your path:
Relative:
cd ~/Documents/yocto/source/poky
source oe-init-build-env build
^
|
(because build is in same folder as the script)
Absolute:
source /home/$USER/Documents/yocto/source/poky/oe-init-build-env /home/$USER/Documents/yocto/source/poky/build
THE RULE
source <path/to/oe-init-build-env> <path/to/build/folder>
If <path/to/build/folder> exists then, poky will source the existing build environment.
If <path/to/build/folder> does not exist, poky will create new build under the same name and path.

Related

install local package so it can find the location of the other files belonging to the project, without adding project directory to `$PATH`

I have a local Go project which requires another data file to live with it, as in
my_project/
go.mod
my_tool.go
data.txt
go.mod:
module my_project/my_tool
go 1.19
Until today, I had the path to my_project directory inserted in the $PATH environment variable so I could build the executable file with go build and run it from anywhere.
Then I wanted to try and run go install (with no arguments, as shown in this tutorial) from my_project directory. So I did and noticed that the command does two things:
go install builds the executable file just like go build does;
go install moves the executable file —the file itself, not its symlink— to the $GOPATH/bin directory.
But the go install command does not put any other project file to $GOPATH/pkg/mod — which is a no-go for my tool which requires its buddy data.txt file to be located in the same filepath.Dir(os.Executable()) directory as the executable file.
Neither does the go install my_project/my_tool command. Hence the question:
Is it possible to install a local Go package in the $GOPATH directory in such a way that it can find the location of the other files belonging to the project without me having to add the project directory to $PATH?

how to build go outside of source directory?

My go application directory structure is like this:
/app
go.mod
go.sum
main.go
When I build the app I usually cd into that directory and build.
cd app
go build
I wonder if I can build without cd in to app directory.
When I go go build /app, it prints go: go.mod file not found in current directory or any parent directory; see 'go help modules'.
See https://golang.org/ref/mod#commands-outside :
go build needs to be run from a module directory.
The simplest way is to cd into your module directory (cd /app) to run your go build command.
(there probably is some way to create a phony local go.mod file, and reference your /app module from there, but I wasn't able to devise a hack to do this)
Go now can change directory before build with the help of flag -C:
go build -C app
"The go subcommands now accept -C to change directory to before performing the command"
Source: https://tip.golang.org/doc/go1.20
(You don't need to run cd .. after this command. Shell stays in the same directory)
I'm pretty sure to build you will need to be in the app directory.
As a workaround if you are just wanting to be on the command line in a different directory and want to run the build with one command you can just chain the cd and go build commands together like this:
cd app; go build ; cd ..
This is the same amount of typing but could be in your command history just a couple presses of the up arrow away.
Note this is for bash or similar UNIX style shell. If using Windows cmd then I think it would be something like this (Not tested as I don’t have readily available access to a Windows machine right now):
cd app & go build & cd ..

Getting cmake to work under Cygwin on Windows 7

I installed the latest Cygwin on my Windows 7 machine: version 2.893 (64-bits). I made sure I included cmake, i.e. I was able to add several packages by running the Cygwin net release setup program again, after doing the first installation. I then tried to use cmake and made sure I invoked it from the bin directory:
user008#L0147816 /bin
$ ./cmake
CMake Error: Could not find CMAKE_ROOT !!!
CMake has most likely not been installed correctly.
Modules directory not found in
//share/cmake-3.6.2
Usage
cmake [options] <path-to-source>
cmake [options] <path-to-existing-build>
Specify a source directory to (re-)generate a build system for it in the
current working directory. Specify an existing build directory to
re-generate its build system.
Run 'cmake --help' for more information.
I don't know where the build directory could be. I'm relatively new to Cygwin. I hope somebody has found a solution for getting cmake installed and working properly under Cygwin.
This looks cmake 101.
Assuming you want to just build a software download from somewhere
eg gl2ps:
# choosing a test area
$ cd /tmp
# downloading source
$ wget http://geuz.org/gl2ps/src/gl2ps-1.4.0.tgz
# expanding source code
$ tar -xf gl2ps-1.4.0.tgz
$ ls gl2ps-1.4.0-source/
CMakeLists.txt COPYING.LGPL gl2ps.h gl2ps.tex gl2psTestSimple.c
COPYING.GL2PS gl2ps.c gl2ps.pdf gl2psTest.c README.txt
# preparing a build area
$ mkdir build
$ cd build
# invoking cmake and pointing to the source directory
$ cmake ../gl2ps-1.4.0-source/
-- The C compiler identification is GNU 7.3.0
[cut ...]
-- Configuring done
-- Generating done
-- Build files have been written to: /tmp/build
# running the build
$ make
Scanning dependencies of target shared
[ 11%] Building C object CMakeFiles/shared.dir/gl2ps.o
...
[ 88%] Building C object CMakeFiles/gl2psTestSimple.dir/gl2psTestSimple.o
[100%] Linking C executable gl2psTestSimple.exe
[100%] Built target gl2psTestSimple
Instead for learning how to build with cmake, go to
https://cmake.org/cmake-tutorial/
Here a solution I just found.
Let's name 3 directories:
{cygwin64-path}/bin/: cmake.exe is here.
{cygwin64-path}/usr/share/: cmake module directory (such as cmake-3.20.0) is here.
{cygwin64-path}/share/: cmake.exe trying to find cmake-module-directory here, but it doesn't exist.
It's wired because cygwin install cmake-module-directory in {cygwin64-path}/usr/share/, but cmake.exe looks for the directory in {cygwin64-path}/share/.
So solution is simple. Each one below works.
METHOD 1: Create the directory {cygwin64-path}/share/ and copy all relevant directories and files from {cygwin64-path}/usr/share/ to the new directory.
METHOD 2: Create a Symbolic links {cygwin64-path}/share/ to {cygwin64-path}/usr/share/.
In windows 10 Administrator cmd.exe: mklink /J share usr\share and all works.
Or use WSL or Cygwin64 Terminal: ln -s usr/share share

Having trouble editing and executing .sh file in Cygwin

I am relatively new to the Cygwin program, and I have a .sh file that I need to edit and execute. I am currently running on Windows 10. I have installed Cygwin64 terminal on my machine.
The full list of steps required are as follows:
Be sure to have libtool installed.
Download protobuf from https://github.com/google/protobuf/ (download ZIP and unZIP at desired location, or clone the repo) The protocol buffer is used for communication between the CuraEngine and the GUI.
Before installing protobuf, change autogen.sh : comment line 18 to line 38 using #s. This removes the dependency on gtest-1.7.0.
Run autogen.sh from the protobuf directory: $ ./autogen.sh
$ ./configure
$ make
$ make install # Requires superused priviliges.
(In case the shared library cannot be loaded, you can try "sudo ldconfig" on Linux systems)
Once I get to 3.:
Before installing protobuf, change autogen.sh : comment line 18 to line 38 using #s. This removes the dependency on gtest-1.7.0.
I am having issues opening up to .sh file in Cygwin to make the appropriate edit.
When I try this command to even execute the .sh file:
$ '/cygdrive/c/Users/Thomas/Desktop/3D Printing/protobuf-master/autogen.sh'
I receive the error:
Could not find source code. Make sure you are running this script
from the root of the distribution tree.
If anyone has some insight as to a solution for this problem it would be greatly appreciated.
You are getting the error from this test in autogen.sh :
# Check that we're being run from the right directory.
if test ! -f src/google/protobuf/stubs/common.h; then
cat >&2 << __EOF__
Could not find source code. Make sure you are running this script from the
root of the distribution tree.
__EOF__
In this test, common.h path is relative to the protbuf install directory, just cd to it before executing the script.

Go: "stat hello.go: no such file or directory"

Just installed Go on Mac OS X, Yosemite Version 10.10.3, as explained in the Getting Started page of the official website:
Mac OS X package installer
Download the package file, open it, and follow the prompts to install
the Go tools. The package installs the Go distribution to
/usr/local/go.
The package should put the /usr/local/go/bin directory in your PATH
environment variable. You may need to restart any open Terminal
sessions for the change to take effect.
I am now in the Test your installation section, which states:
Check that Go is installed correctly by building a simple program, as
follows.
Create a file named hello.go and put the following program in it:
package main
import "fmt"
func main() {
fmt.Printf("hello, world\n") }
Then run it with the go tool:
$ go run hello.go
hello, world
If you see the "hello, world" message then your Go installation is
working.
So, I created a hello.go file and, since I could not (ie: did not know how to) access the /usr/local/go/bin directory, I saved it on my desktop.
Obviously, I got the following error message:
stat hello.go: no such file or directory
So, where should I save my Go files to be able to run them?
UPDATE: after some research, I stumbled upond this video, explaining how to set the GOPATH.
If I want my Go workspace to be in user/code/go, how should I write my export GOPATH= command?
if your are using docker compose up/down to build image. You need to run
docker compose build
after changes in Dockerfile.
In my case, it was as simple as right clicking the file, and then clicking 'open in integrated terminal.' Then, to run your file type 'go run filename.go'
The GOPATH and PATH environment variables
The GOPATH environment variable specifies the location of your workspace. It defaults to a directory named go inside your home directory ($HOME/go).
If you really want to change your GOPATH to something else add GOPATH to your shell/bash/zsh initialization file .bash_profile, .bashrc or .zshrc.
export GOPATH=/something-else
Add GOPATH/bin directory to your PATH environment variable so you can run Go programs anywhere.
export PATH=$PATH:$(go env GOPATH)/bin
Following the explanation of Andrew Gerrand in Writing, building, installing, and testing Go code, I configured my Go workspace as follows:
1. Create workspace
First, since I want my Go code to be in my_user_name/code/go, I started by creating the corresponding folder:
$ cd code
$ mkdir go
2. Setup GOPATH
Then I configured the GOPATH:
$ cd
$ export GOPATH=$HOME/code/go
$ cd code/go
3. Add files to workspace
Last, I manually (through the Finder) moved my hello.go file into the workspace and ran:
$ go run hello.go
Worked like a charm.

Resources