[omniORB] linking error (duplicated-simbol) only
withoption(-g)
Alberto Casado
acasado at ya.com
Wed Nov 30 20:53:52 GMT 2005
Hi again Luke, i have posted this error on Sun forum and i was told what the
problem is. If some one is interested here is a copy.
"""
...
Namespaces are not supported in -compat=4 mode. The only effect
of -features=namespace is to recognize "namespace" as a keyword, and
disallow it as an identifier. You don't actually get namespace semantics.
The pupose of -compat=4 is to allow code written for C++ 4.x to compile and
run until the code can be updated to conform to the C++ Standard. If you
want to use features from the C++ standard, like namespaces, you must use
Sun C++ in the default standard mode.
If you remove -compat=4, the code compiles and links. If you need to
use -compat=4 mode, remove uses of namespace, and fix the code to remove
name conflicts.
......
Why i only have this problem when compiling with debuger information (-g)?.
When you compile with -g, the compiler globalizes static objects and
functions to make them available to the debugger. The compiler also emits
emits non-global unused entities that otherwise might not be emitted. You
can easily expose name conflicts using -g that are otherwise hidden.
.....
""""
http://forum.sun.com/thread.jspa?threadID=27748&tstart=0
Now i will rebuild omniORB without namespace and i hope then all works right
best regards
Alberto
----- Original Message -----
From: <acasado at ya.com>
To: <ldeller at xplantechnology.com>
Cc: <acasado at ya.com>
Sent: Thursday, November 24, 2005 6:17 PM
Subject: Re: Re: Re: [omniORB] linking error (duplicated-simbol) only
withoption(-g)
hi Luke, you were right, my example was wrong .
I wrote an example with static an const member class and this
example compile and work with and without -g, but when I add
an const value in a namespace, i found the error again. I know
my english is very bad, let me show you the code:
************************************************
************
file ejemplo.h
#ifndef _EJEMPLO_H_
#define _EJEMPLO_H_
namespace Ejemplo
{
const int version=1;
static const char* name="Alberto";
class Dummy
{
public:
Dummy():version(12)
{
}
static const char* name;
const int version ;
};
};
#endif
--------------------------------------------------------------
--
file ejemplo.cc
#include "ejemplo.h"
namespace Ejemplo
{
const char* Dummy::name = "Dummy Class";
};
************************************************
**************
************************************************
**************
file ejemplo2.h
#ifndef _EJEMPLO_2_H_
#define _EJEMPLO_2_H_
#include "ejemplo.h"
namespace Ejemplo
{
class Dummy2
{
private:
Dummy _d;
public:
void doit();
};
};
#endif
--------------------------------------------------------------
--
file ejemplo2.cc
#include "ejemplo2.h"
#include <iostream.h>
using namespace Ejemplo;
void Dummy2::doit()
{
cout << name <<" " << version << endl;
cout << _d.name <<" "<< _d.version << endl;
}
************************************************
**************
************************************************
**************
file ejemplo3.h
#ifndef _EJEMPLO_3_H_
#define _EJEMPLO_3_H_
#include "ejemplo.h"
namespace Ejemplo
{
class Dummy3
{
private:
Dummy _d;
public:
void doit();
};
};
#endif
--------------------------------------------------------------
file ejemplo3.cc
#include "ejemplo3.h"
#include <iostream.h>
using namespace Ejemplo;
void Dummy3::doit()
{
cout << _d.name <<" "<< _d.version << endl;
}
************************************************
**************
************************************************
**************
file ejemplo_main.cc
#include <iostream.h>
#include "ejemplo2.h"
#include "ejemplo3.h"
using namespace Ejemplo;
int main()
{
cout << name << " " << version << endl;
Dummy2 d2;
Dummy3 d3;
d2.doit();
d3.doit();
}
************************************************
**************
Makefile
CC_DIR=/export/opt/SUNWspro/SC5.0/bin
CCC=$(CC_DIR)/CC
LIBRERIA=libejemploMain.a
OBJ= ejemplo.o ejemplo2.o ejemplo3.o ejemplo_main.o
EJE=main_ejemplo
all:$(LIBRERIA)
$(CCC) -compat=4 -features=bool,namespace -o $(EJE) -
lejemploMain
$(LIBRERIA):$(OBJ)
$(CCC) -compat=4 -features=bool,namespace -xar -o
$(LIBRERIA) $(OBJ)
%.o:%.cc
$(CCC) -compat=4 -features=bool,namespace -I. -c -o
$@ $<
clean:
rm -f $(OBJ)
rm -f $(LIBRERIA)
rm -f $(EJE)
rm -rf SunWS_cache
~
~
************************************************
**************
and now let compile, first without -g
/home/ipu01/IPU_ALBERTO/corba/tmp:ipu01=> make -f
Makefile.E
/export/opt/SUNWspro/SC5.0/bin/CC -compat=4 -
features=bool,namespace -I. -c -o ejemplo.o ejemplo.cc
/export/opt/SUNWspro/SC5.0/bin/CC -compat=4 -
features=bool,namespace -I. -c -o ejemplo2.o ejemplo2.cc
/export/opt/SUNWspro/SC5.0/bin/CC -compat=4 -
features=bool,namespace -I. -c -o ejemplo3.o ejemplo3.cc
/export/opt/SUNWspro/SC5.0/bin/CC -compat=4 -
features=bool,namespace -I. -c -o ejemplo_main.o
ejemplo_main.cc
/export/opt/SUNWspro/SC5.0/bin/CC -compat=4 -
features=bool,namespace -xar -o libejemploMain.a ejemplo.o
ejemplo2.o ejemplo3.o ejemplo_main.o
/export/opt/SUNWspro/SC5.0/bin/CC -compat=4 -
features=bool,namespace -o main_ejemplo -lejemploMain
edit Makefile and add -g
/home/ipu01/IPU_ALBERTO/corba/tmp:ipu01=> make -f
Makefile.E clean
rm -f ejemplo.o ejemplo2.o ejemplo3.o ejemplo_main.o
rm -f libejemploMain.a
rm -f main_ejemplo
rm -rf SunWS_cache
/home/ipu01/IPU_ALBERTO/corba/tmp:ipu01=> make -f
Makefile.E
/export/opt/SUNWspro/SC5.0/bin/CC -g -compat=4 -
features=bool,namespace -I. -c -o ejemplo.o ejemplo.cc
/export/opt/SUNWspro/SC5.0/bin/CC -g -compat=4 -
features=bool,namespace -I. -c -o ejemplo2.o ejemplo2.cc
/export/opt/SUNWspro/SC5.0/bin/CC -g -compat=4 -
features=bool,namespace -I. -c -o ejemplo3.o ejemplo3.cc
/export/opt/SUNWspro/SC5.0/bin/CC -g -compat=4 -
features=bool,namespace -I. -c -o ejemplo_main.o
ejemplo_main.cc
/export/opt/SUNWspro/SC5.0/bin/CC -compat=4 -
features=bool,namespace -xar -o libejemploMain.a ejemplo.o
ejemplo2.o ejemplo3.o ejemplo_main.o
/export/opt/SUNWspro/SC5.0/bin/CC -compat=4 -
features=bool,namespace -o main_ejemplo -lejemploMain
ld: fatal: symbol `Ejemplo::name' is multiply-defined:
(file ./libejemploMain.a(ejemplo_main.o) type=OBJT;
file ./libejemploMain.a(ejemplo2.o) type=OBJT);
ld: fatal: symbol `Ejemplo::version' is multiply-defined:
(file ./libejemploMain.a(ejemplo_main.o) type=OBJT;
file ./libejemploMain.a(ejemplo2.o) type=OBJT);
ld: fatal: symbol `Ejemplo::name' is multiply-defined:
(file ./libejemploMain.a(ejemplo_main.o) type=OBJT;
file ./libejemploMain.a(ejemplo3.o) type=OBJT);
ld: fatal: symbol `Ejemplo::version' is multiply-defined:
(file ./libejemploMain.a(ejemplo_main.o) type=OBJT;
file ./libejemploMain.a(ejemplo3.o) type=OBJT);
ld: fatal: symbol `Ejemplo::name' is multiply-defined:
(file ./libejemploMain.a(ejemplo_main.o) type=OBJT;
file ./libejemploMain.a(ejemplo.o) type=OBJT);
ld: fatal: symbol `Ejemplo::version' is multiply-defined:
(file ./libejemploMain.a(ejemplo_main.o) type=OBJT;
file ./libejemploMain.a(ejemplo.o) type=OBJT);
ld: fatal: File processing errors. No output written to
main_ejemplo
*** Error code 1
make: Fatal error: Command failed for target `all'
/home/ipu01/IPU_ALBERTO/corba/tmp:ipu01=>
if i compiled whiout -compat=4 (standard mode), the example
compile and work, with and without -g .
if I remove this constants
namespace Ejemplo
{
const int version=1;
static const char* name="Alberto";
}
the example compile and work.
Finally i do not know if i am doing something with constants
that C++ does not permit, or it is compiler bug.
I do not know if it has a solution but i would like to know what
do you think about it.
Regards,
Alberto
>Hi Alberto,
>The errors you report are all related to static class members in
code
>generated by omniidl. (I wonder how the generated code
differs from
>your other test code).
>-g should not affect whether symbols are multiply defined; if it
does,
>then you have probably hit a compiler bug. Either the compiler
bug
>needs to be fixed by Sun, or we need to find a workaround.
>My only suggestion at this point would be to try to narrow
down the
>problematic code to a small example program which causes
your compiler
>to produce this error. This should help to understand the
problem well
>enough to find a workaround and/or report a bug to Sun.
>Regards,
>Luke.
>On Mon, 2005-11-21 at 18:20 +0100, <a
href="javascript:sendMsg
('acasado at ya.com');">acasado at ya.com</a> wrote:
>>
>> Hello Luke, thanks for your answer.
>> I have been testing with those macros, but i cant
resolve
>> the problem. I have verified that the compiler have no
problem
>> with the static class members which are initialised in the
header
>> file with other code i write . And I have compiled this code
with
>> an without -g . And it works.
>> I only have problems with code generated by omniORB
>> when i try to compile with -g.
>>
>> If you have other suggestion I would thank you .
>>
>> Alberto Casado
>>
>>
>>
>>
>>
>> >It looks like your compiler in its compatibility mode is having
>> problems
>> >with static class members which are initialised in the
header
>> file.
>> >Microsoft's C++ compiler also has problems with this.
>> >There is a workaround which causes these static class
>> members to be
>> >initialised in the c++ file rather than the header file for
>> Microsoft's
>> >compiler. You might want to try enabling this workaround
for
>> yourself
>> >too. Look for the definition of the macros _init_in_cldef_
and
>> >_init_in_cldecl_ in omniORB4/CORBA_sysdep.h
>> >Regards,
>> >Luke.
>> >On Thu, 2005-11-17 at 09:00 +0100, <a
>> href="javascript:sendMsg
>> <a href="javascript:sendMsg
('('acasado at ya.com');">acasado at ya.com</a>');">
('acasado at ya.com');">acasado at ya.com</a></a> wrote:
>> >>
>> >> It is me again, i forgot to put the subject.
>> >>
>> >> **************************************
>> >>
>> >> Hello, I am looking for help.
>> >>
>> >> I have download and compiled the omniORB (omniORB-
4.0.5)
>> on
>> >> SunOS 2.8 with CC (5.0) on compatibility mode (-
compat=4)
>> >> because i have legacy code that does not compile in
standar
>> >> mode.
>> >>
>> >> When i try to compile any code generated by omniidl
with
>> >> option (-g) to enable debbug information, I have
>> duplicated-
>> >> symbol at linking, like :
>> >>
>> >> //export/opt/SUNWspro/SC5.0/bin/CC -c -KPIC -g -w -
mt -
>> g -
>> >> DTHREAD -DSOLARIS -compat=4 -
>> features=bool,namespace -
>> >> DSVR4 -
>> I/home/ipu01/IPU_ALBERTO/corba/cpp/src/../inc/ -
>> >> I/home/ipu01/local_CC//include -
>> >>
>>
o /home/ipu01/IPU_ALBERTO/corba/cpp/obj/ipuFactoryInterfaces
>> >> SK.o ipuFactoryInterfacesSK.cc
>> >> Compilation done.
>> >> Haciendo la libreria
>> >>
>>
dinamica /home/ipu01/IPU_ALBERTO/corba/cpp/src/../lib//libipuC
>> >> orba.so
>> >> /export/opt/SUNWspro/SC5.0/bin/CC -G -
>> >> L/home/ipu01/IPU_ALBERTO/corba/cpp/src/../lib/ -
>> >> L/home/ipu01/local_CC//lib -L/usr/lib/ -
>> >>
>>
o /home/ipu01/IPU_ALBERTO/corba/cpp/src/../lib//libipuCorba.so
>>
>> /home/ipu01/IPU_ALBERTO/corba/cpp/src/../obj/ipuDataSK.o
>> /h
>> >>
>>
ome/ipu01/IPU_ALBERTO/corba/cpp/src/../obj/ipuManagerSK.o /
>> >>
>>
home/ipu01/IPU_ALBERTO/corba/cpp/src/../obj/ipuDefinitionsSK.
>> >>
>>
o /home/ipu01/IPU_ALBERTO/corba/cpp/src/../obj/ipuInterfaces
>> >>
>>
SK.o /home/ipu01/IPU_ALBERTO/corba/cpp/src/../obj/ipuFactory
>> >> InterfacesSK.o
>> >>
>> >> ld: fatal: symbol
>> >> `PortableServer::IMPLICIT_ACTIVATION_POLICY_ID' is
>> multiply-
>> >> defined:
>> >>
>> >>
>>
(file /home/ipu01/IPU_ALBERTO/corba/cpp/src/../obj/ipuDataSK.o
>> >> type=OBJT;
>> >>
>>
file /home/ipu01/IPU_ALBERTO/corba/cpp/src/../obj/ipuFactoryIn
>> >> terfacesSK.o type=OBJT);
>> >> ld: fatal: symbol `ipu::corba::MAX_CCIF' is multiply-
defined:
>> >>
>> >>
>>
(file /home/ipu01/IPU_ALBERTO/corba/cpp/src/../obj/ipuDataSK.o
>> >> type=OBJT;
>> >>
>>
file /home/ipu01/IPU_ALBERTO/corba/cpp/src/../obj/ipuFactoryIn
>> >> terfacesSK.o type=OBJT);
>> >> ld: fatal: symbol `CORBA::BAD_POLICY_VALUE' is
multiply-
>> >> defined:
>> >>
>> >>
>>
(file /home/ipu01/IPU_ALBERTO/corba/cpp/src/../obj/ipuDataSK.o
>> >> type=OBJT;
>> >>
>>
file /home/ipu01/IPU_ALBERTO/corba/cpp/src/../obj/ipuFactoryIn
>> >> terfacesSK.o type=OBJT);
>> >> ld: fatal: symbol
`ipu::corba::MAX_UPRIVATESMSBLOCKED'
>> is
>> >> multiply-defined:
>> >>
>> >>
>>
(file /home/ipu01/IPU_ALBERTO/corba/cpp/src/../obj/ipuDataSK.o
>> >> type=OBJT;
>> >>
>>
file /home/ipu01/IPU_ALBERTO/corba/cpp/src/../obj/ipuFactoryIn
>> >> terfacesSK.o type=OBJT);
>> >> ld: fatal: symbol `PortableServer::LIFESPAN_POLICY_ID'
is
>> >> multiply-defined:
>> >>
>> >>
>>
(file /home/ipu01/IPU_ALBERTO/corba/cpp/src/../obj/ipuDataSK.o
>> >> type=OBJT;
>> >>
>>
file /home/ipu01/IPU_ALBERTO/corba/cpp/src/../obj/ipuFactoryIn
>> >> terfacesSK.o type=OBJT);
>> >> ld: fatal: symbol `ipu::corba::MAX_GTELNUM' is multiply-
>> defined:
>> >>
>> >>
>>
(file /home/ipu01/IPU_ALBERTO/corba/cpp/src/../obj/ipuDataSK.o
>> >> type=OBJT;
>> >>
>>
file /home/ipu01/IPU_ALBERTO/corba/cpp/src/../obj/ipuFactoryIn
>> >> terfacesSK.o type=OBJT);
>> >>
>> >>
>> >> If i remove the option (-g) or put in only one file, all
works
>> ok .
>> >>
>> >> Any one can help me? thanks
>> >>
>> >> Alberto
>> >>
>> >> /home/ipu01/IPU_ALBERTO/corba/cpp/src:ipu01=>
uname -a
>> >> SunOS mamas2o 5.8 Generic_117350-14 sun4u sparc
>> >> SUNW,Sun-Fire-V240
>> >>
>> >> /home/ipu01/IPU_ALBERTO/corba/cpp/src:ipu01=> CC -V
>> >> CC: WorkShop Compilers 5.0 02/10/08 C++ 5.0 Patch
>> 107311-19
>> >>
>> >>
>> >>
>> >>
>> >>
>> >>
>> >> _______________________________________________
>> >> omniORB-list mailing list
>> >> <a <a href="javascript:sendMsg
('href="javascript:sendMsg('omniORB-list at omniorb-
');">href="javascript:sendMsg('omniORB-list at omniorb-</a>
>> <a href="javascript:sendMsg('support.com');">omniORB-
list at omniorb-support.com</a>');">support.com');">omniORB-
list at omniorb-support.com</a></a>
>> >> <a href="/app/message?l=es&o=8&url=http%3A%2F%
>> 2Fwww%2Eomniorb%2Dsupport%2Ecom%2Fmailman%
2Flistinfo%
>> 2Fomniorb%2Dlist" target="_blank"><a href="/app/message?
l=es&o=8&url=http%3A%2F%2Fwww%2Eomniorb%2D"
target="_blank">http://www.omniorb-</a>
>> support.com/mailman/listinfo/omniorb-list</a>
>>
>***********************************************
>>
***********************************************
>> >Important Note
>> >This email (including any attachments) contains information
>> which is
>> >confidential and may be subject to legal privilege. If you
are
>> not
>> >the intended recipient you must not use, distribute or copy
this
>> >email. If you have received this email in error please notify
the
>> >sender immediately and delete this email. Any views
expressed
>> in this
>> >email are not necessarily the views of XPlan Technology.
>> >It is the duty of the recipient to virus scan and otherwise
test
>> the
>> >information provided before loading onto any computer
system.
>> >Xplan Technology does not warrant that the
>> >information is free of a virus or any other defect or error.
>>
>***********************************************
>>
***********************************************
>>
>>
>***********************************************
***********************************************
>Important Note
>This email (including any attachments) contains information
which is
>confidential and may be subject to legal privilege. If you are
not
>the intended recipient you must not use, distribute or copy this
>email. If you have received this email in error please notify the
>sender immediately and delete this email. Any views expressed
in this
>email are not necessarily the views of XPlan Technology.
>It is the duty of the recipient to virus scan and otherwise test
the
>information provided before loading onto any computer system.
>Xplan Technology does not warrant that the
>information is free of a virus or any other defect or error.
>***********************************************
***********************************************
More information about the omniORB-list
mailing list