C LibHaru 对 <functions> 的引用未定义

C LibHaru reference to <functions> not defined

我需要在一个项目中使用 LibHaru,我已经下载并安装了它,configure 和 make 运行良好。但是现在,当我尝试在代码中使用它时无法识别这些函数。

我正在尝试 Linux Mint 发行版。 HPDF_Doc、页面和字体被识别。

# This is a template Makefile generated by rpcgen

# Parameters

CLIENT = vuelos_client
SERVER = vuelos_server

SOURCES_CLNT.c = 
SOURCES_CLNT.h = 
SOURCES_SVC.c = 
SOURCES_SVC.h = 
SOURCES.x = vuelos.x

TARGETS_SVC.c = vuelos_svc.c vuelos_server.c vuelos_xdr.c 
TARGETS_CLNT.c = vuelos_clnt.c vuelos_client.c vuelos_xdr.c 
TARGETS = vuelos.h vuelos_xdr.c vuelos_clnt.c vuelos_svc.c vuelos_client.c vuelos_server.c

OBJECTS_CLNT = $(SOURCES_CLNT.c:%.c=%.o) $(TARGETS_CLNT.c:%.c=%.o)
OBJECTS_SVC = $(SOURCES_SVC.c:%.c=%.o) $(TARGETS_SVC.c:%.c=%.o)
# Compiler flags 

CFLAGS += -g 
LDLIBS += -lnsl
RPCGENFLAGS = 

# Targets 

all : $(CLIENT) $(SERVER)

$(TARGETS) : $(SOURCES.x) 
    rpcgen $(RPCGENFLAGS) $(SOURCES.x)

$(OBJECTS_CLNT) : $(SOURCES_CLNT.c) $(SOURCES_CLNT.h) $(TARGETS_CLNT.c) 

$(OBJECTS_SVC) : $(SOURCES_SVC.c) $(SOURCES_SVC.h) $(TARGETS_SVC.c) 

$(CLIENT) : $(OBJECTS_CLNT) 
    $(LINK.c) -o $(CLIENT) $(OBJECTS_CLNT) $(LDLIBS) 

$(SERVER) : $(OBJECTS_SVC) 
    $(LINK.c) -o $(SERVER) $(OBJECTS_SVC) $(LDLIBS)

 clean:
     $(RM) core $(TARGETS) $(OBJECTS_CLNT) $(OBJECTS_SVC) $(CLIENT) $(SERVER)
#include "hpdf.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <setjmp.h>
#include <math.h>
 
jmp_buf env;
 
#ifdef HPDF_DELL
void __stdcall
#else
void
#endif
 
error_handler (HPDF_STATUS error_no, HPDF_STATUS detail_no, void *user_data) {
    printf("ERROR: error_no=%04X, detail_no=%u\n", (HPDF_UINT)error_no, (HPDF_UINT)detail_no);
    longjmp(env, 1);
}
 
//tons of code
 
//Handle PDF
HPDF_Doc pdf;
HPDF_Page page;
HPDF_Font font;
float tw;
const char * titulo = "FACTURACION VUELO";
 
//tons of code
 
pdf = HPDF_New (error_handler, NULL);
if(!pdf){
    printf("Lo sentimos, ha habido un error, contacte con un administrador\n");
    break;
}
if(setjmp(env)){
        HPDF_Free (pdf);
        break;
}
HPDF_SetCompressionMode (pdf, HPDF_COMP_ALL);
font = HPDF_GetFont (pdf, "Helvetica", NULL);
HPDF_SetPageMode (pdf, HPDF_PAGE_MODE_USE_OUTLINE);
page = HPDF_AddPage (pdf);
HPDF_Page_SetSize (page, HPDF_PAGE_SIZE_A4, HPDF_PAGE_PORTRAIT);
HPDF_Page_SetFontAndSize (page, font, 24);
tw = HPDF_Page_TextWidth (page, titulo);
HPDF_Page_BeginText (page);
HPDF_Page_TextOut (page, (HPDF_Page_GetWidth(page) -tw) / 2, HPDF_Page_GetHeight(page) - 50, titulo);
HPDF_Page_EndText (page);
HPDF_Page_BeginText (page);
HPDF_Page_MoveTextPos (page, 60, HPDF_Page_GetHeight(page) -60);
HPDF_Free (pdf);

输出的是引用函数未定义的错误

Output :

opresor@opresor:~/Descargas/PracticaFinal$ make -f Makefile.vuelos

vuelos_client.o: En la función `vuelos_1':

/home/opresor/Descargas/PracticaFinal/vuelos_client.c:508: referencia a `HPDF_New' sin definir

/home/opresor/Descargas/PracticaFinal/vuelos_client.c:514: referencia a `HPDF_Free' sin definir

/home/opresor/Descargas/PracticaFinal/vuelos_client.c:517: referencia a `HPDF_SetCompressionMode' sin definir

/home/opresor/Descargas/PracticaFinal/vuelos_client.c:518: referencia a `

etc..

collect2: error: ld returned 1 exit status

Makefile.vuelos:39: recipe for target 'vuelos_client' failed

make: *** [vuelos_client] Error 1

我不熟悉 rpcgen,我不能说我完全理解这里发生的事情。但我建议您尝试将 -lhpdf 添加到该行 LDLIBS += -lnsl,因此显示为

LDLIBS += -lnsl -lhpdf

为编译器提供形式为 -llibrary 的命令行选项(至少对于 gccclang),告诉 linker 搜索特定的liblibrary.aliblibrary.so 之类的目录集(如果这是一个共享库),实际上 link 你的程序。 AFAICT,libharu 的库名称类似于 libhpdf.so,因此建议将该选项添加到变量 LDLIBS