2017-11-23 3 views
0

Ich versuche CUPS API Entwicklung zu lernen. Dafür habe ich CUPS 2.1.3-4 in meinem Ubuntu 16.04 installiert.CUPS undefined Verweis auf cupsGetDests()

Wenn ich versuche, ihr erstes Tutorial auszuführen, erhalte ich folgende Fehlermeldung.

||=== Build: Debug in cupsfirst (compiler: GNU GCC Compiler) ===| obj/Debug/main.o||In function main':| /home/xxxx/CUPS/cupsfirst/main.c|8|undefined reference to cupsGetDests'| ||error: ld returned 1 exit status| ||=== Build failed: 2 error(s), 0 warning(s) (0 minute(s), 0 second(s)) ===|

Dies ist mein erstes Programm.

#include <stdio.h> 
#include <cups/cups.h> 

int main(void) 
{ 
    int i; 
    cups_dest_t *dests, *dest; 
    int num_dests = cupsGetDests(&dests); 

    for (i = num_dests, dest = dests; i > 0; i --, dest ++) 
    { 
    if (dest->instance) 
     printf("%s/%s\n", dest->name, dest->instance); 
    else 
     puts(dest->name); 
    } 

    return (0); 
} 

Antwort

1

Sie benötigen die CUPS-Bibliothek, die dev-Paket zu installieren (Sie haben es schon nehme ich an)

apt install libcups2 libcups2-dev 

zu kompilieren dann Link, schließen die cups2 Bibliothek

gcc myprog.c -o myprog -lcups 
+0

Ja, 'gcc myprog.c -o myprog -lcups' hat funktioniert. – Sachith

+0

War mir nicht sicher, danke! –