Here are a few notes on integrating Objective C with with Informix ODBC in Cocoa applications in Xcode (3.1) on Mac OS X.
This is not a full tutorial on creating an Informix Cocoa application (though I understand someone is writing or planning to write a developerWorks article on that subject) but more of a few gotchas you could run into. There is more than one way to integrate ODBC with Objective C; in this example the ODBC code was written as functions in a C file and included under Other Sources
in Xcode to be called from Objective C.
Firstly the Xcode build architecture needs to be set to the right processor type to match the Informix Client SDK version, so for 64-bit CSDK (for example) set the build architecture to x86_64.
Next make sure Other Linker Flags
specifies the ODBC specific linker flags:
Also in this section the Header Search Path should be set to point to the Informix header file locations ($INFORMIXDIR/incl/cli, $INFORMIXDIR/incl/esql, $INFORMIXDIR/incl/public) and Library Search Path should be set to point to the corresponding library directories ($INFORMIXDIR/lib, $INFORMIXDIR/lib/cli, $INFORMIXDIR/lib/esql).
When the compiled program is executed the DYLD_LIBRARY_PATH
environment variables need to be set. To execute the code in Xcode this would be under the Arguments
of the Executable settings.
To run the executable outside of Xcode the environment variables could be set globally in /etc/launchd.conf
or in an Environment.plist
One additional issue you might run into (with CSDK 3.50.xC3 at least) is that the BOOL
typedef is defined both in an Xcode header file and in the ODBC header file infxsql.h
, which will cause a build failure. In the Cocoa app we created we temporarily worked this by hacking the infxsql.h file.
I logged a defect against ODBC to find a better way to resolve this.
Overall it was straightforward to integrate ODBC code with Objective C, but I hope to see some tutorials and documentation to make it easier coming along soon.[Read More