C++ static library to be used in XCode - iphone

This is probably not a simple question so I am not looking for a definite answer but just some pointers to get me in the right direction.
I have absolutely no experience with C/C++ but have good knowledge of Objective-C. I also don't know much about different compilers and architectures so please be nice if I am talking stupid :)
I have some MatLab code that needs to be ported to Objective-C to run on an iPhone application. My first tentative path to get this done would be to check if MatLab can export the code as a static C/C++ library that I can call from within my Objective-C code.
This seems to be the case but I am not entirely sure what to do next, and what things I need to keep in mind when compiling the library on the MatLab side (i.e. architecture, compatibility, PC vs Mac, etc).
I have been provided with a .DLL and .LIB files which I believe are Windows compiled so they will not be useful for me, is this correct? From working with previous static libraries I can see they all have a .a extension - what do I need to do to get one that is compatible with the iPhone architecture?
And once I get the library compiled, how to I import and use it within my project? Will I just be able to call the public methods directly from within my code?
What else do I need to know or be aware of?
Any help is very much appreciated!
Thanks,
Rog

Static libraries contain binary code tailored for some specific operating system and platform. That means that it will use the OS to internally acquire memory (if it uses dynamic memory) or to perform any other OS specific operation (logging, output).
Even if the generated code was completely OS-agnostic (basic math could be implemented without OS support), the platform is completely different, matlab will generate code for an intel platform and the iPhone runs in an ARM architecture, with a different instruction set calling conventions...
Unless matlab is able to generate static libraries for the iPhone or at the very least for an ARM platform and make it OS-agnostic, you are out of luck.

Related

iOS - Will ASM code run on armv7/armv7s/arm64?

I'm trying to figure out if the ASM code for the function neon_asm_convert() in the example here will run on all armv7/armv7s/arm64 processors (ie., iPhone 4S/5/5S).
Unfortunately, I don't own all of these devices, so a simple run-test is out of the question.
However, I'm developing an app (testing it only using armv7) which uses the __asm__() from the neon_asm_convert(), and I would like to find out if the ASM code will also run on arm64.
I think I read that ASM code that runs on armv7/armv7s won't run on arm64 but I can't seem to find that reference anymore.
Does anyone have any pointers that cold help me out?
Looks like it's not going to run on arm64. As this answer says:
arm64 is a new ISA. The actual NEON instructions and register layout are entirely new. You will need to re-write or adapt assembly code for the new architecture.
As Tomer said, no. arm64 is a new architecture with a new instruction syntax and register layout.
However, fast implementations of this sort of colorspace conversion are available in the SDK as part of the Accelerate.framework. Except in special circumstances, you shouldn’t need to write your own assembly code for this. Specifically, you can use the vImageConvert_AnyToAny function, which provides high-performance implementations of this and many, many other common conversions that work on all of the architectures that Apple ships (armv7, armv7s, arm64, i386, x86_64).

Is there any way to not show to the user my classes used to make a static library on the user machine?

I'd like to develop a Mac application that builds custom static libraries for iPhone on behalf of the user.
I know that I can invoke xcode from the terminal with -xcodebuild to build these static libraries on the user machine, but my problem is that I don't want show to the user my objective-c classes used for the static library.
So my question is there any way to not show to the user my classes? Instead of use -xcodebuild I have other some way?
Thanks in advance
I guess you want to prevent the users of your library to see the header files of your static lib, right? I guess this is really problematic, as a compiler requires the header files to compile properly.
What you can do is to provide a "stripped down" version of your headers to your class users.
I stumbled across this tutorial a while ago. If you want to keep the code of your classes "closed" to any developers who are supposed to use it, I suggest making it a static library. Alternatively you can make a Framework.
http://www.clintharris.net/2009/iphone-app-shared-libraries/
No worries, this is the same process for iOS and Mac OS X.
In short, No. Since your code will be compiled for the machine by gcc, the user need only intercept Gcc at the appropriate moment and read out the code.
You can make this more difficult (but not impossible) to intercept by piping the code directly into gcc from your application, and do some checks to validate that it's really gcc it's going to.
You can also precompile some of the code that is common to all users into a framework, and that means you don't need to distribute the source to that part.

Common LISP on iPhone/iOS

Is it possible to call a Common Lisp function in iOS?
If so, is it possible create it in a dynamic library?
It depends on what you mean by calling a CL function, but most likely ECL will be your shortest path. Start here, as there is a patch for ECL to better accommodate iOS: http://funcall.posterous.com/tag/iphone
ECL generates C code, so you should be in safe territory with Apple's shifting policies.
Have you tried MOCL?
According to the website "mocl is a highly optimizing CL implementation, delivering tight native code via LLVM/Clang".
Maybe you can create a dynamic library, though it is designed for use the other way around.
Clozure Common Lisp (CCL) runs in Linux on the ARM, and Gary Byers long ago made an experimental iPhone version, but it would only run on a jail-broken iPhone. The problem is that the CCL compiler writes executable code, but iOS out-of-the-box does not allow a writable page to be made executable, so you can't ever RUN that code.
We've had discussions about putting the code that ships with an iOS app be in a read-only code section, and adding a byte-code compiler, so that code created at run-time can be fairly quickly interpreted, but nobody has offered to fund that project, so it hasn't gotten done.
You might think that we could just interpret code created at run-time, but the current CCL "interpreter" compiles non-trivial code before executing it.
MOCL is probably your best option to write code callable from other apps, but that's only a guess, since I haven't used it.
You could use Gambit Scheme or Clozure Common Lisp, both are able to interface with Cocoa, the first because it generates C and the latter because there is a bridge from Clozure to Cocoa. Do a google search about it and you will find a few things.
You might want to keep an eye on this (new) project. It will be publicly available during October 2019: EQL5 iOS EQL5 iOS libs
There also exists Mobile Common Lisp1

SNMP Library for iPhone

Are there any open source libraries for doing SNMP GET/SETs using the Objective C/Cocoa Touch (for IPhone)?
Although there is no SNMP implementations in Objective-C (that i an aware of). There are in C & C++.
I've had success at using snmp++v2.8a. Just drop the .h and .cpp files required for the static libsnmp++.a into your x-code iphone project. And make the necessary tweaks for it to build. I had to add: "-D_XPG4_EXTENDED -DGCC -DLINUX" to Project Settings 'Other C++ Flags', and make some changes to the files. Then any file you are using the c++ objects from, rename from .m to .mm, to tell X-Code the file contains a mixture of objective-C and c++.
In my opinion, the C/C++ package called Net-SNMP (has nothing to do with .NET) is the best implementation of an SNMP library for both the manager (client) and the agent (server) sides. I've looked at a lot of them and used a lot of them, and Net-SNMP is the best of the lot. Open source.
I've spent some time working on building one of these for a project.
there's none for obj-c, or at least there weren't when I was looking last summer. there's a bunch of open source ones in c and c# that are a good starting spot for a port (or re-implementation).
I've never heard of one, and the only thing I'm finding on Google is "IP*Works!", but it seems to be a Mac framework (and might not work on iPhone if it's not compiled as a .a file).
Your best bet may be to roll your own. http://cocoabuilder.com has a couple emails in its archives about people asking for SNMP libraries, but no answers were ever received.

How do I use a 3rd party C library in Xcode for my iphone project?

love this site and all helpful people! I'm newbie to Xcode and iPhone programming but I've pretty much got the hang of using the SDK to make programs in Obj-C (simple programs right now but make me happy). My experience is web programming (such as PHP and Perl) and I'm not really used to a lot of the new Xcode/desktopy-app stuff like static libraries and linking and such. I be honest, I am not total awesome programmer yet!
I have a problem right now, my (card game) program I am writing needs to use this C library. I don't really understand how I get the proper C files and integrate them into my project so I can start using the commands in that tutorial to evaluate hand values.
I hope I have been clear, please let me know if there is anything I am leaving out. Unfortunately, my newbieness may prevent from me making everything so clear and sometimes I can't english perfectly what I am thinking!
Happy thanks in advance, looking forward to any help!
Couple things:
The library you linked to is quite large. Pokersource appears to be a large C project containing all sorts of things like language bindings and some GUI tools as well. A project that large certainly has an IRC channel. I would recommend going there.
The library you linked to appears to be (I may be wrong about this), licensed under the GPLv3. This means that any program that you distribute to others that uses a GPLv3 library or piece of code must also be licensed under the GPLv3. The upshot is that if you use that library, you'll have to release the source for your game.
The site you linked to does seem to have a long list of other poker hand evaluators, so its possible one of them is suitable for your needs.
Good luck!
it's totally possible to use third party static libraries with your iPhone and using Xcode. This webpage illustrates the process of doing it.