G++ libaries

How do I get g++ to recognize a library i’ve installed with pacman?

System:
Kernel: 6.8.1-zen1-1-zen arch: x86_64 bits: 64 compiler: gcc v: 13.2.1
clocksource: tsc avail: hpet,acpi_pm
parameters: BOOT_IMAGE=/@/boot/vmlinuz-linux-zen
root=UUID=4aac3ebc-374d-4e7c-9d1b-629c23010d90 rw rootflags=subvol=@
quiet loglevel=3 ibt=off
Desktop: KDE Plasma v: 6.0.2 tk: Qt v: N/A info: frameworks v: 6.0.0
wm: kwin_wayland vt: 1 dm: SDDM Distro: Garuda base: Arch Linux
Machine:
Type: Desktop System: Gigabyte product: B550 AORUS ELITE v: N/A
serial: <superuser required>
Mobo: Gigabyte model: B550 AORUS ELITE v: x.x serial: <superuser required>
uuid: <superuser required> BIOS: American Megatrends v: F10 date: 09/18/2020
CPU:
Info: model: AMD Ryzen 7 3700X bits: 64 type: MT MCP arch: Zen 2 gen: 3
level: v3 note: check built: 2020-22 process: TSMC n7 (7nm)
family: 0x17 (23) model-id: 0x71 (113) stepping: 0 microcode: 0x8701021
Topology: cpus: 1x cores: 8 tpc: 2 threads: 16 smt: enabled cache:
L1: 512 KiB desc: d-8x32 KiB; i-8x32 KiB L2: 4 MiB desc: 8x512 KiB
L3: 32 MiB desc: 2x16 MiB
Speed (MHz): avg: 3641 high: 4286 min/max: 2200/4426 boost: enabled
scaling: driver: acpi-cpufreq governor: performance cores: 1: 3600 2: 3600
3: 3600 4: 3600 5: 3600 6: 3600 7: 3600 8: 3600 9: 3600 10: 3600 11: 3582
12: 3600 13: 3600 14: 3600 15: 4286 16: 3600 bogomips: 114989
Flags: avx avx2 ht lm nx pae sse sse2 sse3 sse4_1 sse4_2 sse4a ssse3 svm
Vulnerabilities: <filter>
Graphics:
Device-1: NVIDIA TU104 [GeForce RTX 2070 SUPER] vendor: eVga.com.
driver: nvidia v: 550.54.14 alternate: nouveau,nvidia_drm non-free: 545.xx+
status: current (as of 2024-02; EOL~2026-12-xx) arch: Turing code: TUxxx
process: TSMC 12nm FF built: 2018-2022 pcie: gen: 1 speed: 2.5 GT/s
lanes: 16 link-max: gen: 3 speed: 8 GT/s ports: active: none off: DP-3
empty: DP-1, DP-2, HDMI-A-1, Unknown-2 bus-ID: 0a:00.0 chip-ID: 10de:1e84
class-ID: 0300
Display: wayland server: X.org v: 1.21.1.11 with: Xwayland v: 23.2.4
compositor: kwin_wayland driver: X: loaded: nvidia
unloaded: modesetting,nouveau alternate: fbdev,nv,vesa gpu: nvidia
display-ID: 0
Monitor-1: DP-3 res: 1920x1080 size: N/A modes: N/A
API: EGL v: 1.5 hw: drv: nvidia platforms: device: 0 drv: nvidia device: 2
drv: swrast gbm: drv: nvidia surfaceless: drv: nvidia wayland: drv: nvidia
x11: drv: zink inactive: device-1
API: OpenGL v: 4.6.0 compat-v: 4.5 vendor: nvidia mesa v: 550.54.14
glx-v: 1.4 direct-render: yes renderer: NVIDIA GeForce RTX 2070
SUPER/PCIe/SSE2 memory: 7.81 GiB display-ID: :1.0
API: Vulkan v: 1.3.279 layers: 15 device: 0 type: discrete-gpu name: NVIDIA
GeForce RTX 2070 SUPER driver: nvidia v: 550.54.14 device-ID: 10de:1e84
surfaces: xcb,xlib,wayland device: 1 type: discrete-gpu name: NVIDIA
GeForce RTX 2070 SUPER driver: nvidia v: 550.54.14 device-ID: 10de:1e84
surfaces: xcb,xlib,wayland device: 2 type: cpu name: llvmpipe (LLVM
17.0.6 256 bits) driver: mesa llvmpipe v: 24.0.3-arch1.1 (LLVM 17.0.6)
device-ID: 10005:0000 surfaces: xcb,xlib,wayland
Audio:
Device-1: NVIDIA TU104 HD Audio vendor: eVga.com. driver: snd_hda_intel
v: kernel pcie: gen: 3 speed: 8 GT/s lanes: 16 bus-ID: 0a:00.1
chip-ID: 10de:10f8 class-ID: 0403
Device-2: AMD Starship/Matisse HD Audio vendor: Gigabyte
driver: snd_hda_intel v: kernel pcie: gen: 4 speed: 16 GT/s lanes: 16
bus-ID: 0c:00.4 chip-ID: 1022:1487 class-ID: 0403
Device-3: HP HyperX SoloCast driver: hid-generic,snd-usb-audio,usbhid
type: USB rev: 1.1 speed: 12 Mb/s lanes: 1 mode: 1.1 bus-ID: 1-3:3
chip-ID: 03f0:078b class-ID: 0300
Device-4: Razer USA BlackShark V2 Pro
driver: hid-generic,snd-usb-audio,usbhid type: USB rev: 1.1 speed: 12 Mb/s
lanes: 1 mode: 1.1 bus-ID: 1-9:7 chip-ID: 1532:0528 class-ID: 0300
API: ALSA v: k6.8.1-zen1-1-zen status: kernel-api with: aoss
type: oss-emulator tools: N/A
Server-1: PipeWire v: 1.0.4 status: active with: 1: pipewire-pulse
status: active 2: wireplumber status: active 3: pipewire-alsa type: plugin
4: pw-jack type: plugin tools: pactl,pw-cat,pw-cli,wpctl
Network:
Device-1: Realtek RTL8125 2.5GbE vendor: Gigabyte driver: r8169 v: kernel
pcie: gen: 2 speed: 5 GT/s lanes: 1 port: f000 bus-ID: 08:00.0
chip-ID: 10ec:8125 class-ID: 0200
IF: eno1 state: up speed: 1000 Mbps duplex: full mac: <filter>
Info: services: NetworkManager, smbd, systemd-timesyncd
Drives:
Local Storage: total: 1.36 TiB used: 41.61 GiB (3.0%)
SMART Message: Unable to run smartctl. Root privileges required.
ID-1: /dev/nvme0n1 maj-min: 259:0 vendor: Samsung model: SSD 980 PRO 500GB
size: 465.76 GiB block-size: physical: 512 B logical: 512 B speed: 63.2 Gb/s
lanes: 4 tech: SSD serial: <filter> fw-rev: 3B2QGXA7 temp: 45.9 C
scheme: MBR
ID-2: /dev/nvme1n1 maj-min: 259:2 vendor: Samsung
model: SSD 970 EVO Plus 500GB size: 465.76 GiB block-size: physical: 512 B
logical: 512 B speed: 31.6 Gb/s lanes: 4 tech: SSD serial: <filter>
fw-rev: 2B2QEXM7 temp: 29.9 C scheme: GPT
ID-3: /dev/sda maj-min: 8:0 vendor: Samsung model: SSD 860 EVO 500GB
size: 465.76 GiB block-size: physical: 512 B logical: 512 B speed: 6.0 Gb/s
tech: SSD serial: <filter> fw-rev: 4B6Q scheme: GPT
Partition:
ID-1: / raw-size: 465.76 GiB size: 465.76 GiB (100.00%)
used: 41.61 GiB (8.9%) fs: btrfs dev: /dev/nvme0n1p1 maj-min: 259:1
ID-2: /home raw-size: 465.76 GiB size: 465.76 GiB (100.00%)
used: 41.61 GiB (8.9%) fs: btrfs dev: /dev/nvme0n1p1 maj-min: 259:1
ID-3: /var/log raw-size: 465.76 GiB size: 465.76 GiB (100.00%)
used: 41.61 GiB (8.9%) fs: btrfs dev: /dev/nvme0n1p1 maj-min: 259:1
ID-4: /var/tmp raw-size: 465.76 GiB size: 465.76 GiB (100.00%)
used: 41.61 GiB (8.9%) fs: btrfs dev: /dev/nvme0n1p1 maj-min: 259:1
Swap:
Kernel: swappiness: 133 (default 60) cache-pressure: 100 (default) zswap: no
ID-1: swap-1 type: zram size: 31.28 GiB used: 0 KiB (0.0%) priority: 100
comp: zstd avail: lzo,lzo-rle,lz4,lz4hc,842 max-streams: 16 dev: /dev/zram0
Sensors:
System Temperatures: cpu: 60.6 C mobo: 43.0 C
Fan Speeds (rpm): N/A
Info:
Memory: total: 32 GiB available: 31.28 GiB used: 8.5 GiB (27.2%)
Processes: 434 Power: uptime: 6h 49m states: freeze,mem,disk suspend: deep
avail: s2idle wakeups: 0 hibernate: platform avail: shutdown, reboot,
suspend, test_resume image: 12.47 GiB services: org_kde_powerdevil,
power-profiles-daemon, upowerd Init: systemd v: 255 default: graphical
tool: systemctl
Packages: pm: dpkg pkgs: 0 tools: apt,apt-get,gnome-software pm: pacman
pkgs: 2100 libs: 570 tools: octopi,paru Compilers: clang: 17.0.6 gcc: 13.2.1
Shell: garuda-inxi default: fish v: 3.7.0 running-in: konsole inxi: 3.3.33
Garuda (2.6.23-1):
System install date:     2024-03-15
Last full system update: 2024-03-18 ↻
Is partially upgraded:   No
Relevant software:       snapper NetworkManager dracut nvidia-dkms
Windows dual boot:       <superuser required>
Failed units:

If you have read the template this is not a general technical help forum. Something like this can be easily solved with a very basic google search.

If pacman has installed them in the usual place the g++ expects libraries to be like /usr/lib or some such default directory then you don’t have to do anything. However if they are installed in a special directory. Like the avr libs are installed in /usr/avr this is obviously non standard and g++ doesn’t know about this it needs to be pointed to these headers and libs.

To view what file is kept where do a,

pacman -Ql pkgname

This will give you path of every file this package installed in your system.

The easiest way to maintain such special directories would be to write a cmake file for including them. If you don’t want to you can directly just pass them to g++ using flags from command line. For example,

g++ cppfile.cpp -I/path/to/headers

this tells g++ to look for headers in places other than standard paths (/usr/include). There are similarly more such flags to tell g++ to look for libraries in paths other than standard path (/usr/lib) and link them in a project yes you need to tell compiler to link your non standard libs search for them with any search engine.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.