How can I run GCC into WSL? - c

So, Windows System on Linux seems to be an inovative light-weight substitute for a virtual machine, especially when it comes to learning Linux. Nevertheless, for me WSL seems to have a little more complicated organization from a VM when it comes to file management. For example, in WSL the data are stored in
C:\Users\<username>\AppData\Local\Packages\CanonicalGroupLimited.Ubuntu20.04onWindows_79rhkp1fndgsc\LocalState\rootfs\usr\
as shown here.
Of course my first try to install GCC was to type in:
sudo apt install gcc
,but after typing
gcc --version
the output was :
Command 'gcc' not found, but can be installed with:
sudo apt install gcc
After that, I tried installing GCC using the following commands as shown here :
$ sudo apt-get update && sudo apt-get upgrade -y
$ sudo apt autoremove -y
$ sudo apt-get install gcc -y
but I end up getting the same output.
On the other hand, I already had installed TDM GCC on Windows and used sudo in VM to install it also there (successfully:).
Like a lot of people, I want to substitute the use of my virtual machine with WSL in order to be able to develop in C without overloading my RAM my questions are :
Can you count out for me how many times have I downloaded GCC files?
Why the folder that I was supposed to be downloading the gcc files in is shown to be empty?
Where are the downloaded files being stored?
How can get gcc fired up?
Is there any way to use the gcc I had on Windows to compile C using the WSL terminal?
I think these questions come from the fact that I cannot understand how WSL file system interacts with Windows. They are a bit more generic on purpose because I want you to have a lot of "answering" freedom.
Please help me out of this one! I don't want to be forced to use a virtual machine and run out of RAM almost every time!

Related

Installation of postgresql for using and debugging Apache-AGE

I am trying to install postgresql on my system to run apache AGE on it. I am trying to run the ./configure command for checking the required libraries and their existence. Although upon running this command it gives me the following error
I am currently using wsl for this rather than using windows for installation. It would be really helpful if someone can guide me through this process.
Install the required dependencies first using following command
sudo apt-get install build-essential libreadline-dev zlib1g-dev flex bison
Install postgres-11 or 12
sudo apt install postgresql-server-dev-11
Then configure with this command
./configure --enable-debug --enable-cassert --prefix=$(pwd) CFLAGS="-ggdb -Og -fno-omit-frame-pointer"
You may need to install some libraries before.
If you are in Debian based distros, run:
sudo apt-get install build-essential libreadline-dev zlib1g-dev flex bison
Also, if you want to debug later, be sure to run the configure command with at least these debugger flags:
./configure --enable-debug --enable-cassert
This documentation may give you more details about it:
https://www.postgresql.org/docs/current/installation.html

Install arm-poky-linux-gnueabi toolchain on PC

There are 2 compilers used in IMX7(ARM Yocto Linux):
arm-poky-linux-gnueabi-gcc
arm-poky-linux-gnueabi-g++
When I build complete image by spending about 2 hours its already downloaded.
But I would like to know how to install this tool chain directly on PC(Ubuntu/CentOS) and use it as separate compiler in PC instead of with its Image as I mentioned above.
Use below command in your ubuntu pc
$ sudo apt-get install gcc-arm-linux-gnueabihf
$ sudo apt-get install g++-arm-linux-gnueabihf

error when compiling testfiles from installed c-algorithms library

I'm trying to install and test c library c-algorithms from Github.
https://github.com/fragglet/c-algorithms/blob/master/test/test-queue.c
When I try to test the installation from the generated test folder with:
gcc -o test-arraylist `pkg-config --cflags --libs libcalg-1.0` test-arraylist.c
I get the following error massage:
test-arraylist.c:30:23: fatal error: arraylist.h: No such file or directory
compilation terminated.
I use a Vagrant box: ubuntu/xenial32 with Ubuntu 14.04.5 LTS
Prior to installation of c-algorithms:
sudo apt-get install autoconf
sudo apt-get install libtool
sudo apt-get install pkg-config
To install the library I have done following:
sudo ./autogen.sh
sudo ./configure
sudo make
sudo make install
Any help would be highly apriciated
The test-arraylist.c has line #include "arraylist.h" but it is under the libcalg subdirectory not directly in the include path.
libcalg subdir should be added to the include path or you have to modify the include like #include "libcalg/arraylist.h"
If you want only run the tests, then run the
sudo make check from the build root (in your case it is the source root)
This is probably going to be stomped on by process-fetishizers.
But.
When you build in a Unix/Linux operating system (and derivatives like RTEMS), you are building off other people's libraries - so you need those libraries and their header files ( just like c-alg... ) installed in locations that your compiler can find.
To find a file that is associated with a package, use dpkg as explained here:
https://askubuntu.com/questions/481/how-do-i-find-the-package-that-provides-a-file
But you have another problem you might not be aware of. You are trying to compile a test program using a gcc command when the software uses GNU autoconf automake and probably libtool to function PROPERLY.
Perhaps you don't understand you need to make sure autoconf, automake, and then libtool find the right configuration from one directory system to another. Fedora puts files in differing spots from Ubuntu distros.
Instead run:
autoreconf -fvi
first in the top level directory and see if this finds your header file.
THEN you run
./configure
and then
make test/check
(whichever it uses, some use recipe "all-tests", etc.)
make all
This would make all if your system is ready to handle them.

c - can't compile with <sys/times.h> ubuntu

I have 64bit ubuntu installed, and I am trying to compile a code with times.h however I keep getting sys/times.h No such file or directory
What I have tried so far
1. installing libc6-dev-i386, g++-multili, and libc6 and libc6-dev (Even though it is already installed)
2. I swapped <sys/times.h> to </usr/include/sys/times.h> and now I am getting features.h No such file or directory error
Question:
It is weird how it accepts </usr/include/sys/times.h> instead of <sys/times.h>, and help?
EDIT: I can access times.h, if it matters
I would recommend running:
$ locate /sys/time.h | grep include
Using the output you can determine what to do next:
If there is a file named /usr/include/<x86_64 or i386>-linux-gnu/sys/time.h, then simply run: $ sudo ln -s /usr/include/<x86_64 or i386>-linux-gnu/sys /usr/include/sys. This will direct the compiler to the right file if it checks . This seems to be what you are doing manually.
If there is no relevant output, then try downloading build-essential. It may be that something else is missing. $ sudo apt-get update; sudo apt-get install build-essential
Let me know if this helps!

Problems with Compiling C program on Ubuntu

I am using Ubuntu 10.10 as VM and am new to it. Until recently i could easily compile C programs from the terminal. However, as i try to compile them now it gives a message as:
/usr/bin/ld: cannot find -lc
collect2: ld returned 1 exit status
I have searched for it over the net but could not figure out what is going wrong. I know the answer to it must be simple but any help would be appreciated. Thanks!
Installing the necessary tools should solve your problem. Try:
sudo apt-get install build-essential
You probably -- most of us do -- installed Ubuntu desktop, but not Ubuntu server. A whole lot of tools don't come over with a default Ubuntu desktop installation.
So start by installing build-essential:
sudo apt-get install -y build-essential
Then try the compile again. build-essential contains a bunch of components that you need to perform a basic compile.
For my work, beyond build-essential, I have to install other libraries like curses. However, I first have to have build-essential installed before I can do anything else.

Resources