Arrsoya / jmupdf

Automatically exported from code.google.com/p/jmupdf
1 stars 0 forks source link

Build Issues in OSX 10.7 #8

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
The included makefile has consistently refused to successfully build the JNI 
libraries I need to bring JMuPDF into a Java application being developed on OSX 
10.7. I've gone through the MakeJNI1 and MakeJNI2 makefiles line by line to 
tweak in the hopes of making it work, but I always get stuck at the linking 
step.

I isolated the OSX build process into a separate shell script so I could 
inspect each action item step by step. I've attached that file as build_osx.sh

Not sure what to do at this point. Both the included makefile, and my own 
attempts at linking get stuck at the same place:

mrapczynski:MuPDF mattrapczynski$ ./build_osx.sh
Undefined symbols for architecture i386:
  "__lfind", referenced from:
      _TIFFFindFieldInfoByName in libtifflib.a(tif_dirinfo.o)
      _TIFFFieldWithName in libtifflib.a(tif_dirinfo.o)
  "_jni_write_jpg", referenced from:
      _Java_com_jmupdf_JmuPdf_writeJPeg in jni_java_pixmap.o
ld: symbol(s) not found for architecture i386
collect2: ld returned 1 exit status

I feel like I'm so close to getting a finished library. Any ideas?

Original issue reported on code.google.com by matt.rap...@gmail.com on 17 Mar 2012 at 8:31

Attachments:

GoogleCodeExporter commented 9 years ago
What compiler are you using? I noticed a reference to osx/libjmupdf64.jnilib 
but yet you are compiling to -m32. Could there be a mismatch of x86 vs x64?

The reference to _lfind is found in tif_config.h line 66. Try commenting this 
line out and see if it makes a difference. 

Depending on the compiler you are using you might need to tweak the linking 
options for that platform a little further. I have had issues with undefined 
symbols and usually it was an ld setting for creating dynamic libraries.

I don't have a Mac here so it will be difficult for me to test. 

All our builds for Win and Linux are done using GNU (gcc) compilers.

Pedro

Original comment by pedro.ri...@gmail.com on 18 Mar 2012 at 1:23

GoogleCodeExporter commented 9 years ago
Thanks for pointing that out. It's actually just a naming hiccup since I 
started in 64-bit, but then set 32-bit so I could link with the rest of the 
output from the makefile.

I am using GCC as well. Apple packages a Darwin version, and keeps it up to 
date:

gcc version 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2336.1.00)

First, I run your makefile as is with no changes so that it can build MuPDF to 
create the library objects, and only after then do I run my customized script 
to build the JNI library. Compiling MuPDF on its own without the JNI libraries 
seems to work just fine.

I'll try your suggestion for _lfind to see if it helps, and report back on this 
thread.

Thanks!

Original comment by matt.rap...@gmail.com on 18 Mar 2012 at 5:17

GoogleCodeExporter commented 9 years ago
Update:

Commenting out _lfind in tif_config.h helped eliminate one of the errors. So 
after running make, then when I go to rebuild the JNI libs, now the only error 
is this:

mrapczynski:MuPDF mattrapczynski$ ./build_osx.sh
Undefined symbols for architecture i386:
  "_jni_write_jpg", referenced from:
      _Java_com_jmupdf_JmuPdf_writeJPeg in jni_java_pixmap.o
ld: symbol(s) not found for architecture i386
collect2: ld returned 1 exit status

I did a grep looking for _jni_write_jpg and _Java_com_jmupdf_JmuPdf_writeJPeg, 
but neither of them seem to appear in any of the source files:

mrapczynski:MuPDF mattrapczynski$ grep -R _jni_write_jpg *
Binary file build/release/jni_java_pixmap.o matches
Binary file build/release/jni_write_jpeg.o matches
Binary file osx/jni_java_pixmap.o matches

mrapczynski:MuPDF mattrapczynski$ grep -R _Java_com_jmupdf_JmuPdf_writeJPeg *
Binary file build/release/jni_java_pixmap.o matches
Binary file osx/jni_java_pixmap.o matches

I figured you may not have access to a Mac, and that's okay. If we get this 
working, I'll send you anything I've worked out so you can keep it with your 
project for others.

Original comment by matt.rap...@gmail.com on 18 Mar 2012 at 5:25

GoogleCodeExporter commented 9 years ago
Thanks! I look forward to a Mac build script. Try downloading the latest git 
commit under "multi-thread". See if that makes a difference. 

Pedro

Original comment by pedro.ri...@gmail.com on 19 Mar 2012 at 11:52

GoogleCodeExporter commented 9 years ago
If this is a possible to get a built library for MacOS? 

Original comment by maciej.l...@gmail.com on 13 Aug 2012 at 5:40

GoogleCodeExporter commented 9 years ago
Is there any updates on this issue? I've been trying different approach to 
build the library for MacOS but so far no luck.

Original comment by art...@gmail.com on 5 Feb 2013 at 12:58

GoogleCodeExporter commented 9 years ago
Okay, I found a workaround to make a build on MacOS (mine is OS 10.7.5).

In MakeJINI2, add the following code for MacOS. It is for linking the JIN from 
the jdk.
#
# --- MacOS 
#
ifeq "$(findstring Darwin,$(OS))" "Darwin"
LBITS := $(shell getconf LONG_BIT)
ifeq ($(LBITS),64)
JNI_DLL := $(OUT)/libjmupdf64.dylib
else
JNI_DLL := $(OUT)/libjmupdf32.dylib
endif
JNI_CMD := -shared
JVM_INCLUDES := -I"PATH-TO-UR-JDK/Contents/Home/include" 
-I"/PATH-TO-UR-JDK/Contents/Home/include/darwin"
endif

In MakeJINI1, if ur machine is 64bits, change the first line (-m32) to (-m64)
OS ?= $(shell uname)-m64

To avoid the error on the tif lib, go to tif_dirinfo.c and find where the 
function lfind() was called. Then comment out the content of the function, and 
return NULL instead. Apparently this is not a solution but a workaround, but it 
WORKS!

const TIFFFieldInfo* _TIFFFindFieldInfoByName(TIFF* tif, const char 
*field_name, TIFFDataType dt)
{
  return NULL;
}

And then do a "make". Hope this helps.

Original comment by art...@gmail.com on 12 Feb 2013 at 5:36

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago

Thanks for the workaround. Sorry I have been silent. Project coding for JMuPDF 
will begin again with updated code and bug fixes, etc. 

I should be releasing a new version soon.

BTW, I got myself a Mac over the holidays so I should help figuring out the 
compile issues for a more permanent solution.

Thanks again,

Pedro

Original comment by pedro.ri...@gmail.com on 12 Feb 2013 at 1:32

GoogleCodeExporter commented 9 years ago
Hi all,

A new commit was made today that should allow you to compile the JNI code in 
MAC OSx with no issues. Here is the link with details. 

http://code.google.com/p/jmupdf/source/detail?r=a56ebe12709d7704685cf512dd8ae777
17939f8e

A new version coming soon with Win, Linux, & Mac 64 and 32 bit binaries.

Thanks,

Pedro

Original comment by pedro.ri...@gmail.com on 13 Feb 2013 at 4:03

GoogleCodeExporter commented 9 years ago
Mac OS X binaries are now available for download.

Thanks,

Pedro

Original comment by pedro.ri...@gmail.com on 8 Apr 2014 at 3:50