kubo / ruby-oci8

Ruby-oci8 - Oracle interface for ruby
Other
169 stars 75 forks source link

installing gem on archlinux fails with OCIEnvCreate() in oci.h... no #229

Open ciapecki opened 3 years ago

ciapecki commented 3 years ago

I have oracle-instantclient-basic installed on my Arch Linux. There is no instantclient folder. The libraries are in /usr/lib

usr/lib/libclntsh.so
usr/lib/libclntsh.so.21
usr/lib/libclntsh.so.21.1
usr/lib/libclntshcore.so
usr/lib/libclntshcore.so.21
usr/lib/libclntshcore.so.21.1
usr/lib/libnnz21.so
usr/lib/libocci.so
usr/lib/libocci.so.21
usr/lib/libocci.so.21.1

oracle-instantclient-sdk installs into /usr/include/:

usr/include/oci.h

I try to install gem for ruby 2.7.0 ruby 2.7.0p0 (2019-12-25 revision 647ee6f091) [x86_64-linux]

$ gem install ruby-oci8 fails with:

Building native extensions. This could take a while...
ERROR:  Error installing ruby-oci8:
    ERROR: Failed to build gem native extension.

    current directory: /home/chris/.rvm/gems/ruby-2.7.0/gems/ruby-oci8-2.2.9/ext/oci8
/home/chris/.rvm/rubies/ruby-2.7.0/bin/ruby -I /home/chris/.rvm/rubies/ruby-2.7.0/lib/ruby/2.7.0 -r ./siteconf20210129-1455963-oh6ty3.rb extconf.rb
attempting to locate oracle-instantclient...
checking load library path...
  LD_LIBRARY_PATH is not set.
  checking ld.so.conf... yes
no
  /usr/lib/libclntsh.so.21.1 looks like an instant client.
checking for cc... ok
checking for gcc... yes
checking for LP64... yes
checking for sys/types.h... yes
checking for ruby header... ok
checking for OCIEnvCreate() in oci.h... no
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers.  Check the mkmf.log file for more details.  You may
need configuration options.

Is there a way to install it successfully?

BTW. sqlplus works fine

last 100 lines of mkmf.log:

$ tail -100 /home/chris/.rvm/gems/ruby-2.7.0/extensions/x86_64-linux/2.7.0/ruby-oci8-2.2.9/mkmf.log
11720 |                              const OCISodaColl   *coll,
      |                                    ^~~~~~~~~~~
/usr/include/ociap.h:11723:30: error: unknown type name ‘OCISodaDoc’
11723 |                              OCISodaDoc          *document,
      |                              ^~~~~~~~~~
/usr/include/ociap.h:11729:41: error: unknown type name ‘OCISodaColl’
11729 |                                   const OCISodaColl  *coll,
      |                                         ^~~~~~~~~~~
/usr/include/ociap.h:11732:35: error: unknown type name ‘OCISodaDoc’
11732 |                                   OCISodaDoc        **document,
      |                                   ^~~~~~~~~~
/usr/include/ociap.h:11739:28: error: unknown type name ‘OCISodaColl’
11739 |                      const OCISodaColl               *coll,
      |                            ^~~~~~~~~~~
/usr/include/ociap.h:11740:28: error: unknown type name ‘OCISodaOperationOptions’
11740 |                      const OCISodaOperationOptions   *optns,
      |                            ^~~~~~~~~~~~~~~~~~~~~~~
/usr/include/ociap.h:11747:37: error: unknown type name ‘OCISodaColl’
11747 |                               const OCISodaColl  *coll,
      |                                     ^~~~~~~~~~~
/usr/include/ociap.h:11757:23: error: unknown type name ‘OCISodaColl’; did you mean ‘OCIColl’?
11757 |                       OCISodaColl *coll,
      |                       ^~~~~~~~~~~
      |                       OCIColl
/usr/include/ociap.h:11764:32: error: unknown type name ‘OCISodaColl’
11764 |                          const OCISodaColl *coll,
      |                                ^~~~~~~~~~~
/usr/include/ociap.h:11778:33: error: unknown type name ‘OCISodaColl’
11778 |                           const OCISodaColl  *collection,
      |                                 ^~~~~~~~~~~
/usr/include/ociap.h:11780:27: error: unknown type name ‘OCISodaDoc’
11780 |                           OCISodaDoc        **doc,
      |                           ^~~~~~~~~~
/usr/include/ociap.h:11785:33: error: unknown type name ‘OCISodaColl’
11785 |                           const OCISodaColl  *collection,
      |                                 ^~~~~~~~~~~
/usr/include/ociap.h:11792:22: error: unknown type name ‘OCIAsync’
11792 |                      OCIAsync *asynchp,
      |                      ^~~~~~~~
/usr/include/ociap.h:11796:24: error: unknown type name ‘OCIAsync’
11796 | sword OCIAsyncDisable (OCIAsync *asynchp,
      |                        ^~~~~~~~
/usr/include/ociap.h:11800:22: error: unknown type name ‘OCIAsync’
11800 | sword OCIAsyncFdGet (OCIAsync *asynchp,
      |                      ^~~~~~~~
/usr/include/ociap.h:11806:31: error: unknown type name ‘OCIAsync’
11806 | sword OCIAsyncCoroutineSubmit(OCIAsync *asynchp,
      |                               ^~~~~~~~
/usr/include/ociap.h:11807:31: error: unknown type name ‘OCIAsyncCoroutine’
11807 |                               OCIAsyncCoroutine *proc,
      |                               ^~~~~~~~~~~~~~~~~
/usr/include/ociap.h:11813:23: error: unknown type name ‘OCIAsync’
11813 | sword OCIAsyncWaitOne(OCIAsync  *asynchp,
      |                       ^~~~~~~~
/usr/include/ociap.h:11819:24: error: unknown type name ‘OCIAsync’
11819 | sword OCIAsyncWaitMany(OCIAsync **asynchp,
      |                        ^~~~~~~~
/usr/include/ociap.h:11822:24: error: unknown type name ‘OCIAsync’
11822 |                        OCIAsync **readyp,
      |                        ^~~~~~~~
/usr/include/ociap.h:11827:31: error: unknown type name ‘OCIAsync’
11827 | sword OCIAsyncCoroutineResume(OCIAsync *asynchp,
      |                               ^~~~~~~~
/usr/include/ociap.h:11831:30: error: unknown type name ‘OCIAsync’
11831 | sword OCIAsyncCoroutineAbort(OCIAsync *asynchp,
      |                              ^~~~~~~~
conftest.c:16:13: error: conflicting types for ‘OCIEnvCreate’
   16 | extern void OCIEnvCreate();
      |             ^~~~~~~~~~~~
In file included from /usr/lib/sdk/include/oci.h:3456,
                 from conftest.c:3:
/usr/include/ociap.h:7341:9: note: previous declaration of ‘OCIEnvCreate’ was here
 7341 | sword   OCIEnvCreate (OCIEnv **envp, ub4 mode, void  *ctxp,
      |         ^~~~~~~~~~~~
cc1: note: unrecognized command-line option ‘-Wno-self-assign’ may have been intended to silence earlier diagnostics
cc1: note: unrecognized command-line option ‘-Wno-parentheses-equality’ may have been intended to silence earlier diagnostics
cc1: note: unrecognized command-line option ‘-Wno-constant-logical-operand’ may have been intended to silence earlier diagnostics
checked program was:
/* begin */
 1: #include "ruby.h"
 2:
 3: #include <oci.h>
 4:
 5: /*top*/
 6: extern int t(void);
 7: int main(int argc, char **argv)
 8: {
 9:   if (argc > 1000000) {
10:     int (* volatile tp)(void)=(int (*)(void))&t;
11:     printf("%d", (*tp)());
12:   }
13:
14:   return !!argv[argc];
15: }
16: extern void OCIEnvCreate();
17: int t(void) { OCIEnvCreate(); return 0; }
/* end */

--------------------

It seems that wrong oci.h is used (from /usr/lib/sdk/include instead of /usr/include as installed by oracle-instantclient-sdk)

In file included from /usr/lib/sdk/include/oci.h:3456,
                 from conftest.c:3:
/usr/include/ociap.h:11450:25: error: unknown type name ‘OCISodaColl’; did you mean ‘OCIColl’?
11450 |                         OCISodaColl    **collection,
      |                         ^~~~~~~~~~~
      |                         OCIColl

How can I tell to use different oci.h?

My dirty solution was to replace oci.h in /usr/lib/sdk/include with the one from /usr/include.

Now gem installs fine 👍