Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > Mixing library written in different languages

Mixing library written in different languages
Thread Tools
ThaShef
Fresh-Faced Recruit
Join Date: Mar 2003
Status: Offline
Reply With Quote
Jan 7, 2004, 12:25 AM
 
I have a really quick question.

I am writing a simple software that will resize hundreds of pictures in a batch process and then ftp them to a server with couple of setting files.

I have the ftp library that is written in Java and I was planning on using DevIL image library that is written in C++.

How would I go about using both of these libraries from a single application.

I was planning on using Cocoa/Java but I dont really know how to mix and match the different languauges using XCode, as this is my first application in Mac OSX (I am recent switcher)

Thanks
     
itai195
Addicted to MacNN
Join Date: May 2001
Location: Cupertino, CA
Status: Offline
Reply With Quote
Jan 7, 2004, 01:59 AM
 
These are kind of general answers, but for info about accessing Java from Objective-C check out this article about the Java Bridge.

I know you can pretty easily use C++ libraries from Cocoa via Objective-C++, see some info about that here. One important thing to keep in mind, name files that use Objective-C++ with a .mm extension in xcode! There might be some newer documentation regarding Objective-C++ but I've just started writing an app that uses a C++ library and haven't had any issues.
     
aleph_null
Dedicated MacNNer
Join Date: Jan 2001
Location: Boulder, CO, USA
Status: Offline
Reply With Quote
Jan 7, 2004, 02:20 PM
 
Originally posted by ThaShef:

I am writing a simple software that will resize hundreds of pictures in a batch process and then ftp them to a server with couple of setting files.

I have the ftp library that is written in Java and I was planning on using DevIL image library that is written in C++.

How would I go about using both of these libraries from a single application.
It's probably possible, but unless someone has already come up with a way to do it (eg, hooks in Java that let you run foreign code), I'm guessing it'll be more work than it's worth. You may consider making two apps and bridging them with applescript or your own interapplication messaging system.

I'm pessimistic because Java and C++ code run in completely different runtime environments and use completely different executable formats. Getting both to live happily in a single app might be tricky. But ymmv!
     
ThaShef  (op)
Fresh-Faced Recruit
Join Date: Mar 2003
Status: Offline
Reply With Quote
Jan 7, 2004, 03:22 PM
 
Originally posted by itai195:
These are kind of general answers, but for info about accessing Java from Objective-C check out this article about the Java Bridge.

I know you can pretty easily use C++ libraries from Cocoa via Objective-C++, see some info about that here. One important thing to keep in mind, name files that use Objective-C++ with a .mm extension in xcode! There might be some newer documentation regarding Objective-C++ but I've just started writing an app that uses a C++ library and haven't had any issues.
Do I have to program in Objective-C or Objective-C++, could I just use straight C++.

Thanks
     
johnMG
Registered User
Join Date: Oct 2003
Status: Offline
Reply With Quote
Jan 10, 2004, 02:37 AM
 
Do I have to program in Objective-C or Objective-C++, could I just use straight C++.

You may have both C++ files (.cpp) and "Objective-C++" files (.mm) in your project.

"Programming in Objective-C++" just means creating a source code file with a .mm extension, filling it with Objective-C code, and then occasionally making use of some C++ classes.

I think the way it goes is, if you like using C++, most of your files will be C++ (and will be making use of C++ libs like DevIL) except for one or two with Obj-C and C++ mixed: the .mm file(s) -- that's where you glue your C++ code into your Objective-C GUI stuff.
     
   
 
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Top
Privacy Policy
All times are GMT -4. The time now is 07:03 PM.
All contents of these forums © 1995-2017 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.8 © 2000-2017, Jelsoft Enterprises Ltd.,