Please be aware that the content in SAP SQL Anywhere Forum will be migrated to the SAP Community in June and this forum will be retired.


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%20Cleyne's gravatar image

Dan Cleyne
accept rate: 25%

edited 09 Jan '12, 03:20

Volker%20Barth's gravatar image

Volker Barth

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:

if( !sqlany_initialize_interface( &api, NULL ) ) {
    printf( "Could not initialize the interface!\n" );
    exit( 0 );

if( !api.sqlany_init( "Test1", SQLANY_API_VERSION_2, &max_api_ver )) {
    printf( "Failed to initialize the interface! Supported version = %d\n", max_api_ver );
    sqlany_finalize_interface( &api );
    return -1;

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

(06 Jan '12, 01:38) Dan Cleyne


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

(06 Jan '12, 10:34) Mohammed Abo...

Thanks Mohammad,

I have setup the paths and DYLD_LIBRARY_PATH the same way as are in the 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

(06 Jan '12, 15:49) Dan Cleyne


Turns out that even after setting up the environment variables in ./MacOSX/environment.plist, Xcode 4 overrides the DYLD_LIBRARY_PATH for the execution environment of the application in the debugger.

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

permanent link

answered 06 Jan '12, 18:20

Dan%20Cleyne's gravatar image

Dan Cleyne
accept rate: 25%

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text]( "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:


question asked: 05 Jan '12, 23:26

question was seen: 3,453 times

last updated: 09 Jan '12, 03:20