LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 02-09-2023, 03:40 PM   #1
jmgibson1981
Senior Member
 
Registered: Jun 2015
Location: Tucson, AZ USA
Distribution: Debian
Posts: 1,140

Rep: Reputation: 392Reputation: 392Reputation: 392Reputation: 392
Angry Expanding my C usage.


I'm stuck on libraries. I know there are countless libraries out there. I know they contain functions that can be dynamically linked to to utilize them and not reinvent the wheel. I know how to get some output from
Code:
nm
None of this helps me to know how am I supposed to find the proper libary for a given thing I'm doing, if it exists. Is there no other way than looking at git pages or something directly at the code? In which case is it sheer dumb luck stumbling on the proper library i'm looking for?

Google is zero help. Countless results on how to link to libraries, where they are, how they work (to a degree) but I have found nada on how to search libraries overall to find if the function i need already exists somewhere. And in which library it exists.
 
Old 02-09-2023, 03:59 PM   #2
NevemTeve
Senior Member
 
Registered: Oct 2011
Location: Budapest
Distribution: Debian/GNU/Linux, AIX
Posts: 4,856
Blog Entries: 1

Rep: Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869
Try to describe the desired functionality and ask google. E.g.:https://www.google.com/search?q=C+find+string+in+string
 
1 members found this post helpful.
Old 02-09-2023, 05:34 PM   #3
EdGr
Member
 
Registered: Dec 2010
Location: California, USA
Distribution: I run my own OS
Posts: 997

Rep: Reputation: 470Reputation: 470Reputation: 470Reputation: 470Reputation: 470
jmgibson - Your distro has made finding library functions difficult by not installing headers or documentation by default. Install them for the libraries that you are interested in.
Ed
 
1 members found this post helpful.
Old 02-09-2023, 08:35 PM   #4
jmgibson1981
Senior Member
 
Registered: Jun 2015
Location: Tucson, AZ USA
Distribution: Debian
Posts: 1,140

Original Poster
Rep: Reputation: 392Reputation: 392Reputation: 392Reputation: 392
I think you misunderstand. I don't know which libraries I would want. I can man page them but is there NY quick way to narrow that down. There seems to be no central place t9 search for given functions

*EDIT 5 mins later *

Unless I can search via apropos and that will get me started... thank you for the insight. Maybe not what I wanted but got me thinking about the man pages again.

Last edited by jmgibson1981; 02-09-2023 at 08:37 PM.
 
Old 02-09-2023, 09:47 PM   #5
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,356

Rep: Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751
apropos searches the man pages ok, but if you install the assoc headers src files and docs, you can grep through those...
Could be quicker.

Also, if you ls the dirs those are in, you can often just spot the most likely candidate from the name eg 'math.h' is the first place to look for maths fns etc.
 
1 members found this post helpful.
Old 02-09-2023, 10:01 PM   #6
jmgibson1981
Senior Member
 
Registered: Jun 2015
Location: Tucson, AZ USA
Distribution: Debian
Posts: 1,140

Original Poster
Rep: Reputation: 392Reputation: 392Reputation: 392Reputation: 392
Okay thank you. That helps a great deal. I supposed it would be damn near impossible to create a searchable db of all the libs out there. But all 3 of you have helped. With the idea to look by general type I can just apt search (or whatever a given distro does) to find generally what I'm looking for. In the case of Debian + derivatives I can just apt source the dev pkg and dig through it.

Thank you all very much. Long way to go but loving every minute of it... even with the occasional frustrations.
 
Old 02-10-2023, 12:09 AM   #7
NevemTeve
Senior Member
 
Registered: Oct 2011
Location: Budapest
Distribution: Debian/GNU/Linux, AIX
Posts: 4,856
Blog Entries: 1

Rep: Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869
One could learn a lot from `info libc` (or `tkinfo libc` in GUI).
 
Old 02-10-2023, 05:01 AM   #8
hazel
LQ Guru
 
Registered: Mar 2016
Location: Harrow, UK
Distribution: LFS, AntiX, Slackware
Posts: 7,567
Blog Entries: 19

Rep: Reputation: 4447Reputation: 4447Reputation: 4447Reputation: 4447Reputation: 4447Reputation: 4447Reputation: 4447Reputation: 4447Reputation: 4447Reputation: 4447Reputation: 4447
You could try skimming through Linux From Scratch and Beyond Linux From Scratch. The BLFS contents list would be particularly useful for this kind of thing as it has the software organised by type, e.g.security, graphics, networking...
 
Old 02-12-2023, 05:12 PM   #9
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 10,649
Blog Entries: 4

Rep: Reputation: 3934Reputation: 3934Reputation: 3934Reputation: 3934Reputation: 3934Reputation: 3934Reputation: 3934Reputation: 3934Reputation: 3934Reputation: 3934Reputation: 3934
The choice of libraries is simply a "design choice" that you must somehow make while creating your application. While there are sometimes multiple choices, in most cases just a few have become "reliable, cross-platform, 'industry standards.'"

Each library comes with both binaries and a set of header files to describe its use.

"But Also!! ... ... Always remember the admonition to "do not do a thing already done!" You will usually be able to find some software package which "insulates you" from having to interact with your chosen library directly. These libraries will "abstract away" at least some of the messy details of "using a binary library correctly."

It is today a very reliable "rule of thumb" to presume(!) that whatever-it-is you are trying to do is: "a thing already done." Always think outside the box and do not write any more "original source code" than you have to.

As Perl programmers like to say: "Tim Toady" = TMTOWTDI = There's More Than One Way To Do It." For instance, if you need to process an XML file, there are already-perfected "Pure Perl" libraries that will do that. But the usual way to do that is to use binary libraries – "libxml2" or "SAX." And the Perl language provides already-perfected "wrappers" for both which let you completely ignore how it is all done. Other languages which appear to "build in" support for XML use these libraries behind the scenes. No matter what is the language, somewhere you will find a good "wrapper" to do the dirty work for you.

Last edited by sundialsvcs; 02-13-2023 at 08:12 AM.
 
Old 02-12-2023, 06:36 PM   #10
rtmistler
Moderator
 
Registered: Mar 2011
Location: USA
Distribution: MINT Debian, Angstrom, SUSE, Ubuntu, Debian
Posts: 9,883
Blog Entries: 13

Rep: Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930
Maybe you just haven't organized your ways to look things up.

Example search for "strstr manpage"

You find manpages for strstr.

But read those:
  1. First thing is it tells you what library, a.k.a. include file(s) you need to use for it
  2. Next it tells you about that function, how to call it, the arguments for it, and the expected return of it
  3. Next there's usually a "See Also" section where is show related functions
Virtually all C library functions have a man page and additional information about them.

There's no right answer, learn what benefits you and your most recent efforts.
 
Old 02-13-2023, 08:15 AM   #11
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 10,649
Blog Entries: 4

Rep: Reputation: 3934Reputation: 3934Reputation: 3934Reputation: 3934Reputation: 3934Reputation: 3934Reputation: 3934Reputation: 3934Reputation: 3934Reputation: 3934Reputation: 3934
FYI: Virtually every program written in any compiled language is created to make extensive calls to a usually-dynamic "runtime library." For Linux "C" that library is glibc. In a Microsoft environment it is MSVCRTxx.DLL. While it is usually possible to "static-link" a program so that it has no runtime dependencies at all, this is almost never done. When a dynamic library is loaded by one process, its virtual-memory resources are shared by all of them, greatly reducing the memory footprint.
 
Old 02-13-2023, 08:43 AM   #12
NevemTeve
Senior Member
 
Registered: Oct 2011
Location: Budapest
Distribution: Debian/GNU/Linux, AIX
Posts: 4,856
Blog Entries: 1

Rep: Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869
Mind you, the nowadays trendy versioned symbols present a very good reason to link statically. (Sure, they are meant to solve compatibility problems. By causing more serious compatibility problems. Clever.)

Edit: I thought it was just me, but just now I've found this: http://harmful.cat-v.org/software/dy...sioned-symbols

Last edited by NevemTeve; 02-13-2023 at 08:44 AM.
 
1 members found this post helpful.
Old 02-13-2023, 10:58 PM   #13
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,356

Rep: Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751
Your own system is the definitive info for what's on it, but this is handy for a quick search and easier on the eyes (imho) https://linux.die.net/man/
 
Old 02-14-2023, 12:11 AM   #14
astrogeek
Moderator
 
Registered: Oct 2008
Distribution: Slackware [64]-X.{0|1|2|37|-current} ::12<=X<=15, FreeBSD_12{.0|.1}
Posts: 6,263
Blog Entries: 24

Rep: Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194
Quote:
Originally Posted by NevemTeve View Post
I thought it was just me, but just now I've found this: http://harmful.cat-v.org/software/dy...sioned-symbols
Thank you very much for ruining my day! I was blissfully unaware of any of that...
 
1 members found this post helpful.
Old 02-14-2023, 07:51 AM   #15
jmgibson1981
Senior Member
 
Registered: Jun 2015
Location: Tucson, AZ USA
Distribution: Debian
Posts: 1,140

Original Poster
Rep: Reputation: 392Reputation: 392Reputation: 392Reputation: 392
I am grateful to all of you for your suggestions. It definitely helps. Thank you all.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] trouble expanding 4+TB GPT partition after expanding hardware RAID-5 volume muad'dib Linux - Enterprise 6 09-26-2009 05:01 PM
how to determine cpu usage, memory usage, I/O usage by a particular user logged on li rags2k Programming 4 08-21-2004 04:45 AM
Expanding a partition echid Linux - General 1 08-12-2002 10:21 AM
need help expanding a partition linuxmaster Linux - General 2 12-01-2001 03:25 PM
A project i want to take up: expanding off of blackbox! bb-boy Linux - General 4 11-20-2001 02:37 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 03:53 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration