vrogier / ocilib

OCILIB (C and C++ Drivers for Oracle) - Open source C and C++ library for accessing Oracle databases
http://www.ocilib.net
Apache License 2.0
325 stars 119 forks source link

windows vs2019 OCI_ERR_LOADING_SHARED_LIB #315

Closed hewittzgh closed 2 years ago

hewittzgh commented 2 years ago

@vrogier Hi! I am trying to use ocilib. my environment is win11, vs2019. my C code is as follows:

OCI_Connection* oracle_cn;
OCI_Statement* oracle_st;
OCI_Resultset* oracle_rs;

if (!OCI_Initialize(oracle_err_handler, NULL, OCI_ENV_DEFAULT))
{
printf("Init Fail!");
return EXIT_FAILURE;
}

// ...

The function "OCI_Initialize" can not work. I get OCI_ErrorGetType and OCI_ERR_LOADING_SHARED_LIB error. I tried the method in the link, but I couldn't solve it. Can you give me some suggestions?

hewittzgh commented 2 years ago

PS: I install the ocilib 4.7.3 package through NuGet package manager. Of course, I had tested 4.7.2/4.7.1/4.7.0 version and tried to install it by configure the vs project manually, but it never worked.

vrogier commented 2 years ago

Hi,

Have you install an oracle client or downloaded an instant client package? If not, there error is normal. OCILIB relies on oracle OCI client libraries to interact with Oracle databases.

Regards,

Vincent

hewittzgh commented 2 years ago

Thanks! I will try. If it works, I will close the issue.

hewittzgh commented 2 years ago

@vrogier Hi! I have solved the initialization problem. But when I connect the oracle server, I find the OCI_ConnectionCreate api return NULL. My OCI client library version is 11.2.0.4.0 basic. Do you known what causes this problem? Thank you! My code: oracle_cn = OCI_ConnectionCreate("<ip>:<port>", "<username>", "<password>", OCI_SESSION_DEFAULT);

vrogier commented 2 years ago

The first parameter can be:

You can check oracle documentation for more details.

In your example, the easy connect string is not correct.

Easy connect string is host:port/servicename.

Regards,

Vincent

vrogier commented 2 years ago

Hi, Any news ?

vrogier commented 2 years ago

Closing the issue as no news from OP and given information provided, invalid connection string was used.