ss7m / paleofetch

neofetch, but written in C
MIT License
168 stars 49 forks source link

Bug - Cannot compile. pci library isn't found #25

Closed ghost closed 4 years ago

ghost commented 4 years ago

Whenever I run make, it refuses to find pci/pci.h

Here's my output

cc paleofetch.c -o paleofetch -O3 -Wall -Wextra -lX11 -lpci
paleofetch.c:10:10: fatal error: pci/pci.h: No such file or directory
 #include <pci/pci.h>
          ^~~~~~~~~~~
compilation terminated.
make: *** [Makefile:10: paleofetch] Error 1

And pciutils is installed.

ss7m commented 4 years ago

On my machine replacing that include statement with either

#include <sys/pci.h>

or

#include <linux/pci.h>

causes it to not compile, I think there are significant differences between these various pci.h headers.

ss7m commented 4 years ago

What distro are you running?

pacman -Qo /usr/include/pci/pci.h

tells me that header is from the pciutils package

ghost commented 4 years ago

I'm running Debian 10.

I tried changing it to sys/pci.h but that juse gives me a flood warnings

paleofetch.c: In function ‘get_terminal’:
paleofetch.c:304:20: warning: unused variable ‘prop’ [-Wunused-variable]
     unsigned char *prop;
                    ^~~~
paleofetch.c: In function ‘get_gpu’:
paleofetch.c:376:12: warning: implicit declaration of function ‘pci_alloc’; did you mean ‘calloc’? [-Wimplicit-function-declaration]
     pacc = pci_alloc();
            ^~~~~~~~~
            calloc
paleofetch.c:376:10: warning: assignment to ‘struct pci_access *’ from ‘int’ makes pointer from integer without a cast [-Wint-conversion]
     pacc = pci_alloc();
          ^
paleofetch.c:377:5: warning: implicit declaration of function ‘pci_init’ [-Wimplicit-function-declaration]
     pci_init(pacc);
     ^~~~~~~~
paleofetch.c:378:5: warning: implicit declaration of function ‘pci_scan_bus’ [-Wimplicit-function-declaration]
     pci_scan_bus(pacc);
     ^~~~~~~~~~~~
paleofetch.c:379:15: error: dereferencing pointer to incomplete type ‘struct pci_access’
     dev = pacc->devices;
               ^~
paleofetch.c:382:9: warning: implicit declaration of function ‘pci_fill_info’ [-Wimplicit-function-declaration]
         pci_fill_info(dev, PCI_FILL_IDENT);
         ^~~~~~~~~~~~~
paleofetch.c:382:28: error: ‘PCI_FILL_IDENT’ undeclared (first use in this function); did you mean ‘PCI_MIN_GNT’?
         pci_fill_info(dev, PCI_FILL_IDENT);
                            ^~~~~~~~~~~~~~
                            PCI_MIN_GNT
paleofetch.c:382:28: note: each undeclared identifier is reported only once for each function it appears in
paleofetch.c:383:48: warning: implicit declaration of function ‘pci_lookup_name’ [-Wimplicit-function-declaration]
         if(strcmp("VGA compatible controller", pci_lookup_name(pacc, buffer, sizeof(buffer), PCI_LOOKUP_CLASS, dev->device_class)) == 0) {
                                                ^~~~~~~~~~~~~~~
paleofetch.c:383:94: error: ‘PCI_LOOKUP_CLASS’ undeclared (first use in this function); did you mean ‘PCI_EXP_FLAGS’?
         if(strcmp("VGA compatible controller", pci_lookup_name(pacc, buffer, sizeof(buffer), PCI_LOOKUP_CLASS, dev->device_class)) == 0) {
                                                                                              ^~~~~~~~~~~~~~~~
                                                                                              PCI_EXP_FLAGS
paleofetch.c:383:115: error: dereferencing pointer to incomplete type ‘struct pci_dev’
         if(strcmp("VGA compatible controller", pci_lookup_name(pacc, buffer, sizeof(buffer), PCI_LOOKUP_CLASS, dev->device_class)) == 0) {
                                                                                                                   ^~
paleofetch.c:384:72: error: ‘PCI_LOOKUP_DEVICE’ undeclared (first use in this function); did you mean ‘PCI_CLASS_DEVICE’?
             strncpy(gpu, pci_lookup_name(pacc, buffer, sizeof(buffer), PCI_LOOKUP_DEVICE | PCI_LOOKUP_VENDOR, dev->vendor_id, dev->device_id), BUF_SIZE);
                                                                        ^~~~~~~~~~~~~~~~~
                                                                        PCI_CLASS_DEVICE
paleofetch.c:384:92: error: ‘PCI_LOOKUP_VENDOR’ undeclared (first use in this function); did you mean ‘PCI_CAP_ID_VNDR’?
             strncpy(gpu, pci_lookup_name(pacc, buffer, sizeof(buffer), PCI_LOOKUP_DEVICE | PCI_LOOKUP_VENDOR, dev->vendor_id, dev->device_id), BUF_SIZE);
                                                                                            ^~~~~~~~~~~~~~~~~
                                                                                            PCI_CAP_ID_VNDR
paleofetch.c:394:5: warning: implicit declaration of function ‘pci_cleanup’ [-Wimplicit-function-declaration]
     pci_cleanup(pacc);
     ^~~~~~~~~~~

and linux/pci.h gives me the same.

ss7m commented 4 years ago

On Debian it looks like you might have to install libpci separately. It doesn't look like sys/pci.h or linux/pci.h are viable options. I'll try and make this more clear in the README

dwzg commented 4 years ago

Install libpci-dev and libx11-dev to get it running.

ghost commented 4 years ago

Install libpci-dev and libx11-dev to get it running.

Thanks. That made it work.