Installing openssh-server, g++, gdb, and gdbserver in a docker container | Visual C++ for Linux Development + Docker - bash

I would like to install the dependencies for Visual C++ for Linux Development, namely openssh-server, g++, gdb and gdbserver in a docker container.
I run a docker container based on an Ubuntu image I have tried ubuntu:14.04, ubuntu:12.04 and ubuntu:latest. I am running the container in interactive mode and using bash to attempt to install the dependencies.
The Visual C++ for Linux page linked above suggests that the dependencies can be installed with...
sudo apt-get install openssh-server g++ gdb gdbserver
However I'm having trouble installing them. For instance when I attempt to install gdb I get an error stating that the package could not be found...
root#f6de8c642ffa:/# apt-get install gdb
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package gdb
I have also tried prefixing with sudo without luck. I get similar errors for the other packages, except for g++ which I believe installed.
I'm presuming that these tools for C++ development can be used with a docker container. I'm new to both Linux and docker though.
How do I get these tools installed in an Ubuntu docker container?

You probably need to do an apt-get update first - these packages have probably been updated (and thus their explicit package versions have changed) since the source list in your container was written (when the image was created, not when the container was instantiated).
Once you update, apt-get install ... should be able to install them.

Related

Packages apt-get vs brew?

Im trying to get something running in a lab, and I need to install a whole bunch of packages to compile the code:
sudo apt-get install build-essential libgtk2.0-dev libwxgtk3.0-dev libwx-perl libmodule-build-perl git cpanminus libextutils-cppguess-perl libboost-all-dev libxmu-dev liblocal-lib-perl wx-common libopengl-perl libwx-glcanvas-perl libtbb-dev libxmu-dev freeglut3-dev libwxgtk-media3.0-dev libboost-thread-dev libboost-system-dev libboost-filesystem-dev libcurl4-openssl-dev libextutils-makemaker-cpanfile-perl
The problem is, I'm working on a Mac; So I only have brew available - and the package names are not equivalent.
Am I trying to do something dumb and impossible, or is there a way to cross reference those apt-get packages to ones available in brew and install those so I can build the app?
For added context, its a modified "slicer" application for generating files that a 3d printer uses to make parts. I could fire up an ubuntu VM and use apt-get, but I'm on an M1 mac at the moment and recompiling experimental QEMU code just so I can fire up an ubuntu VM takes me way more out of my depth than I already am... I'm running brew on a duplicated, rosetta emulation forced terminal.
There is no straightforward way to automatically figure out whether a corresponding Homebrew package exists for each of these packages, no. But you can probably guess the majority, and manually figure out the rest. Each Debian package has a link to the upstream sources, and a home page if one exists, from which you can often find links to packages for other architectures, etc.
From the Debian package search page you can search e.g. for the libxmu-dev package, and discover the corresponding package page for Buster (the current stable Debian release), which in turn has links to the upstream repo, etc. But this is an X11 package, so it's not straightforwardly compatible with macOS, which uses an entirely different GUI architecture.

Unable to install quickly in Ubuntu 18.04

Installing quickly on Ubuntu 18.04
$ sudo apt-get install quickly quickly-ubuntu-template
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package quickly-ubuntu-template
Build new apps quickly - is not found in the Ubuntu Software Center also.
How can I now install quickly?
I'm afraid after Ubuntu 14.04 Quickly is no longer available for download but you could use illumination software creator from :
https://github.com/jsebean/IlluminationSoftwareCreator
but i haven't found how to install it yet...

Installing libgcrypt11-dev through Terminal on macOS

I have a project using headers such as malloc and gcrypt. To get the project to compile on my Ubuntu machine, I just have to run: % sudo apt-get install libgcrypt11-dev
However, I would like to be able to work on this project on my mac. I have tried to use brew for libgcrypt11-dev, but that is not a viable library with brew. Does anyone have any suggestions on how to install the equivalent of libgcrypt11-dev on macOS? I am using GCC on both machines.

exec: "gcc": executable file not found in %PATH% when trying go build

I am using Windows 10. When I tried to build Chaincode it reported this error
# github.com/hyperledger/fabric/vendor/github.com/miekg/pkcs11
exec: "gcc": executable file not found in %PATH%
My chaincode imports:
import (
"fmt"
"strconv"
"github.com/hyperledger/fabric/core/chaincode/shim"
pb "github.com/hyperledger/fabric/protos/peer"
)
It's running fine in Docker.
gcc (the GNU Compiler Collection) provides a C compiler. On Windows, install TDM-GCC. The github.com/miekg/pkcs11 package uses cgo. Cgo enables the creation of Go packages that call C code.
If you are running Ubuntu do:
apt-get install build-essential
This solved the problem. It installs the gcc/g++ compilers and libraries.
I also encountered this message, but in my case, it was missing gcc.exe. I used choco and installed mingw, and then it worked.
details:
download choco
choco install mingw -y
check: gcc -v
1) Install .exe from > https://sourceforge.net/projects/mingw-w64/
1.2) ! use x86_64 architecture
2) Add C:\Program Files\mingw-w64\x86_64-8.1.0-posix-seh-rt_v6-rev0\mingw64\bin to PATH in User Variables and in System Variables. For me it works.
! To edit Path variable press Windows key, type 'path', choose 'Edit the system environment variables', click 'Environment Variables', find Path variable in System variables and in User variables then edit.
On Windows install http://tdm-gcc.tdragon.net/download, that is all.
If you are using an alpine based image with your Dockerfile
Install build-base which will be met with your requirements.
apk add build-base
$ go env
check CGO_ENABLED if its 1 change it to 0 by
$export CGO_ENABLED=0
For my case :
os: windows 10
command:
choco install mingw
install choco if not installed:
Link: https://www.liquidweb.com/kb/how-to-install-chocolatey-on-windows/
worked for me.
The proper explanations why go build does not work for hyperledger in Windows environment are given as other answers.
For your compilation purposes, just to make it work without installing anything extra, you can try the following
go build --tags nopkcs11
It worked for me. I hope same works for you too.
You can try - this is not a solution but a temp workaround
cgo_enabled=0 go build
Once you install gcc - and make sure %PATH has a way to find it (gcc.exe) - this should go away.
Also running this one will ensure the cgo_enabled variable will stay this way as long as terminal is open. That way you don't have to prefix it each time you do a build.
export cgo_enabled=0 go build
just followed instructions from following and it solve my issue
https://code.visualstudio.com/docs/cpp/config-mingw
it ask to install Mingw-w64 via MSYS2
important command is pacman -S --needed base-devel mingw-w64-x86_64-toolchain
then add C:\msys64\mingw64\bin to PATH
thanks
For Ubuntu, what worked for me was to simply run:
sudo apt install gcc
On Amazon Linux 2:
Install go
wget https://go.dev/dl/go1.18.1.linux-amd64.tar.gz
rm -rf /usr/local/go && tar -C /usr/local -xzf go1.18.1.linux-amd64.tar.gz
export PATH=$PATH:/usr/local/go/bin
Install gcc
sudo yum groupinstall "Development Tools"
I recommend using the package group, even though it can be done without it, because groupinstall gives you the necessary packages to compile software on Amazon Linux and Redhat, CentOS for that matter.
on Ubuntu its very easy but on windows need to do it:
download MinGW on http://www.mingw.org/
install on basic package Gcc-g++ (see this image)
add on environment Patch of windows variables.
restart and continue with "go get ..."
If you are running Ubuntu do:
sudo apt-get update
sudo apt-get install build-essential.
If the above commands do not work do:
sudo add-apt-repository "deb http://archive.ubuntu.com/ubuntu $(lsb_release -sc) main universe"
The main component contains applications that are free software, can be freely redistributed and are fully supported by the Ubuntu team. & The universe component is a snapshot of the free, open-source, and Linux world.
Then install package by following command in terminal:
sudo apt-get update
sudo apt-get install build-essential.
For more info click here: https://itectec.com/ubuntu/ubuntu-problem-installing-build-essential-on-14-04-1-lts-duplicate/
Just add this to your Dockerfile
RUN apk add alpine-sdk
gcc should not be necessary, unless you are cross compiling for a non-windows platform, or use cgo.
If you still need gcc, however, you should install MinGW, which provides a gcc port for Windows (Cygwin and msys should also work, although I have never actually tested this).
Edit: I see from your error message now, that it is a dependency that requires gcc. If you didn't already know this, gcc is a c/c++ compiler, and in this case it is probably needed to compile c source files included by a dependency or sub-dependency.
Instruction to fix the "exec: “gcc”: executable file not found in %PATH%" error with MSYS2:
Download MSYS2.
Put MSYS2 folder into your $PATH.
Start the MSYS2 command line program.
Run this command: pacman -S gcc.
Kindly install the MINGW after GUI will automatically take.
http://mingw.org/wiki/Getting_Started
On Windows, you can install gcc by Scoop:
scoop install gcc
you need to download MingGW64
put MingGW64 folder into your $PATH
run go build xxx.go (with cgo library)
Hi jaswanth the main problem is that you haven't register your %GO_HOME%\pkg\tool\windows_amd64 to yuour Environment Path.
%GO_HOME% is the repository where you install your go at the first time.
same as other, just install tdm-gcc, but you can use its terminal, "MinGW", you can access it from start menu folder tdm-gcc, after start, browse to your project, and run it again
I'm a Windows user and I downloaded tdm-gcc (MinGW-w64 based) from the link below:
https://jmeubank.github.io/tdm-gcc/
After installation, it made a folder named "TDM-GCC-64".
I added "C:\TDM-GCC-64\bin" to my PATH, And it fixed my problem.

installing a GCC compiler onto a Docker Container

I am trying to install mono package onto a Docker container, but mono requires
git , autoconf, libtool, automake, build-essential , mono-devel, gettext packages.
the problem I am having is that libtool requires libc-dev, and libc-dev requires gcc compiler.
The docker container does not have any compiler installed, but my local machine does.
arcolombo#acolombo:~/Documents/bedgraph_dockerfile$ dpkg --list |grep compiler
ii g++ 4:4.8.2-1ubuntu6 amd64 GNU C++ compiler
ii g++-4.8 4.8.2-19ubuntu1 amd64 GNU C++ compiler
ii gcc 4:4.8.2-1ubuntu6 amd64 GNU C compiler
ii gcc-4.8 4.8.2-19ubuntu1 amd64 GNU C compiler
ii hardening-includes 2.5ubuntu2.1 all Makefile for enabling compiler flags for security hardening
ii libllvm3.5:amd64 1:3.5-4ubuntu2~trusty2 amd64 Modular compiler and toolchain technologies, runtime library
ii libmono-compilerservices-symbolwriter4.0-cil 3.2.8+dfsg-4ubuntu1.1 all Mono.CompilerServices.SymbolWriter library (for CLI 4.0)
ii libxkbcommon0:amd64 0.4.1-0ubuntu1 amd64 library interface to the XKB compiler - shared library
ii mono-mcs 3.2.8+dfsg-4ubuntu1.1 all Mono C# 2.0 / 3.0 / 4.0 / 5.0 compiler for CLI 2.0 / 4.0 / 4.5
so my question is , what is the easiest way to get a gcc compiler onto a Docker container? should I just create a volume of these compiler directories into my docker container?
The reason I think I may need it is because I am running a website, and the website executes a docker image directly.
In your Dockerfile:
FROM ubuntu
# ...
ENV DEBIAN_FRONTEND noninteractive
RUN apt-get update && \
apt-get -y install gcc mono-mcs && \
rm -rf /var/lib/apt/lists/*
As I understand it, the OP has confused the terminology, and probably meant to ask:
installing a GCC compiler onto a Docker image
My answer starts by addressing the title of the question (regarding containers), then moves on to the intent of the question (regarding images).
If you can run a BASH shell in the container, then you don't need to manipulate a Dockerfile.
Say, for example, you try the hint from the docker run hello-world example:
docker run -it ubuntu bash
Then just run these from the shell in the container...
apt-get update
apt-get install gcc
A key point is that apt-get install in a raw Docker container may not behave as expected if you don't first run apt-get update. Expect to see...
Unable to locate package gcc
The error message when trying to install g++ without apt-get update is even more confusing due to "regex" substitution.
See also: http://www.liquidweb.com/kb/how-to-list-and-attach-to-docker-containers
docker ps -a ## list all available containers
and
docker exec -ti [CONTAINER ID] bash
This live-manipulation approach can also be used to creates images as the OP probably intended. Use docker commit to save your live container as a new image.
You could also grab an official image that already has GCC and/or some/most of the tools you need already installed. The docker store has a lot of official images already setup: https://store.docker.com/search?page_size=99&q=&source=verified
I'm not sure if it's the right mono, but they have a mono image: https://store.docker.com/images/4234a761-444b-4dea-a6b3-31bda725c427?tab=description
And an official GCC image: https://store.docker.com/images/06ad851d-f666-47d3-9ef3-e90535c141ec?tab=description
There's also buildpack-deps if you're going to be building stuff yourself: https://store.docker.com/images/9e56c286-5b40-4838-89fe-fd513c9c3bd6
You can browse by category: https://store.docker.com/search?page_size=99&q=&source=verified
And also directly search docker hub for mono or whatever your needs are: https://hub.docker.com/search/?isAutomated=0&isOfficial=0&page=1&pullCount=0&q=mono&starCount=0

Resources