Including 3rd party libraries.

210 views
Skip to first unread message

osca...@gmail.com

unread,
Jun 9, 2015, 3:24:39 PM6/9/15
to j2objc-...@googlegroups.com
I have successfully generated Objc .m and .h files from my simplistic Dagger-2 code.

https://gist.github.com/OscarRyz/ffd976fcae9acf87dbe1

Now I'm trying to compile those file using j2objcc but the error message says it can't find .h for the the Dagger-2 classes:

j2objcc -c -I. `find app -name *.m`
In file included from app/DaggerSearchComponent.m:10:
./app/SearchInPage_Factory.h:10:10: fatal error: 'dagger/internal/Factory.h' file not found
#include "dagger/internal/Factory.h"
^
1 error generated.
app/SearchComponent.m:11:10: fatal error: 'dagger/Component.h' file not found
#include "dagger/Component.h"
^
1 error generated.
In file included from app/SearchInPage_Factory.m:8:
./app/SearchInPage_Factory.h:10:10: fatal error: 'dagger/internal/Factory.h' file not found
#include "dagger/internal/Factory.h"
^
1 error generated.
In file included from app/SearchInPage_MembersInjector.m:9:
./app/SearchInPage_MembersInjector.h:10:10: fatal error: 'dagger/MembersInjector.h' file not found
#include "dagger/MembersInjector.h"
^
1 error generated.
app/SearchModule.m:10:10: fatal error: 'dagger/Module.h' file not found
#include "dagger/Module.h"
^
1 error generated.
In file included from app/SearchModule_ProvideHostFactory.m:8:
./app/SearchModule_ProvideHostFactory.h:10:10: fatal error: 'dagger/internal/Factory.h' file not found
#include "dagger/internal/Factory.h"
^
1 error generated.
In file included from app/SearchModule_ProvideHttpClientFactory.m:9:
./app/SearchModule_ProvideHttpClientFactory.h:10:10: fatal error: 'dagger/internal/Factory.h' file not found
#include "dagger/internal/Factory.h"
^
1 error generated.


Question: Does this means that I need to have the library source code while generating the ObjC code so the .h for those could be generated as well?

Tom Ball

unread,
Jun 9, 2015, 6:20:10 PM6/9/15
to j2objc-...@googlegroups.com
Dagger isn't distributed with j2objc, so you have to build it yourself. To do so (requires Maven, described in the Building J2ObjC wiki):
  • git clone https://github.com/google/dagger.git
  • cd dagger
  • mvn install
  • j2objc -d build -classpath $J2OBJC_HOME/lib/javax-inject.jar -sourcepath core/src/main/java `find core/src/main/java -name *.java`
  • cd build
  • j2objcc -c -I. `find dagger -name *.m`
  • ar -r libdagger.a *.o
Notes:
  • Specify J2OBJC_HOME either where your j2objc distribution was unzipped, or if you built j2objc, its dist directory. To test, "ls $J2OBJC_HOME/j2objc" should list the j2objc script.
  • These instructions generate the macosx architecture, useful when testing. The files need to be recompiled for each architecture you want to use -- the easiest way to do so is to create a static library project in Xcode, add the translated files, then include this project in your app and add it as a dependency of your app.
  • ar will warn that "libdagger.a(package-info.o) has no symbols", which can be ignored since it doesn't have any symbols.
--
You received this message because you are subscribed to the Google Groups "j2objc-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to j2objc-discus...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

osca...@gmail.com

unread,
Jun 9, 2015, 6:26:43 PM6/9/15
to j2objc-...@googlegroups.com
So, it does need the Java source code of the 3rd party library. It wasn't clear for me.


Thanks for the response, the suggested method is way cleaner that what I have ^^

Regards
Reply all
Reply to author
Forward
0 new messages