Search code examples
odbcsudoeiffel

Eiffel 18.07 trying to get an ODBC connection running from examples


Trying to just compile Eiffel_18.07/examples/store/esql/ on Debian 9 I've got following error:

In file included from od243.c:202:0,
                 from big_file_C8_c.c:42:
/opt/Eiffel_18.07/library/store/dbms/rdbms/odbc/Clib/odbc.h:27:17: fatal error: sql.h: No such file or directory
 #include <sql.h>
                 ^
compilation terminated.
Makefile:36: recipe for target 'big_file_C8_c.o' failed
make[1]: *** [big_file_C8_c.o] Error 1
Makefile:72: recipe for target 'C8/Cobj8.o' failed
make: *** [C8/Cobj8.o] Error 2
make: *** Waiting for unfinished jobs....

an apt-get install unixodbc unixodbc-dev odbc-postgresql got me further to

gcc: error: /opt/Eiffel_18.07/library/store/spec/linux-x86-64/lib/libodbc.a: No such file or directory
Makefile:177: recipe for target 'esql' failed

When I try to go to /opt/Eiffel_18.07/library/store/dbms/rdbms/odbc/Clib thinking I'll be able to generate some code to get it working following the /opt/Eiffel_18.07/library/store/install into /opt/Eiffel_18.07/library/store/dbms/rdbms/odbc/Clib trying a sudo /opt/Eiffel_18.07/studio/spec/linux-x86-64/bin/finish_freezing -library got

cp: cannot stat '/usr/include/eiffelstudio-18.07/config.sh': No such file or directory
Can't find config.sh.
Makefile.SH: 6: .: Can't open ./config.sh

Being a fan of Eiffel, it doesn't seem to be working out of the box and I didn't find enough documentation to get it working :-()


Solution

  • Here is a sequence of steps that allowed me to build the example on Ubuntu 16.04:

    1. Download and unpack EiffelStudio in a new directory (let's denote the absolute path as #ES#).

    2. Set environment variables:

      export ISE_EIFFEL=#ES#
      export ISE_PLATFORM=linux-x86-64
      export PATH=$PATH:$ISE_EIFFEL/studio/spec/$ISE_PLATFORM/bin
      

      These commands assume bash, replace them with equivalents when using another shell.

    3. Install package unixodbc-dev:

      sudo apt-get install unixodbc-dev
      
    4. Compile C code of the Eiffel library store:

      cd ${ISE_EIFFEL}/library/store/dbms/rdbms/odbc/Clib
      finish_freezing -library
      

      Note: no need to prefix finish_freezing with sudo unless EiffelStudio has been installed to a path without write permissions for ordinary users. Otherwise (e.g., for the original poster of the problem on Debian 9, where EiffelStudio has been installed under /opt), permissions have to be elevated:

      sudo -i
      cd ${ISE_EIFFEL}/library/store/dbms/rdbms/odbc/Clib
      finish_freezing -library
      exit
      
    5. Compile the example esql:

      cd ${ISE_EIFFEL}/examples/store/esql
      ec -c_compile -config esql.ecf -target esql_odbc
      
    6. Run the compiled executable:

      ./EIFGENs/esql_odbc/W_code/esql