Finding path of static system libraries in Linux - linux

I am compiling a package that links against the OpenSSL static libraries libssl.a and libcrypto.a which are included with libssl-dev in Debian/Ubuntu. However the actual location of these files depends on the architecture and distribution at hand.
Is there some sort of method or environment variable that I can use in the Makefile to give the linker the correct path to the system directory with static libraries? Currently I am using:
-L/usr/lib/x86_64-linux-gnu/ -L/usr/lib/i686-linux-gnu/ -lssl -lcrypto
However this gives a bunch of warnings if these dirs do not exist, and might still not generally work.

If you are sure, that your users are using aptitude as package manager, that is default for Debian/Ubuntu, than you can use apt-file to locate libraries.
$ apt-file update
$ LIBSSL_PATH=`apt-file list libssl-dev | grep libssl.a | awk '{ print $2 }'`
$ LIBCRYPTO_PATH=`apt-file list libssl-dev | grep libcrypto.a | awk '{ print $2 }'`
Next you may use them. Say on my machine:
$ echo $LIBSSL_PATH
/usr/lib/libssl.a
I known no other way and doubt if any exists.

I was struggling with the same for my ubuntu machine.
I was able to find the library by using the following command.
sudo find libssl.a / | grep libssl.a
The default location for ubuntu is.
/usr/lib/x86_64-linux-gnu/libssl.a

Related

can't find curl-config on NixOS

I'm trying to install vim-now-haskell on NixOS 17.09.
The installation fails with the exception
*** Installer requires 'curl-config'. Please install and try again.
*** Aborting...
Unfortunately Search NixOS packages doesn't list any package for curl-config. It also isn't in installed curl-7.56.1.
I can hardly believe NixOS doesn't provide curl-config. Therefore I'm looking here for help to find it.
It's in the curl.dev output.
$ ls $(nix-build --no-out-link '<nixpkgs>' -A curl.dev)/bin
curl-config
The reason for this is to keep the closure size of anything the uses curl small. Normally Nixpkgs' stdenv.mkDerivation takes care of those details when processing the buildInputs attribute, but if you're not using Nixpkgs to build something you may have to do a bit more manual work.
Another way to get the curl-config command is nix-shell -p curl, which launches a shell that has the command in its environment.
[user#feb:~]$ nix-shell -p curl
[nix-shell:~]$ curl-config --version
libcurl 7.65.3
[nix-shell:~]$ exit
[user#feb:~]$
NixPkgs also has a curlFull package which has more features enabled, as can be seen by the number of packages in the closure of the runtime library output:
$ nix-store -q --requisites $(nix-build --no-out-link '<nixpkgs>' -A curl.out) | wc -l
6
$ nix-store -q --requisites $(nix-build --no-out-link '<nixpkgs>' -A curlFull.out) | wc -l
29
So for a more capable build of curl, use curlFull.dev.

Nix shell: How to list the installed Haskell package versions

As a non-nix'er I installed the newest version of https://github.com/reflex-frp/reflex-platform. I think working in this nix-shell is a nice experience.
Now I want to know which Haskell packages in which versions are installed and used in this shell. After some googling I found a nix-env command in the following form:
nix-env -f '<nixpkgs>' -qaPA haskellPackages|grep reflex-dom
This command gives me the version of reflex-dom as reflex-dom-0.3. But I know from here that in my nix shell I use the newest version 0.4 of reflex-dom. So I assume the above command just lists the available Hackage packages.
What is the correct nix-env -q command to get only the installed Haskell packages and its versions?.
(I played with the --installed option, however I never got something back)
You can try to nix-store -q --references $out after you entered the shell. This will, however, mix both haskell and non-haskell dependencies in output.
This is a complete example with filter applied:
$ nix-store -q --references $out \
| while read p; do du -a $p | grep -q ghc && echo $p; done

How to view all installed packages in terminal (Ubuntu)

Need to view all the packages installed on my system through terminal.
I am using ubuntu 16.10
# dpkg -l
From dpkg manual:
dpkg-query actions
See dpkg-query(1) for more information about the following actions.
-l, --list package-name-pattern...
List packages matching given pattern.
-s, --status package-name...
Report status of specified package.
-L, --listfiles package-name...
List files installed to your system from package-name.
-S, --search filename-search-pattern...
Search for a filename from installed packages.
-p, --print-avail package-name...
Display details about package-name, as found in
/var/lib/dpkg/available. Users of APT-based frontends
should use apt-cache show package-name instead.
To list packages installed only by you:
gunzip -c /var/log/apt/history.log.*.gz | grep 'apt-get install' | cut -f4- -d" " | tr ' ' $'\n' | sort -u
Solution: In order to view all installed packages in linux Ubuntu, run on terminal apt --installed list,
Use apt flags and would be able to see available upgrades to some packages ( --upgradeable ) / current installed packages ( --installed ) / all available versions ( --all-versions ).
From Documentation:
DESCRIPTION
apt provides a high-level commandline interface for the package management system.
It is intended as an end user interface and enables some options better suited for interactive usage by
default compared to more specialized APT tools like apt-get(8) and apt-cache(8).
Much like apt itself, its manpage is intended as an end user interface and as such only mentions the most
used commands and options partly to not duplicate information in multiple places and
partly to avoid overwhelming readers with a cornucopia of options and details.
the list flag offers 3 options:
list (work-in-progress)
list is somewhat similar to dpkg-query --list in that it can display a
list of packages satisfying certain criteria. It supports glob(7)
patterns for matching package names as well as
options to list installed (--installed), upgradeable (--upgradeable) or
all available (--all-versions) versions.
command to list all installed packages
sudo apt list --installed
you can add 'grep' to find your service as below:
sudo apt list --installed | grep <my_service_name>
I used the following Three Cmd Syntaxes & tested them to List installed packages on My ubuntu Subsystem machine from VB6 Shell() function and 2 of them Worked fine:
1- Syntax-#1:[ Worked ]
sudo apt list --installed
2- Syntax-#2:[ Worked ]
sudo dpkg -l
Syntax-#3: [ Do not Worked .. for me ]
sudo dpkg -l | grep -i apache
And Here is MY VB6 - Code List:
Private Sub Command1_Click()
Dim Id3 As Variant ' 1- Syntax-#1: Worked fine:
Id3 = Shell(App.Path & "\bash.exe | sudo apt list --installed", vbNormalFocus)
' 2- Syntax-#2: Worked Also: ' Id3 = Shell(App.Path & "\bash.exe
| sudo dpkg -l", vbNormalFocus)
' 3- Syntax-#3: Does not show output ... Why .. Dont know now: '
Id3 = Shell(App.Path & "\bash.exe | sudo dpkg -l | grep -i apache",
vbNormalFocus) End Sub**

Remove packages contain specific word in name

In Linux (Fedora), how I see all the installed packages which contain a certain words in the package name. Then, remove all these packages installed.
Assuming you are using a debian-based Linux (like Ubuntu or Mint, for example), you can do like this to search for mysq:
dpkg -l | grep mysq
and to get only the names
dpkg -l | grep mysq | awk '{print $2}'
if you want remove all packages, containing a specific word, you don't need to pipe lists through grep or whatever. Just type
$ sudo yum remove "*word*"
If you want to review list of such packages before removing, then type
$ rpm -qa "*word*"
That's it.
Fedora is an RPM-based distribution. So you'll want to use the rpm or yum commands.
To list installed: yum list installed | grep <name> or rpm -a | grep <name>
To remove a package: rpm -e <package-name> or yum remove <package-name>
Sources:
Fedora RPM Guide
Fedora yum wiki
in linux, you can install programs in a variety of places. Most of the time, your rpm on your distro is responsible for removing all of the bits and pieces of a program. One solution, although this is fraught with danger, is to grep your usr/bin like this:
ls /usr/bin || grep 'some package name'
and pipe that to an rm-rf ... 'shuddurs'
A safer bet though is to just use apt-get uninstall 'someApp' much safter

Without admin prevlieges, how do I find the directories searched by ld?

How do I find the directories searched in by the GNU linker, without admin privileges?
I can get the listing in the following way:
$ sudo ldconfig -v 2>/dev/null | grep -v ^$'\t'
/lib/i386-linux-gnu:
/usr/lib/i386-linux-gnu:
/usr/local/lib:
/lib/x86_64-linux-gnu:
/usr/lib/x86_64-linux-gnu:
/usr/lib/fglrx:
/usr/lib32/fglrx:
/lib32:
/usr/lib32:
/lib:
/usr/lib:
/usr/lib/i386-linux-gnu/sse2: (hwcap: 0x0000000004000000)
this solution came from: How to print the ld(linker) search path
However, on a machine where I do not have admin privileges, this will not work. I assume that’s because ldconfig is located in /sbin/. I download glibc and installed it locally to create another version of ldconfig. I guess that was silly though because the local version gives me:
/usr/local/lib:
/usr/local/lib64:
Is it still possible to get all the directories as a non-admin?
There doesn't appear to be any helpful ld flags, or environment variables to do the job.
Just because ldconfig is in sbin doesn't mean it can't be run as a normal user. Simply use that command and specify the full path to ldconfig:
/sbin/ldconfig -v 2>/dev/null | grep -v ^$'\t'

Resources