I am not sure how I can include/use libHaru in my c++ project. https://github.com/libharu/libharu/wiki/Installation#Windows_except_cygwinMSYS. Do I need to run the nmake commands to make it work?
-
Read the instructions provided. It it here: https://github.com/libharu/libharu/wiki – Anon Mail Apr 10 '17 at 16:32
1 Answers
Using the nmake commands will build the library with the msvc compiler which you can then link with your application, I'm guessing the Makefile.msvc
script will build a static library where as Makefile.msvc_dll
will build a dynamic one.
Anyway, you don't need to do it like that, but if you want to use the library with your Win32 application then thats probably the easiest/fastest way to do it.
Just make sure that you have the necessary paths in your cmd session where you call nmake from before doing the compilation, you can do this by executing vcvars32.bat
in your %Visual Studio InstallDir%/VC/bin directory or just permanently add that path to your %PATH% environment variable.
And that the necessary dependencies for libHaru are present as well, from an initial compilation attempt it looks like libpng and zlib need to be placed in the same directory as the extracted libHaru directory.

- 136
- 1
- 9
-
@user2047610- i get this error when I try to build it in visual studio. rror LNK2019: unresolved external symbol _deflateInit_ referenced in function _HPDF_Stream_WriteToStreamWithDeflate – amanda45 Apr 10 '17 at 18:30
-
Sounds like it didn't link with the zlib dependency, perhaps you need to build that library first? – user2047610 Apr 10 '17 at 18:41
-
-
@user2047610- i get this error when I run nmake cl -Fosrc\hpdf_utils.obj -MT -nologo -O2 -Iinclude -Iwin32\include -c sr c\hpdf_utils.c hpdf_utils.c src\hpdf_utils.c(15) : fatal error C1083: Cannot open include file: 'stdlib.h': No such file or directory NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio 12.0 \VC\bin\cl.EXE"' : return code '0x2' Stop. – amanda45 Apr 10 '17 at 19:51
-
I had to compile zlib (using nmake again) and mess around with the paths in the Makefile.msc of libHaru so it would find the header files of both libpng and zlib (just removed one relative directory level for both and the appendend "\include"s at CFLAGS (just the ones for the zlib and libpng paths), so it would point to the root directory of the extracted archives). Doing that it produced me a libhpdf.lib in the root directory which should be usable for linkage. – user2047610 Apr 10 '17 at 21:09
-
@user2047610- I dont understand what you are saying. I was able to add libharu as a static lib using the .h and .c files. The lib can complie without error. When I run this code HPDF_Doc pdf=NULL; pdf = HPDF_New(error_handler, NULL); I get this error unresolved external symbol deflateInit referenced in function _HPDF_Stream_WriteToStreamWithDeflate – amanda45 Apr 10 '17 at 23:19
-
You never said that you were able to compile the library, I was assuming you still had trouble with that. Anyway, it looks like you will need to also link with zlib for your main application in addition to libHaru, I was able to build your code snippet doing just that. Last but not least, consider marking this as an answer and/or upvote it if it helped you with your problem. – user2047610 Apr 11 '17 at 08:45
-
@user2047610-do I add zlib as a static lib? and can I use this one http://zlib.net – amanda45 Apr 11 '17 at 14:11
-
Yes, thats the upstream website of zlib (which you can again compile with nmake). Compiling it gives you a dynamic and static .lib file so you can choose which one you prefer (but all that is explained in the readme's anyway). – user2047610 Apr 14 '17 at 15:55