Building native libraries on MacOS X

Have a great idea for extending Zimbra? Share ideas, ask questions, contribute, and get feedback.
ajmas
Posts: 4
Joined: Fri Sep 12, 2014 9:58 pm

Building native libraries on MacOS X

Postby ajmas » Thu Oct 13, 2005 12:19 pm

I just downloaded the source (zcs-3.0.M1_21) on my MacOS X 10.4. At this point I have compiled all the java source and attempted to build the C/C++ code in the ZimbraNative directory, but failed with errors.
Just to document what I did, from the source base directory:
ant -f Ajax/build.xml

ant -f ZimbraCharset/build.xml

ant -f ZimbraServer/build.xml

ant -f ZimbraWebClient/build.xml

cd ZimbraBuild

make

cd ../ZimbraNative

make
The last few lines of the 'make' output of ZimbraBuild follows:



echo "%attr(-, zimbra, zimbra) /opt/zimbra/db" >>

/Users/ajmas/Desktop/zcs-3.0.M1_21-src/ZimbraBuild/zimbracore.spec

echo "%attr(-, zimbra, zimbra) /opt/zimbra/jdk1.5.0_04" >>

/Users/ajmas/Desktop/zcs-3.0.M1_21-src/ZimbraBuild/zimbracore.spec

echo "%attr(-, zimbra, zimbra) /opt/zimbra/lib" >>

/Users/ajmas/Desktop/zcs-3.0.M1_21-src/ZimbraBuild/zimbracore.spec

echo "%attr(-, zimbra, zimbra) /opt/zimbra/zimbramon" >>

/Users/ajmas/Desktop/zcs-3.0.M1_21-src/ZimbraBuild/zimbracore.spec

(cd /Users/ajmas/Desktop/zcs-3.0.M1_21-src/ZimbraBuild/corebuild;

rpmbuild --target i386 --quiet --define '_rpmdir /Users/ajmas/Desktop/zcs-3.0.M1_21-src/ZimbraBuild'

--buildroot=/Users/ajmas/Desktop/zcs-3.0.M1_21-src/ZimbraBuild/corebuild -bb /Users/ajmas/Desktop/zcs-3.0.M1_21-src/ZimbraBuild/zimbracore.spec )

/bin/sh: line 1: rpmbuild: command not found

make: *** [core] Error 127



The 'make' output of ZimbraNative follows:



mkdir -p build/classes

javac -source 1.4 -target 1.4 -d build/classes src/java/com/zimbra/znative/IO.java src/java/com/zimbra/znative/tests/HardLinkTest.java src/java/com/zimbra/znative/tests/LinkCountTest.java

rm -f build/zimbra-native.jar

jar c0vf build/zimbra-native.jar -C build/classes com

added manifest

adding: com/(in = 0) (out= 0)(stored 0%)

adding: com/zimbra/(in = 0) (out= 0)(stored 0%)

adding: com/zimbra/znative/(in = 0) (out= 0)(stored 0%)

adding: com/zimbra/znative/IO.class(in = 1300) (out= 1300)(stored 0%)

adding: com/zimbra/znative/tests/(in = 0) (out= 0)(stored 0%)

adding: com/zimbra/znative/tests/HardLinkTest.class(in = 1779) (out= 1779)(stored 0%)

adding: com/zimbra/znative/tests/LinkCountTest.class(in = 952) (out= 952)(stored 0%)

mkdir -p build

rm -f build/IO.h

javah -o build/IO.h -classpath build/classes com.zimbra.znative.IO

gcc -Ibuild -Wall -Wmissing-prototypes -c -o build/IO.o src/native/IO.c

src/native/IO.c:26:17: error: jni.h: No such file or directory

In file included from src/native/IO.c:35:

build/IO.h:16: error: syntax error before "void"

build/IO.h:17: error: parse error before '*' token

build/IO.h:17: warning: type defaults to 'int' in declaration of 'Java_com_zimbra_znative_IO_link0'

build/IO.h:17: warning: data definition has no type or storage class

build/IO.h:24: error: parse error before "jint"

build/IO.h:25: error: parse error before '*' token

build/IO.h:25: warning: type defaults to 'int' in declaration of 'Java_com_zimbra_znative_IO_linkCount0'

build/IO.h:25: warning: data definition has no type or storage class

src/native/IO.c:38: error: parse error before '*' token

src/native/IO.c: In function 'ThrowNPE':

src/native/IO.c:40: error: 'jclass' undeclared (first use in this function)

src/native/IO.c:40: error: (Each undeclared identifier is reported only once

src/native/IO.c:40: error: for each function it appears in.)

src/native/IO.c:40: error: parse error before "cls"

src/native/IO.c:42: error: 'cls' undeclared (first use in this function)

src/native/IO.c:43: error: 'env' undeclared (first use in this function)

src/native/IO.c:43: error: 'msg' undeclared (first use in this function)

src/native/IO.c: At top level:

src/native/IO.c:47: error: parse error before '*' token

src/native/IO.c: In function 'ThrowIAE':

src/native/IO.c:49: error: 'jclass' undeclared (first use in this function)

src/native/IO.c:49: error: parse error before "cls"

src/native/IO.c:51: error: 'cls' undeclared (first use in this function)

src/native/IO.c:52: error: 'env' undeclared (first use in this function)

src/native/IO.c:52: error: 'msg' undeclared (first use in this function)

src/native/IO.c: At top level:

src/native/IO.c:56: error: parse error before '*' token

src/native/IO.c: In function 'ThrowIOE':

src/native/IO.c:58: error: 'jclass' undeclared (first use in this function)

src/native/IO.c:58: error: parse error before "cls"

src/native/IO.c:59: error: 'cls' undeclared (first use in this function)

src/native/IO.c:60: error: 'env' undeclared (first use in this function)

src/native/IO.c:60: error: 'msg' undeclared (first use in this function)

src/native/IO.c: At top level:

src/native/IO.c:63: error: syntax error before "void"

src/native/IO.c:64: error: parse error before '*' token

src/native/IO.c:69: warning: return type defaults to 'int'

src/native/IO.c:69: warning: no previous prototype for 'Java_com_zimbra_znative_IO_link0'

src/native/IO.c: In function 'Java_com_zimbra_znative_IO_link0':

src/native/IO.c:75: error: 'joldpath' undeclared (first use in this function)

src/native/IO.c:76: error: 'env' undeclared (first use in this function)

src/native/IO.c:77: warning: 'return' with no value, in function returning non-void

src/native/IO.c:80: error: 'jnewpath' undeclared (first use in this function)

src/native/IO.c:82: warning: 'return' with no value, in function returning non-void

src/native/IO.c:88: warning: 'return' with no value, in function returning non-void

src/native/IO.c:94: warning: 'return' with no value, in function returning non-void

src/native/IO.c:106: warning: 'return' with no value, in function returning non-void

src/native/IO.c:109: warning: implicit declaration of function 'snprintf'

src/native/IO.c:109: warning: incompatible implicit declaration of built-in function 'snprintf'

src/native/IO.c:113: warning: control reaches end of non-void function

src/native/IO.c: At top level:

src/native/IO.c:115: error: parse error before "jint"

src/native/IO.c:116: error: parse error before '*' token

src/native/IO.c:117: warning: return type defaults to 'int'

src/native/IO.c:117: warning: no previous prototype for 'Java_com_zimbra_znative_IO_linkCount0'

src/native/IO.c: In function 'Java_com_zimbra_znative_IO_linkCount0':

src/native/IO.c:122: error: 'jpath' undeclared (first use in this function)

src/native/IO.c:123: error: 'env' undeclared (first use in this function)

src/native/IO.c:138: error: 'jint' undeclared (first use in this function)

src/native/IO.c:138: error: parse error before "sb"

src/native/IO.c:141: warning: incompatible implicit declaration of built-in function 'snprintf'

src/native/IO.c:145: warning: control reaches end of non-void function

make: *** [build/IO.o] Error 1



'gcc -v' gives:



Reading specs from /usr/lib/gcc/powerpc-apple-darwin8/4.0.0/specs

Configured with: /private/var/tmp/gcc/gcc-4061.obj~8/src/configure --disable-checking --prefix=/usr --mandir=/share/man --enable-languages=c,objc,c++,obj-c++ --program-transform-name=/^[cg][^+.-]*$/s/$/-4.0/ --with-gxx-include-dir=/include/gcc/darwin/4.0/c++ --build=powerpc-apple-darwin8 --host=powerpc-apple-darwin8 --target=powerpc-apple-darwin8

Thread model: posix

gcc version 4.0.0 20041026 (Apple Computer, Inc. build 4061)



ajmas
Posts: 4
Joined: Fri Sep 12, 2014 9:58 pm

Building native libraries on MacOS X

Postby ajmas » Thu Oct 13, 2005 12:21 pm

I modified the make file so that the gcc command for '$(BUILD)/IO.o' now reads:



gcc -I$(BUILD) -I$(JAVA_HOME)/include -Wall -Wmissing-prototypes -c -o $@ $


This removes all of the dependency related errors, leaves a few warnings and then fails since gcc on Darwin/MacOS X does not suport the '-shared' option. I think think it should be '-dynamiclib', so I changed that in the make file and that resolves the build issues there.
As to ZimbraBuild, the blocking point at the moment seems to be RPM creation. Maybe we need to create a generic version that will create a tarball distribution. That should allow most platforms to have a working solution, even if it is not the ideal one.
14319KevinH
Ambassador
Ambassador
Posts: 4558
Joined: Fri Sep 12, 2014 9:52 pm

Building native libraries on MacOS X

Postby 14319KevinH » Thu Oct 13, 2005 3:19 pm

As of now the source has been setup to compile on Red Hat and Fedora. We are working on more ports so you can build an installable pkg for other OS's. MacOS X is on that list.
riegersteve
Advanced member
Advanced member
Posts: 51
Joined: Fri Sep 12, 2014 9:55 pm

Building native libraries on MacOS X

Postby riegersteve » Sat Oct 15, 2005 1:00 am

i actually just started getting it up and running on solaris 10 sparc. give me a week and i will have some more details.

Return to “Developers”

Who is online

Users browsing this forum: No registered users and 2 guests