cancel
Showing results for 
Search instead for 
Did you mean: 

Running dbcapi examples on mac osx?

Former Member
3,766

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

Former Member
0 Kudos

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

Former Member

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

Former Member
0 Kudos

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

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member

Ok,

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