gpt4 book ai didi

C LibHaru 对 的引用未定义

转载 作者:太空宇宙 更新时间:2023-11-04 07:46:17 25 4
gpt4 key购买 nike

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

我正在尝试使用 Linux Mint 发行版。 HPDF_Doc、Page 和 Font 被识别。

# 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),告诉链接器在一组特定目录中搜​​索类似 library.alibrary.so(如果这是一个共享库)的内容,并将您的程序与其实际链接起来。 AFAICT,libharu 的库名称类似于 libhpdf.so,因此建议将该选项添加到变量 LDLIBS

关于C LibHaru 对 <functions> 的引用未定义,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56706534/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com