Re: C++ templates and Oracle OCI on SPARC

From: Greg Brail <gjb_at_fig.citib.com>
Date: 24 Feb 1994 21:40:35 GMT
Message-ID: <2kj6sj$7jk_at_ftn.ftn.us-ny.citicorp.com>


In article <CLozzC.6op_at_butch.lmsc.lockheed.com>, Jason May <jmay_at_ctp.com> wrote:

>We're using Sun's SPARCCompiler C++ 3.0.1 to build a C++ program that
>uses the Oracle OCI library. The release version of this compiler could
>not handle C++ templates in libraries (static or shared).
>
>I got a patch for the compiler, patch# 100967-06. This appears to fix
>the template problem, but now the compiler is have trouble with the
>Oracle libraries.

I'm not sure what you mean by "not handle C++ templates in libraries". I have a library that uses templates, so I build a "fake" executable before linking the library so all my template symbols get instantiated, then I add "ptrepository/*.o" into the library along with all my other .o files. The "ptrepository" files have long names, but there's a script in the "C++ Selected Readings" part of the answerbook that comes with the compiler that deals with that. Unfortunately, Sun doesn't supply a printed copy of this manual.

There still seems to be one bug -- if you want such a library (that uses templates) to work properly, you ought to make both a shared and non-shared version of the library. "ptlink" will search the .a file for the template symbols, but for some reason it won't search the ".so".

Incidentially, the compilers and shared library implementation for Solaris 2.3 doesn't have any of these problems. You use "CC" to build a shared library, and it takes care of all the template problems for you. Very nice.

>At link time, I'm getting the following errors:
>
>nm: /usr/local/oracle/lib/libsqlnet.a:(osnpop.o): no name list
>nm: /usr/local/oracle/lib/libsqlnet.a:(osntei.o): no name list
>nm: /usr/local/oracle/lib/libsqlnet.a:(osntxo.o): no name list
>nm: /usr/local/oracle/lib/libsqlnet.a:(osnt3n.o): no name list
>nm: /usr/local/oracle/lib/libsqlnet.a:(snlm.o): no name list
>nm: /usr/local/oracle/lib/libsqlnet.a:(nttost.o): no name list
>nm: /usr/local/oracle/lib/libsqlnet.a:(ntt3n.o): no name list
>CC[ptlink] warning: ##### nm failed on /usr/local/oracle/lib/libsqlnet.a, ignoring ... #####

"ptlink" reads the ".a" files using nm, looking for template symbols. These error messages come from "nm". You can safely ignore them, since I assume "libsqlnet.a" is one of the Oracle libraries and you didn't use any templates in there.

>There's a similar bunch of errors for the libora.a and libnetwork.a
>libraries; after dumping out the error messages, the compile hangs.

Actually, it didn't hang. It's compiling the templates. If you did what I mentioned above and manually instantiated the template symbols in your library, it won't take as long. Otherwise, it could take hours. I suggest you link with the "-ptv" option -- this will show you what's going on during the link phase, but it'll still take hours in some cases. This is the time to read netnews, or to theorize about more efficent template-instantiation mechanisms, or to wonder why a 486 PC compiles C++ ten times faster than a Sparcstation Classic.

>These errors never appeared when compiling with the pre-patch version of
>the compiler.

The older version didn't check the library files at all for compiled-in template symbols, which I guess is what you meant when you said it didn't work with templates and libraries. Like I said -- ignore the errors.

                                greg

-- 
Greg Brail ------------------ Citibank -------------------- gjb_at_fig.citib.com
"All seven million Austrians and half the cows in Switzerland can
 ski faster than the U.S. Ski Team."
		-- Sports Illustrated, before the Winter Olympics
Received on Thu Feb 24 1994 - 22:40:35 CET

Original text of this message