Skip to Main Content

DevOps, CI/CD and Automation

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

g++ error......Multiple defnitions for oraca and sqlca

858326Oct 20 2011 — edited Oct 21 2011
Hi All,

I have come across the following error when trying to compile the source code using g++.
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/iostream:76: multiple definition of `oraca'
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/new:94: multiple definition of `sqlca'
One common header is including sql2oci.h+. We are trying to create one shared library from many *.cc* files. Most of them include sql2oci.h+.

The following example shows the exact scenario.

sql2oci1.cc
      #include <sql2oci.h>
      #include <iostream>

      void display()
      {
        std::cout << "I am sqlca-1" << std::endl;
      }
sql2oci2.cc
      #include <sql2oci.h>
      #include <iostream>

      extern void display();

      int main() {
        display();
        std::cout << "I am sqlca-2" << std::endl;

        return 0;
      }
$ g++ -m32 -Wall -g -c -I/app/oracle/client/precomp/public -I/app/oracle/client/rdbms/public -o sql2oci1.o sql2oci1.cc
$ g++ -m32 -Wall -g -c -I/app/oracle/client/precomp/public -I/app/oracle/client/rdbms/public -o sql2oci2.o sql2oci2.cc
$ g++ -m32 -Wall -g -o sample sql2oci1.o sql2oci2.o
sql2oci2.o: In function `__static_initialization_and_destruction_0':
/data1/users/nfr1dev2/port_gcc/sql2oci2.cc:11: multiple definition of `sqlca'
sql2oci1.o:/data1/users/nfr1dev2/port_gcc/sql2oci1.cc:7: first defined here
sql2oci2.o: In function `main':
/data1/users/nfr1dev2/port_gcc/sql2oci2.cc:8: multiple definition of `oraca'
sql2oci1.o:(.bss+0xa0): first defined here
collect2: ld returned 1 exit status
In the header, sql2oci.h+, the structs oraca and sqlca are defined.
When i am trying to combine several *.o* files to produce a binary/library, the compiler is seeing the definitons of oraca and sqlca being included from different obj files.

Can someone suggest a solution...or.....any work-around for this?

Thanks in advance.

Cheers,
Sreekar

Edited by: 855323 on 20-Oct-2011 02:15
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Nov 18 2011
Added on Oct 20 2011
2 comments
2,723 views