Databases
cancel
Showing results for 
Search instead for 
Did you mean: 

How to compile multiple Pro*C programs in a C++ file

RaviKumar_8
Occasional Visitor

How to compile multiple Pro*C programs in a C++ file

Hi All,
Actually I have created one Pro*C program compiled and executed.And I called this Pro*C program from one C++ program(Pro*c program as a method in C++ program).I have compiled C++ program as well as pro*C program and linked both programs.Its working fine.

I tried to call two Pro*C routines from C++ program.But I am getting the following errors.
ld:Duplicate Symbol "sqlca" in files test.o and test1.o

Here test1.o and test.o are object files for Pro*C programs.So give some information to solve this problem.

Thanks in Advance,
Ravi Kumar.T



7 REPLIES
Peter Godron
Honored Contributor

Re: How to compile multiple Pro*C programs in a C++ file

Ravi,
please have a look at:
http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=72147&admit=-682735245+1139992559275+28353475

The problem is that symbols are defined in two files and can not be removed. The files have to be relinked.
Peter Godron
Honored Contributor

Re: How to compile multiple Pro*C programs in a C++ file

Ravi,
to summarize what I found out a long while back:
Amend LD_FLAGS to include
-Wl,-hsqlca,+allowdups

This may leave you with some warnings, but the code should run.
RaviKumar_8
Occasional Visitor

Re: How to compile multiple Pro*C programs in a C++ file

Hi,
I tried the option +allowdups then also i am getting the same error and warning message.
I am working in HP-UX 11i and Oracle 10g.

I have included sqlca.h in both of Pro*c files.
I am getting the following error.
aCC: warning 901: unknown option: `+allowdups': use +help for online documentation.
ld: Duplicate symbol "sqlca" in files down.o and down1.o
1 errors.

Thanks,
Ravi Kumar.T



Peter Godron
Honored Contributor

Re: How to compile multiple Pro*C programs in a C++ file

Ravi,
for the +allowdups your compiler/linker has to be at a certain version.
Try without the allowdups, but with -Wl,-hsqlca
RaviKumar_8
Occasional Visitor

Re: How to compile multiple Pro*C programs in a C++ file

Thank you Mr.Peter

I have tried to link using -WL,-hsqlca,+allowdups.Its working but giving the following warning msg.

ld: Overriding sqlca(OBJECT) in file down.o with symbol sqlca(OBJECT) in file d
wn1.o
1 warnings.

But its generating exe file and its working fine.If u don't mine Pls can u explain what is the meaning of "duplicate symbol".

Thanks & Regards,
Ravi Kumar.T
Arunvijai_4
Honored Contributor

Re: How to compile multiple Pro*C programs in a C++ file

Hi Ravi,

Take a look at this,

http://h21007.www2.hp.com/dspp/tech/tech_TechDocumentDetailPage_IDX/1,1701,386,00.html

Workaround for duplicate symbol errors

http://h21007.www2.hp.com/dspp/ml/showArchiveMessage/1,,4!03!11!0054,00.html

-Arun
"A ship in the harbor is safe, but that is not what ships are built for"
Peter Godron
Honored Contributor

Re: How to compile multiple Pro*C programs in a C++ file

Ravi,
the duplicate symbol message refers to information that appears more than once in the object code.
So you compile filea which pulls in some library code, which includes the label sqlca.
No problem.
You then compile fileb which pulls in some code which has the same label sqlca defined.
No problem.
But if you try to link the two object codes later, the linker says that there are two labels sqlca and it does not know which to use. The trick is to "optimise" the second label away when you link everything together.

Hope this explains it, at least to start.

http://forums1.itrc.hp.com/service/forums/helptips.do?#28