Operating System - OpenVMS
cancel
Showing results for 
Search instead for 
Did you mean: 

C++ link problem undefined symbol std::basic_string

Alex Chupahin
Super Advisor

C++ link problem undefined symbol std::basic_string

Hello!
In linking C++ I see undefined symbols.
Please help?

CXXL []cf_gen.obj,debug.obj,time.obj,globals.obj,squid/LIB,auth/LIB,[-.LIB]miscu
til/LIB
%LINK-W-MULDEF, symbol DECC$TOLOWER multiply defined
in module DECC$SHR file SYS$COMMON:[SYSLIB]DECC$SHR.EXE;1
%LINK-W-NUDFSYMS, 2 undefined symbols:
%LINK-I-UDFSYM, std::basic_ostringstream ,
std::allocator > ::basic_ostringstream(int)
%LINK-I-UDFSYM, std::basic_string , std::al
locator > std::basic_ostringstream , std::al
locator > ::str() const
%LINK-W-USEUNDEF, undefined symbol std::basic_string> , std::allocator > std::basic_ostringstream> , std::allocator > ::str() const referenced
in psect $LINK$ offset %X000014A0
in module DEBUG file SYS$SYSROOT:[SYSMGR.ALEX.GNU.SQUID.SQUID-3_0_STABLE
11.SRC]DEBUG.OBJ;1
%LINK-W-USEUNDEF, undefined symbol std::basic_ostringstreamts , std::allocator > ::basic_ostringstream(int) referenced
in psect $LINK$ offset %X00001640
in module DEBUG file SYS$SYSROOT:[SYSMGR.ALEX.GNU.SQUID.SQUID-3_0_STABLE
11.SRC]DEBUG.OBJ;1
15 REPLIES
Alex Chupahin
Super Advisor

Re: C++ link problem undefined symbol std::basic_string

Forget to say,
compiling with /DEF=(__USE_STD_IOSTREAM)
Steven Schweda
Honored Contributor

Re: C++ link problem undefined symbol std::basic_string

> %LINK-W-MULDEF, symbol DECC$TOLOWER multiply defined

If your source code contains its own
tolower() function, get rid of it. (Bad
"config.h" choices?)


> %LINK-I-UDFSYM, std::basic_ostringstream [...]

I know almost nothing about C++, but I'd
guess that you're calling basic_ostringstream
with argument types which don't match the
standard ones.
x2084
Trusted Contributor

Re: C++ link problem undefined symbol std::basic_string

Looks like C++ templates, which aren't found/ instantiated. If you compile in different directories, make sure that the linker can get to all [.CXX_REPOSITORY] directories. In one of them there should be an object file instantiating the template, that is defining the missing symbols. CXXLINK has a /REPOSITORY switch. HELP should explain how to use it. Also, check the documentation how template instantation is done, on Alpha.

And yes, get rid of the MULDEF, your copy of tolower used in the image, right now.
Alex Chupahin
Super Advisor

Re: C++ link problem undefined symbol std::basic_string

Unfortunately, cant solve the problem yet.

Things are more strange. I do not understand this things any more.

Previously I tried on 7.3-2. CXX is V7.3-009
Now I've tried the same sources with the same DESCRIP.MMS on the 8.2 with the same version of the compiler - another strange:
%LINK-I-UDFSYM, CURRENTDEBUG__5DEBUG
%LINK-I-UDFSYM, CXXL$CTQ13STD62BSCSTRNGC1626C2E
%LINK-W-USEUNDEF, undefined symbol CURRENTDEBUG__5DEBUG referenced
in psect $LINK$ offset %X00001450
in module DEBUG file SYS$SYSROOT:[SYSMGR.ALEX.GNU.SQUID.SQUID-3_0_STABLE11.SRC]DEBUG.OBJ;1
%LINK-W-USEUNDEF, undefined symbol CXXL$CTQ13STD62BSCSTRNGC1626C2E referenced
in psect $LINK$ offset %X00001D40
in module DEBUG file SYS$SYSROOT:[SYSMGR.ALEX.GNU.SQUID.SQUID-3_0_STABLE11.SRC]DEBUG.OBJ;1
Alex Chupahin
Super Advisor

Re: C++ link problem undefined symbol std::basic_string

And for finish:
so called *the best*

It seems tonn bugs in the HP C++ compiler ??

I'm compiling source files, as I do it many thousend times:
cxx /INCLUDE=([],[-],[-.include]) /DEFINE=(HAVE_CONFIG_H,__USE_STD_IOSTREAM) /OPTIMIZE=(INLINE=SPEED) /WARN
=(DIS=EXTRASEMI) AUTHSCHEME.CC

cxx /INCLUDE=([],[-],[-.include]) /DEFINE=(HAVE_CONFIG_H,__USE_STD_IOSTREAM) /OPTIMIZE=(INLINE=SPEED) /WARN
=(DIS=EXTRASEMI)AUTHUSER.CC

LIB/CREA AUTH AUTHSCHEME.OBJ,AUTHUSER.OBJ

I just got:
%LIBRAR-E-DUPGLOBAL, global symbol STRINGHASWHITESPACE from file SYS$SYSROOT:[SYSMGR.ALEX.GNU.SQUID.SQUID-3_0_STABLE11.SRC]AUTHSCHEM
E.OBJ;1 already in library SYS$SYSROOT:[SYSMGR.ALEX.GNU.SQUID.SQUID-3_0_STABLE11.SRC]auth.olb;1
%LIBRAR-E-DUPGLOBAL, global symbol STRINGHASWHITESPACE from file SYS$SYSROOT:[SYSMGR.ALEX.GNU.SQUID.SQUID-3_0_STABLE11.SRC]AUTHUSER.
OBJ;1 already in library SYS$SYSROOT:[SYSMGR.ALEX.GNU.SQUID.SQUID-3_0_STABLE11.SRC]auth.olb;1


The STRINGHASWHITESPACE is defined in header
as SQUIDCEXTERN int stringHasWhitespace(const char *);
SQUIDCEXTERN is defined

#ifdef __cplusplus
#define SQUIDCEXTERN extern "C"
#endif

And, I wish to say, there are lot of functions (about 30 or 40) defined exactly as stringHasWhitespace before and later that string. But troubles are only with stringHasWhitespace()

Please, I need your help
Alex Chupahin
Super Advisor

Re: C++ link problem undefined symbol std::basic_string

Ohh I forget to say (for a second time!)
This problem solves very very strange:

If I preprocess first the file
like
CXX ...MY FLAGS... /PREP file.cc
CXX file.ixx

I avoid the error with dublicate name.
Is it bug in CXX ??
x2084
Trusted Contributor

Re: C++ link problem undefined symbol std::basic_string

>>> %LINK-I-UDFSYM, CURRENTDEBUG__5DEBUG
%LINK-I-UDFSYM, CXXL$CTQ13STD62BSCSTRNGC1626C2E

This is the real thing, the Alpha linker, but you are linking C++. On Alpha you should always use CXXLINK if there are C++ modules included in the link operation.

I can't find CXXL$CTQ13STD62BSCSTRNGC1626C2E in the CXX OLBs on my system. I have no idea where it comes from and how to demangle it. If you use CXXLINK, the UDFSYM message will be demangled. That should give you a hint.

>>> LIB/CREA AUTH AUTHSCHEME.OBJ,AUTHUSER.OBJ

Looks odd to me. If there is a duplicate symbol in both object modules, you should see only one error message, here from AUTHUSER. /CREA creates a fresh library. But even if you replace both modules and there is a duplicate, you should only see a message from the last module. It looks like you already have a different module defining that symbol in the OLB. But that doesn't match your /CREA.

>>> SYS$SYSROOT:[SYSMGR.ALEX.GNU....

SYS$SYSROOT is a search list, I don't think you need it, I don't think it's the cause of your problem, but it may be confusing and I would avoid it, here.

>>> #ifdef __cplusplus
#define SQUIDCEXTERN extern "C"
#endif

This doesn't say anything about where the definition of the function is. You can always use "extern int foo();" and later on in the same source an "int foo(){return 0;}".

It looks like something is wrong with the macro definitions and/or the conditional compilation, as you indicate in the next reply. I would rather use /list/show=all to determine where the stringHasWhitespace() is defined.
Alex Chupahin
Super Advisor

Re: C++ link problem undefined symbol std::basic_string


>> This is the real thing, the Alpha linker,
>>but you are linking C++. On Alpha you
>>should always use CXXLINK if there are C++
>>modules included in the link operation.


I always use CXXLINK with any C++ programs/modules, not LINK.

What about undefined symbols? Please what do you think about?


>> I would rather use /list/show=all to
>>determine where the stringHasWhitespace()
>>is defined. "

Ok,
here is a fragment from LIS file:

-----------------------------------------------
I3 46192 SQUIDCEXTERN void kb_incr(kb_t *, size_t);
E extern "C" void kb_incr(kb_t *, size_t);
I3 46193 SQUIDCEXTERN int stringHasWhitespace(const char *);
E extern "C" int stringHasWhitespace(const char *);
I3 46194 SQUIDCEXTERN int stringHasCntl(const char *);
E extern "C" int stringHasCntl(const char *);
---------------------------------------------

How can you see, "SQUIDCEXTERN" is become
"extern "C""
Please note, Neither global stringHasCntl, no global kb_incr leads to such error.
stringHasWhitespace() only is.

And one more important thing.
No stringHasWhitespace() is using in that c++ sources either.


stringHasWhitespace() is only in a header...

Problems still here, what do you think about?
x2084
Trusted Contributor

Re: C++ link problem undefined symbol std::basic_string

>>> I always use CXXLINK with any C++ programs/modules, not LINK.

If you get the real linker messages with mangled names, then you either use LINK or CXXLINK doesn't have access to the CXX_REPORITORY with the demangle information. The latter may be the case if the object module wasn't compiled on your system. This application came as source code, right?, so I assume you compiled everything.

>>> What about undefined symbols? Please what do you think about?

CURRENTDEBUG__5DEBUG looks like a user defined function like currentDebug which expects a class/struct named "debug", or so. An application object module with its definition is missing in the link operation. Or, the source lines with the definition were not compiled.

CXXL$CTQ13STD62BSCSTRNGC1626C2E looks like a C++ name, which should be in one of the supplied C++ shareable images or OLBs. As I said, I can't find it on my system, but I have different compilers. On the other hand, CXXLINK should include these libraries for you.

>>> here is a fragment from LIS file:

The fragment shows the include file and the expansion of the macro SQUIDCEXTERN. Did you check the whole .LIS if and where the name "stringHasWhitespace" shows?

For only a 'extern "C" int stringHasWhitespace(const char *);' the C++ compiler will not define the global symbol STRINGHASWHITESPACE. LIBRARIAN only adds global symbols which define something (a function, an object) to the symbol table of the OLB. There should be more than just that "extern" line in this source.

It's unlikely that this is a C++ compiler bug.
Alex Chupahin
Super Advisor

Re: C++ link problem undefined symbol std::basic_string

>>LIBRARIAN only adds global symbols which
>>define something (a function, an object) to
>>the symbol table of the OLB. There should be
>>more than just that "extern" line in this
>>source.

Yes, of course. And please look to the strange thing, that I treat as fantastic behavor.

---------------------------------------------------
$cxx /INCLUDE=([],[-],[--.include]) /DEFINE=(__USE_STD_IOSTREAM)/WARN=DIS=EXTRASEMI/DEB /LIST/SHOW=ALL UFSCOMMON.CC

$ search UFSCOMMON.LIS stringHasWhitespace
I3 46190 SQUIDCEXTERN int stringHasWhitespace(const char *);
E extern "C" int stringHasWhitespace(const char *);
I1 50774 stringHasWhitespace(const char *s)
---------------------------------------------------
How can you see, there is a line 50774, a function definition statement, that generates a global symbol. And this statement is present on every OBJ and LIB shows duplicate symbol error. Ok.
But if I do split preprocessor stage and compilation by hands:
---------------------------------------------------
$cxx /INCLUDE=([],[-],[--.include]) /DEFINE=(__USE_STD_IOSTREAM)/WARN=DIS=EXTRASEMI /DEB /LIST/SHOW=ALL [.UFS]UFSCOMMON
.CC /PREP

$cxx /LIS=ufscommon_ixx.lis ufscommon.ixx

$search ufscommon_ixx.lis stringHasWhitespace

36045 extern "C" int stringHasWhitespace(const char *);

---------------------------------------------------

How can you see, no function definition statement (as it should be).
Any ideas?
Alex Chupahin
Super Advisor

Re: C++ link problem undefined symbol std::basic_string

"[.UFS]UFSCOMMON.CC"
please treat as "UFSCOMMON.CC" - when copy/paste from terminal I do make the mistake.
It is really pain that message cannot be edited after posting. :( :(

Alex Chupahin
Super Advisor

Re: C++ link problem undefined symbol std::basic_string

I start new thread devoted to "Strange behavor of C++" about duplicate names. Please answer there.

But about missing modules (topic of this thread) - I really do not understand what does it mean
"CXXLINK doesn't have access to the CXX_REPORITORY with the demangle information."

I login via SYSTEM account, compiling sources from scratch with usual keys.
Never use /REPOSITORY. I really do not need it. Other products are compiling fine.
Today I'll return to home and try once more on the 8.2 system.

But what about error I got on the 7.3-2 ?
---------------------------------------------------
%LINK-W-NUDFSYMS, 2 undefined symbols:
%LINK-I-UDFSYM, std::basic_ostringstream ,
std::allocator > ::basic_ostringstream(int)
%LINK-I-UDFSYM, std::basic_string , std::al
locator > std::basic_ostringstream , std::al
locator > ::str() const
%LINK-W-USEUNDEF, undefined symbol std::basic_string> , std::allocator > std::basic_ostringstream> , std::allocator > ::str() const referenced
in psect $LINK$ offset %X000014A0
in module DEBUG file SYS$SYSROOT:[SYSMGR.ALEX.GNU.SQUID.SQUID-3_0_STABLE
11.SRC]DEBUG.OBJ;1
%LINK-W-USEUNDEF, undefined symbol std::basic_ostringstreamts , std::allocator > ::basic_ostringstream(int) referenced
in psect $LINK$ offset %X00001640
in module DEBUG file SYS$SYSROOT:[SYSMGR.ALEX.GNU.SQUID.SQUID-3_0_STABLE
11.SRC]DEBUG.OBJ;1
------------------------------------------------------

Alex Chupahin
Super Advisor

Re: C++ link problem undefined symbol std::basic_string

ostringstream description is really present in sstream.h
is it mean that STDC++ library does not contain
such function?
Bug?
x2084
Trusted Contributor

Re: C++ link problem undefined symbol std::basic_string

>>> ostringstream description is really present in sstream.h

Please read the documentation about templates in C++ on OpenVMS/Alpha.

>>> I start new thread devoted to "Strange behavor of C++" about duplicate names.

If you don't mind, I add my comments, here.
Squid comes with "String.cc", the compiler wants/needs its "string.cc", it finds your/Squid's [...SRC]STRING.CC and includes it. That defines stringHasWhiteSpace().

No, defining _USE_INLINE_ 1 or 0 doesn't help. Sorry, I don't have the time to try what the C++ compiler does on ODS5.

Alex Chupahin
Super Advisor

Re: C++ link problem undefined symbol std::basic_string

It seems I should find solution at another place