Operating System - OpenVMS
1752805 Members
5668 Online
108789 Solutions
New Discussion юеВ

Re: 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 15
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.