Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

patch required to build oracle plugin, collectd-5.4.0 #653

Closed
komeda-shinji opened this issue Jun 20, 2014 · 8 comments
Closed

patch required to build oracle plugin, collectd-5.4.0 #653

komeda-shinji opened this issue Jun 20, 2014 · 8 comments

Comments

@komeda-shinji
Copy link
Contributor

@komeda-shinji komeda-shinji commented Jun 20, 2014

configure failed with Symbol 'OCIEnvCreate' not found.
$with_oracle_libs should be added in $LIBS, but $LDFLAGS

config.log

configure:22597: checking for OCIEnvCreate
configure:22597: gcc -o conftest -g -O2  -I/app/oracle/product/11.2.0/xe/rdbms/public  -L/app/oracle/product/11.2.0/xe/lib -lclntsh conftest.c -ldl  >&5
/tmp/ccEel8Uy.o: In function `main':
/usr/local/src/collectd-5.4.0/conftest.c:214: undefined reference to `OCIEnvCreate'
collect2: error: ld returned 1 exit status
configure:22597: $? = 1

This is fix.

diff -u configure.in- configure.in
--- configure.in-   2013-08-18 19:24:25.049973054 +0900
+++ configure.in    2014-06-20 18:00:16.857025560 +0900
@@ -2962,14 +2962,14 @@
 if test "x$with_oracle" = "xyes"
 then
    SAVE_CPPFLAGS="$CPPFLAGS"
-   SAVE_LDFLAGS="$LDFLAGS"
+   SAVE_LIBS="$LIBS"
    CPPFLAGS="$CPPFLAGS $with_oracle_cppflags"
-   LDFLAGS="$LDFLAGS $with_oracle_libs"
+   LIBS="$LIBS $with_oracle_libs"

    AC_CHECK_FUNC(OCIEnvCreate, [with_oracle="yes"], [with_oracle="no (Symbol 'OCIEnvCreate' not found)"])

    CPPFLAGS="$SAVE_CPPFLAGS"
-   LDFLAGS="$SAVE_LDFLAGS"
+   LIBS="$SAVE_LIBS"
 fi
 if test "x$with_oracle" = "xyes"
 then
diff -u configure- configure
--- configure-  2013-08-18 19:25:01.622558671 +0900
+++ configure   2014-06-20 18:00:40.409688597 +0900
@@ -22590,9 +22590,9 @@
 if test "x$with_oracle" = "xyes"
 then
    SAVE_CPPFLAGS="$CPPFLAGS"
-   SAVE_LDFLAGS="$LDFLAGS"
+   SAVE_LIBS="$LIBS"
    CPPFLAGS="$CPPFLAGS $with_oracle_cppflags"
-   LDFLAGS="$LDFLAGS $with_oracle_libs"
+   LIBS="$LIBS $with_oracle_libs"

    ac_fn_c_check_func "$LINENO" "OCIEnvCreate" "ac_cv_func_OCIEnvCreate"
 if test "x$ac_cv_func_OCIEnvCreate" = xyes; then :
@@ -22603,7 +22603,7 @@


    CPPFLAGS="$SAVE_CPPFLAGS"
-   LDFLAGS="$SAVE_LDFLAGS"
+   LIBS="$SAVE_LIBS"
 fi
 if test "x$with_oracle" = "xyes"
 then
@toni-moreno
Copy link
Contributor

@toni-moreno toni-moreno commented Jun 22, 2014

I've compiled ok (current master branch ) on rhel 5.9 with these oracle client libraries. ( RPM downloaded from oracle )

oracle-instantclient11.2-basic-11.2.0.4.0-1
oracle-instantclient11.2-devel-11.2.0.4.0-1

And before running ./configure I did the following link

/usr/lib/oracle/11.2/client64/rdbms/public -> /usr/include/oracle/11.2/client64

After that you can run ./configure like that:

./configure --with-oracle=/usr/lib/oracle/11.2/client64/

@komeda-shinji
Copy link
Contributor Author

@komeda-shinji komeda-shinji commented Jun 23, 2014

I am using Oracle Database Express Edition 11g Release 2 in Ubuntu 14.04 LTS.

But this problem caused by library option order, not the environment.
The library option -lclntsh should be placed after .c or .o modules.
That is,
not "gcc -o conftest -g -O2 $CPPFLAGS $with_oracle_libs conftest.c -ldl”,
but "gcc -o conftest -g -O2 $CPPFLAGS conftest.c -ldl $with_oracle_libs"

@toni-moreno
Copy link
Contributor

@toni-moreno toni-moreno commented Jun 23, 2014

With this settings my config.log is showing the following.

configure:42534: checking for OCIEnvCreate
configure:42591: gcc -o conftest -g  -I/usr/lib/oracle/11.2/client64//rdbms/public  -L/usr/lib/oracle/11.2/client64//lib -lclntsh conftest.c  >&5
configure:42597: $? = 0
configure:42601: test -z
                         || test ! -s conftest.err
configure:42604: $? = 0
configure:42607: test -s conftest
configure:42610: $? = 0
configure:42622: result: yes

current configure is finding the libraries as you can see.

The main difference between our config.logs are the "-ldl" you have after conftest.c

I hope this help you.

@komeda-shinji
Copy link
Contributor Author

@komeda-shinji komeda-shinji commented Jun 23, 2014

But my config.log is showing failure, undefined reference to OCIEnvCreate'`.
The test has "-ldl", (this is already shown at first)

configure:22597: checking for OCIEnvCreate
configure:22597: gcc -o conftest -g -O2  -I/app/oracle/product/11.2.0/xe/rdbms/public  -L/app/oracle/product/11.2.0/xe/lib -lclntsh conftest.c -ldl  >&5
/tmp/ccEel8Uy.o: In function `main':
/usr/local/src/collectd-5.4.0/conftest.c:214: undefined reference to `OCIEnvCreate'
collect2: error: ld returned 1 exit status
configure:22597: $? = 1

Why do you append $with_oracle_libs to $LDFLAGS not $LIBS?

@komeda-shinji
Copy link
Contributor Author

@komeda-shinji komeda-shinji commented Jun 23, 2014

when LDFLAGS="$LDFLAGS $with_oracle_libs" will fail.
I run gcc with "-v"

gcc -v -o conftest -g -O2  -I/app/oracle/product/11.2.0/xe/rdbms/public  -L/app/oracle/product/11.2.0/xe/lib -lclntsh conftest.c -ldl
/usr/lib/gcc/x86_64-linux-gnu/4.8/collect2 --sysroot=/ --build-id --eh-frame-hdr -m elf_x86_64 --hash-style=gnu --as-needed -dynamic-linker /lib64/ld-linux-x86-64.so.2 -z relro -o conftest /usr/lib/gcc/x86_64-linux-gnu/4.8/../../../x86_64-linux-gnu/crt1.o /usr/lib/gcc/x86_64-linux-gnu/4.8/../../../x86_64-linux-gnu/crti.o /usr/lib/gcc/x86_64-linux-gnu/4.8/crtbegin.o -L/app/oracle/product/11.2.0/xe/lib -L/usr/lib/gcc/x86_64-linux-gnu/4.8 -L/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../x86_64-linux-gnu -L/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../lib -L/lib/x86_64-linux-gnu -L/lib/../lib -L/usr/lib/x86_64-linux-gnu -L/usr/lib/../lib -L/usr/lib/gcc/x86_64-linux-gnu/4.8/../../.. -lclntsh /tmp/cc6UAkvW.o -ldl -lgcc --as-needed -lgcc_s --no-as-needed -lc -lgcc --as-needed -lgcc_s --no-as-needed /usr/lib/gcc/x86_64-linux-gnu/4.8/crtend.o /usr/lib/gcc/x86_64-linux-gnu/4.8/../../../x86_64-linux-gnu/crtn.o
/tmp/cc6UAkvW.o: In function `main':
/usr/local/src/collectd-5.4.0/conftest.c:231: undefined reference to `OCIEnvCreate'
collect2: error: ld returned 1 exit status

when LIBS="$LIBS $with_oracle_libs" works fine.

gcc -v -o conftest -g -O2  -I/app/oracle/product/11.2.0/xe/rdbms/public  conftest.c -ldl  -L/app/oracle/product/11.2.0/xe/lib -lclntsh
 /usr/lib/gcc/x86_64-linux-gnu/4.8/collect2 --sysroot=/ --build-id --eh-frame-hdr -m elf_x86_64 --hash-style=gnu --as-needed -dynamic-linker /lib64/ld-linux-x86-64.so.2 -z relro -o conftest /usr/lib/gcc/x86_64-linux-gnu/4.8/../../../x86_64-linux-gnu/crt1.o /usr/lib/gcc/x86_64-linux-gnu/4.8/../../../x86_64-linux-gnu/crti.o /usr/lib/gcc/x86_64-linux-gnu/4.8/crtbegin.o -L/app/oracle/product/11.2.0/xe/lib -L/usr/lib/gcc/x86_64-linux-gnu/4.8 -L/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../x86_64-linux-gnu -L/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../lib -L/lib/x86_64-linux-gnu -L/lib/../lib -L/usr/lib/x86_64-linux-gnu -L/usr/lib/../lib -L/usr/lib/gcc/x86_64-linux-gnu/4.8/../../.. /tmp/ccKKNh15.o -ldl -lclntsh -lgcc --as-needed -lgcc_s --no-as-needed -lc -lgcc --as-needed -lgcc_s --no-as-needed /usr/lib/gcc/x86_64-linux-gnu/4.8/crtend.o /usr/lib/gcc/x86_64-linux-gnu/4.8/../../../x86_64-linux-gnu/crtn.o
@mfournier
Copy link
Contributor

@mfournier mfournier commented Jun 24, 2014

It's a known fact that ubuntu's gcc is more strict than other distros wrt the options order:
https://wiki.ubuntu.com/ToolChain/CompilerFlags#A-Wl.2C--as-needed

I can't be of any help as I don't use oracle, but if you figure out a patch that fixes the build for ubuntu without breaking it for others, please submit a pull-request so it can be easily merged. Thanks :-)

komeda-shinji added a commit to komeda-shinji/collectd that referenced this issue Jun 25, 2014
@komeda-shinji
Copy link
Contributor Author

@komeda-shinji komeda-shinji commented Jun 25, 2014

Thank you, I submit a pull-request.

pyr added a commit that referenced this issue Jul 30, 2014
patch required to build oracle plugin, collectd-5.4.0 (#653)
@octo
Copy link
Member

@octo octo commented Sep 6, 2014

Merged by Marc.

@octo octo closed this Sep 6, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
4 participants
You can’t perform that action at this time.