首页 > 解决方案 > 使用库 pdfium 构建小型 c 程序时出错

问题描述

我正在尝试使用 pdfium 构建 init.c,以测试是否有效。我在桌面上的 dir、文件 init.c、pdfium.lib 和带有 pdfium 头文件的公共目录。init.c 代码是

    #include <fpdfview.h>
  int main() {
  FPDF_LIBRARY_CONFIG config;
  config.version = 2;
  config.m_pUserFontPaths = NULL;
  config.m_pIsolate = NULL;
  config.m_v8EmbedderSlot = 0;
  FPDF_InitLibraryWithConfig(&config);
  FPDF_DestroyLibrary();
  return 0;
}

在 Windows cmd 类型上打开...

 set PDF_LIBS="-lpdfium -lfpdfapi -lfxge -lfpdfdoc -lfxcrt -lfx_agg -lfxcodec -lfx_lpng -lfx_libopenjpeg -lfx_lcms2 -lfx_freetype -ljpeg -lfdrm -lpwl -lbigint -lformfiller -ljavascript -lfxedit"
set PDF_DIR=pdfium

然后尝试构建...

 g++ -I $PDF_DIR/public -o init init.c -L $PDF_DIR/out/Debug -lstdc++ $PDF_LIBS

我正在犯错误...

>g++ -I $PDF_DIR/public -o init init.c -L $PDF_DIR/out/Debug -lstdc++ $PDF_LIBS

g++:错误:$PDF_LIBS:没有这样的文件或目录

知道为什么吗?我已接受https://pdfium.googlesource.com/pdfium/+/master/docs/getting-started.md的指示 谢谢吉姆

标签: windowstestingbuildpdfium

解决方案


您试图在 Windows 的 shell 中使用 bash(和其他 Linux shell)变量扩展语法,这是行不通的。Windows 使用%VAR%而不是$VAR.

所以,要么使用正确的语法,就像这样......

g++ -I %PDF_DIR%/public -o init init.c -L %PDF_DIR%/out/Debug -lstdc++ %PDF_LIBS%

...或使用 Linux shell。作为开发人员,您可能已经安装了 Git,因此您可以使用 Git bash。


推荐阅读