Error - Adding external libraries to native iOS code

270 views
Skip to first unread message

Karuna Pandey

unread,
Mar 11, 2014, 2:48:26 AM3/11/14
to codenameone...@googlegroups.com
Hello,

I have implemented printing via Epson printer on the native iOS env. However when I get my code to my codenameone project, it gives me errrors reg the libraries that I am trying to add. I read the earlier discussions where it was mentioned that I can add my .h & .a libraries directly where my code was. So I have ["ePOS-Print.h" and "libeposprint.a"] in the same location where my iOS code exists.

Here is the error I get when I tried a server debug build.

Ld build/Release-iphoneos/S2PayApp.app/S2PayApp normal armv7
    cd /var/folders/p_/xlvwhg4101z8r81_nl13cds80000gn/T/build3377300505847546075xxx/dist
    setenv IPHONEOS_DEPLOYMENT_TARGET 4.3
    setenv PATH "/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin"
    /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/llvm-g++-4.2 -arch armv7 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS6.1.sdk -L/var/folders/p_/xlvwhg4101z8r81_nl13cds80000gn/T/build3377300505847546075xxx/dist/build/Release-iphoneos -L/var/folders/p_/xlvwhg4101z8r81_nl13cds80000gn/T/build3377300505847546075xxx/dist/../btres -F/var/folders/p_/xlvwhg4101z8r81_nl13cds80000gn/T/build3377300505847546075xxx/dist/build/Release-iphoneos -filelist /var/folders/p_/xlvwhg4101z8r81_nl13cds80000gn/T/build3377300505847546075xxx/dist/build/S2PayApp.build/Release-iphoneos/S2PayApp.build/Objects-normal/armv7/S2PayApp.LinkFileList -dead_strip -lz -miphoneos-version-min=4.3 -weak-liconv -weak_framework AddressBookUI -weak_framework MapKit -weak_framework AudioToolbox -framework Foundation -weak_framework OpenGLES -weak-lxml2 -weak_framework QuartzCore -weak_framework AddressBook -weak-lsqlite3 -lzbar -weak_framework GameKit -weak_framework Security -framework CoreMotion -framework UIKit -weak_framework CoreLocation -weak_framework MessageUI -weak_framework MediaPlayer -framework CoreGraphics -weak_framework AVFoundation -weak_framework CoreVideo -weak_framework QuickLook -weak_framework StoreKit -weak_framework iAd -weak_framework CoreMedia -o /var/folders/p_/xlvwhg4101z8r81_nl13cds80000gn/T/build3377300505847546075xxx/dist/build/Release-iphoneos/S2PayApp.app/S2PayApp
Undefined symbols for architecture armv7:
  "_OBJC_CLASS_$_EposPrint", referenced from:
      objc-class-ref in com_nvsoft_s2pay_epson_print_PrintText.o
  "_OBJC_CLASS_$_EposBuilder", referenced from:
      objc-class-ref in com_nvsoft_s2pay_epson_print_PrintText.o
ld: symbol(s) not found for architecture armv7
collect2: ld returned 1 exit status
** BUILD FAILED **
The following build commands failed:
    Ld build/Release-iphoneos/S2PayApp.app/S2PayApp normal armv7
(1 failure)

Thanks
Karuna

Shai Almog

unread,
Mar 11, 2014, 3:59:46 AM3/11/14
to codenameone...@googlegroups.com
Hi,
just to make sure. You placed both of those files under native/ios right?
Its possible that you need to enable the -ObjC flag which has some size implications. Try the build argument ios.objC=true

Karuna Pandey

unread,
Mar 11, 2014, 4:41:07 AM3/11/14
to codenameone...@googlegroups.com
Yes placed them under native/ios, also added the buid arguement, ios.objC still get the same error.

Shai Almog

unread,
Mar 11, 2014, 3:32:09 PM3/11/14
to codenameone...@googlegroups.com
Is it possible the .a file is built for the simulator x86 and not for the device armv7/armv7s architectures?

Karuna Pandey

unread,
Mar 12, 2014, 8:38:53 AM3/12/14
to codenameone...@googlegroups.com
Just checked, they are (armv6, armv7, armv7s, arm64, i386 supported). 

Shai Almog

unread,
Mar 12, 2014, 1:29:56 PM3/12/14
to codenameone...@googlegroups.com
In that case I'm fresh out of ideas. If you have a paid account I suggest working with xcode and trying to get this to work with source which will probably illuminate what you need to change.

Karuna Pandey

unread,
Mar 13, 2014, 9:39:05 AM3/13/14
to codenameone...@googlegroups.com

To look into this further, I created a new basic codenameone application, and tried to use this library from the native ios code. I still get the same error. Attached here is my codenameone project, and the errorlog. I do not see any reference to "libeposprint.a" in the errorlog but do see --lib=libzbar.a. 

https://drive.google.com/file/d/0BytH7i90MiV4Y2tUTDVGSk0yT3M/edit?usp=sharing
https://drive.google.com/file/d/0BytH7i90MiV4bGgyU3JUOG45NDQ/edit?usp=sharing

Error:
iphoneos/MyTestApp.app/MyTestApp

Undefined symbols for architecture armv7:
  "_OBJC_CLASS_$_EposPrint", referenced from:
      objc-class-ref in com_epson_myapp_MyNativeInterfaceImpl.o

ld: symbol(s) not found for architecture armv7
collect2: ld returned 1 exit status
** BUILD FAILED **




Shai Almog

unread,
Mar 13, 2014, 3:28:30 PM3/13/14
to codenameone...@googlegroups.com
If you don't see your lib in the logs under --lib that means the lib isn't linked.
It should be seamlessly linked if its under the ios folder, starts with lib and ends with .a.
Make sure the file made its way into your jar file sent to the server.

karuna...@nvsoft.com

unread,
Mar 14, 2014, 2:29:20 AM3/14/14
to codenameone...@googlegroups.com
The file is included in the jar file. Also the lib file follows the naming convention, with a name "libeposprint.a".
I noticed a setting ios.add_libs to add frameworks used within .a files. Do I have any such parameter to explicitly set for a .a file?

Shai Almog

unread,
Mar 14, 2014, 1:17:15 PM3/14/14
to codenameone...@googlegroups.com, karuna...@nvsoft.com
You can use the add_libs argument for the .a file but I doubt it will help. I'm out of ideas here.

slas...@gmail.com

unread,
May 6, 2015, 3:44:37 AM5/6/15
to codenameone...@googlegroups.com
I'm not sure if you figured it out by now but I got this error as well. I solved it by going into the build phases target and adding "libeposprint.a" under link binaries with libraries. Any other method of adding it to the project was unsuccessful. 
Reply all
Reply to author
Forward
0 new messages