Folks, I'm doing an evaluation of SQL Anywhere 12 for my company. We want to use the db as a datastore behind an application using the c api to access the database. In the last couple of days I've managed to get a sample application to run on windows and 11.10 ubuntu but I can't get the same application to run on mac osx 7. I've created a small project in Xcode 4, added the sample code and it all compiles fine. When I run the app however I get: Failed to load library: dlopen(libdbcapi_r.dylib, 1): image not found Could not initialize the interface! Can anybody tell me how I setup the dynamic libraries within the Xcode project so they're available to the application at runtime? Failing that, do I have to make a copy of the dylibs and run the install_name_tool against them to generate install names that I then use to reference them? I'm very new to Mac programming so any help would be appreciated. Cheers, Dan asked 05 Jan '12, 23:26 Dan Cleyne Volker Barth |
Ok, Turns out that even after setting up the environment variables in ./MacOSX/environment.plist, Xcode 4 overrides the You have to set the environment variables explicitly in the scheme of the application to have them available when debugging. Having done that I can now connect successfully to a running db server. Cheers, Dan answered 06 Jan '12, 18:20 Dan Cleyne |
Ok, so I've spent the last little while playing with the install_name_tool and I've managed to get the dynamic libraries to load at least.
The problem I have now is that the process fails and I have no idea why.
from this code:
I get returned:
Failed to initialize the interface! Supported version = 2
So I guess the library isn't in a good state. How do I find out what the problem is?
Cheers, Dan
Dan,
Make sure when you run your application that your SQL Anywhere environment is setup correctly and that the SQL Anywhere binaries are in your PATH and DYLD_LIBRARY_PATH. Have you sourced the configuration script sa_config.[c]sh?
To test that your environment is setup correctly, try to run dbping and see if you can successfully ping to a running server. Then from the same shell try to execute your application.
-- Mohammed
Thanks Mohammad,
I have setup the paths and DYLD_LIBRARY_PATH the same way as are in the sa_config.sh script. If I start a terminal session and run any of the tools they work fine (dbinit is the one I used to check)
So from that I think that maybe Xcode is not providing the right environment variables for the debugging session. I'll have a look through their documentation and see what I can find.
Cheers, Dan