[csw-maintainers] need help with C++ linker error from Sun's linker

James Lee james at opencsw.org
Thu May 28 11:09:54 CEST 2009


On 27/05/09, 19:25:50, John Ellson <ellson at opencsw.org> wrote regarding
[csw-maintainers] need help with C++ linker error from Sun's linker:

> If I compile liblasi (mgar/pkg/liblasi/trunk) using g++ it compiles and
> links without problem.

> If I use Sun's tools  (remove the line: "CXX=/opt/csw/gcc4/bin/g++ \"
> from the Makefile)
> then I get this error:

...

> Undefined                       first referenced
>  symbol                             in file
> void LASi::PostscriptDocument::setFont(const
>
char*const,LASi::FontStyle,LASi::FontWeight,LASi::FontVariant,LASi::Font
St
retch)
> CMakeFiles/example0.dir/MissingGlyphExample.o
> ld: fatal: Symbol referencing errors. No output written to example0



> There's something odd about the "const char*const"   but I don't know if
> thats related.


I think you've almost answered your own question.   gcc does not use
"const" type qualifier for types passed by value when making external
names.  So "const char*const" is the same as "const char*" on the call
because the value is copied anyway (the second "const" is of benefit to
the compiler in the function only).  Nevertheless CC likes consistency
so try matching the "const"s in all function declarations.




$ cat sub.cc
void sub(const char*const arg)
{
    return;
}

$ g++ -c sub.cc
$ nm -C sub.o


sub.o:

[Index]   Value      Size    Type  Bind  Other Shndx   Name

[2]     |         0|       0|SECT |LOCL |0    |1      |
[3]     |         0|       0|SECT |LOCL |0    |2      |
[4]     |         0|       0|SECT |LOCL |0    |3      |
[5]     |         0|       0|SECT |LOCL |0    |4      |
[6]     |         0|      16|FUNC |GLOB |0    |1      |sub(const char*)
                                                       [_Z3subPKc]
[1]     |         0|       0|FILE |LOCL |0    |ABS    |sub.cc

$ CC -c sub.cc
$ nm -C sub.o


sub.o:

[Index]   Value      Size    Type  Bind  Other Shndx   Name

[1]     |         0|       0|FILE |LOCL |0    |ABS    |sub.cc
[2]     |        16|      24|FUNC |GLOB |0    |2      |void sub(const
char*const)

[__1cDsub6Fkpkc_v_]




James.



More information about the maintainers mailing list