You are not logged in.

#1 2018-12-26 16:49:58

sollongqua
Member
Registered: 2018-12-26
Posts: 2

how do you develop in C in arch ?

how can i get c libraries ? and what are some useful tools i should use to help me  program in c ?

Offline

#2 2018-12-26 16:54:09

graysky
Wiki Maintainer
From: :wq
Registered: 2008-12-01
Posts: 10,734
Website

Offline

#3 2018-12-26 16:57:31

sollongqua
Member
Registered: 2018-12-26
Posts: 2

Re: how do you develop in C in arch ?

i just want to know if there is somthing like pip or npm but for c or how can i do it manually ?

Offline

#4 2018-12-26 17:02:04

graysky
Wiki Maintainer
From: :wq
Registered: 2008-12-01
Posts: 10,734
Website

Re: how do you develop in C in arch ?

sollongqua wrote:

i just want to know if there is somthing like pip or npm but for c or how can i do it manually ?

https://wiki.archlinux.org/index.php/Pa … cific_file
https://www.archlinux.org/packages/

Arch probably isn't for you if you're unwilling to research things or ask good questions...

Offline

#5 2018-12-26 17:51:28

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 30,531
Website

Re: how do you develop in C in arch ?

sollongqua wrote:

i just want to know if there is somthing like pip or npm but for c

No.  C is fundamentally different than python or javascript (isn't that what npm is for).  C is a compiled programming language, python and javascript are scripting languages.  Further, and in my very personal opinion, a need for pip or npm is a sign of a fundamentally broken design of a language (but note that python doesn't need pip).

With C, you write code that will compile and run on the actual target machine.  It doesn't need a virtual machine or an interpreter.  Further, with a compiled language like C, you can link to libraries* written in any language.  It can be helpful if they come wth C header files - which almost all compiled libraries do - but this is not strictly necessary.

You most likely have most of the libraries you would want already installed on your system.  Look in /usr/lib/*, those are all libraries you can use in C.  Or look in /usr/include/*, those are all the headers.  If you were in a distro like debian, you might have to install the -devel version of a given package to get the headers, but in arch, you'll already have them if you've installed the library.

So in a sense, the equivalent to pip or npm for coding in C is pacman.

*note: "libraries" here refers to actual object files of compiled code for the target architecture that it will run on, not just bundles of reusable scripts which is what "library" generally means in scripting languages (again, python can blur the lines here too, but that's a different topic.)

sollongqua wrote:

... or how can i do it manually ?

Do what manually?  While I said pacman is kind of the equivalent, that is only true in arch as pacman is how you install software in arch.  There is no equivalent to pip or npm for C as there is no need for such monstrosities (er, I mean tools).  If you have a text editor and a compiler, you have all you need to write C code and create executable programs.

Last edited by Trilby (2018-12-26 17:58:05)


"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman

Offline

#6 2018-12-26 17:58:37

loqs
Member
Registered: 2014-03-06
Posts: 19,106

Re: how do you develop in C in arch ?

There is pkgconf for determining if a library is present and build systems such as autotools / meson can check for the availability of functions / compilers features etc.

Offline

#7 2018-12-26 18:44:33

/dev/zero
Member
From: Melbourne, Australia
Registered: 2011-10-20
Posts: 1,247

Re: how do you develop in C in arch ?

sollongqua wrote:

how can i get c libraries ? and what are some useful tools i should use to help me  program in c ?

I assume you've already done some basic C tutorials so you know about concepts like for-loops, functions, structures, pointers and using GCC (or some other compiler) to translate source code into an executable.

If you haven't done such tutorials, do them.

It's also useful to know about common data structures such as linked lists and hashes. There is no default implementation of these in C. You either need to learn how to reimplement them yourself, or find a sensible library.

Then to get started writing a real C program the process I follow is:

  1. Decide what the goal is. What should the program be able to do? What are the inputs and outputs? Who is the audience? What should the interface look like? What licence will it be under? Preferably write some shell scripts which will test the program for correct output.

  2. Research what libraries will be required to provide the functionality you require, based on the answers to (1). Work through tutorials for those libraries. (Working through the tutorials will require you to also have the libraries installed.)

  3. Put a skeleton in place for your program. Decide what all the functions you are going to need will be, what are their inputs and outputs? Put in their definitions. What are the main data structures you'll need? Add functions for querying and manipulating the data structures. Add #include for any libraries you identified in step (2).

  4. Make sure you can compile the skeleton. It won't be able to actually do anything yet, but you should be able to compile and run it without errors or segfaults. This is also about the point in time when it's a good idea to place the program under version control and create a Makefile.

  5. Flesh out the skeleton. Do this iteratively: add a bit of code, then compile and test. Add a bit more code. Compile and test. This basically covers the entire lifetime of your program going forward: almost everything after this is just part of the cycle of implementing new features and fixing bugs.

Some libraries I have found useful in the past:

Last edited by /dev/zero (2018-12-26 18:50:08)

Offline

#8 2018-12-26 19:14:45

ewaller
Administrator
From: Pasadena, CA
Registered: 2009-07-13
Posts: 20,715

Re: how do you develop in C in arch ?

Many C libraries can be installed by Pacman.

For example, try info libc for a good manual on a fairly comprehensive library you likely already have.


Nothing is too wonderful to be true, if it be consistent with the laws of nature -- Michael Faraday
The shortest way to ruin a country is to give power to demagogues.— Dionysius of Halicarnassus
---
How to Ask Questions the Smart Way

Offline

#9 2018-12-26 20:35:03

eschwartz
Fellow
Registered: 2014-08-08
Posts: 4,097

Re: how do you develop in C in arch ?

The official repositories also contain two alternative libc implementations you can target when building applications: musl, and dietlibc.


Managing AUR repos The Right Way -- aurpublish (now a standalone tool)

Offline

#10 2018-12-27 01:26:03

romstor
Member
Registered: 2018-08-18
Posts: 54

Re: how do you develop in C in arch ?

Trilby wrote:

Further, and in my very personal opinion, a need for pip or npm is a sign of a fundamentally broken design of a language (but note that python doesn't need pip)

npm, pip, etc. are just tooling to make dev's lives easier, not a part of the language. That said, having wasted untold amounts of time searching, syncing, compiling and fixing random C libraries, I find Rust's cargo to be life-changing. One can argue that this is something pacman could (or even should) do, but at the same time we can't get Linux distros agree on the package manager, let alone programming languages. Some things will just always be "mee too" kind of deal...

Offline

#11 2018-12-27 01:30:52

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 30,531
Website

Re: how do you develop in C in arch ?

romstor wrote:

npm, pip, etc. are just tooling to make dev's lives easier, not a part of the language.

I didn't say they are part of the language.  But npm, at least, is effectively necessary to use javascript in the way that npm users do.  Python is less tied to it's package manager, but still one must use pip or a distro package manager to install python-specific stuff in order to do much.  This is not the case with actual compiled languages like C.  You do not need C-specific libraries or tools - you just write what you want and link to what you want.


"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman

Offline

#12 2018-12-30 18:21:30

mxfm
Member
Registered: 2015-10-23
Posts: 166

Re: how do you develop in C in arch ?

sollongqua wrote:

how can i get c libraries ? and what are some useful tools i should use to help me  program in c ?

This is a completely ill-posed question. You can get "c libraries" by running pacman -S "needed package" but this is unlikely helpful because majority of needed "c libraries" are installed by default (they are in 'base' and 'base-devel' groups). If you need specific library, then your question would be 'I need library XXX, is it available in Arch'? That question would lead you to packages.archlinux.org and (as an option) aur.archlinux.org. These are "official sites" where there is 99% probability you can get desired specific "c library".

Again, the question "how I can program in C in archlinux?" is ill-posed question. Archlinux does not deviate from any relevant standard of C programming, so any information regarding C programming in linux/unix is applicable in arch. Tl;dr you should consult C forum.

Offline

Board footer

Powered by FluxBB