Subject: | |
From: | |
Reply To: | |
Date: | Mon, 20 Jul 2009 15:02:58 +0200 |
Content-Type: | text/plain |
Parts/Attachments: |
|
|
Hi,
I tried using -fPIC in ALL the compiles (tried -fpic too) but didn't
get any success.
it still crashes with segmentation fault but I noticed a strange behaviour:
when I call the constructor of the shared library ( after writhing in
this constructor some printf debug lines) my program invoke a LOT of
time the said constructor. ie:
__________
printf("before constructor call\n")
device= new okCUsbFrontPanel();
__________
okCUsbFrontPanel::okCUsbFrontPanel()
{
printf("Inside okUsbFrontPanel() %i time: %i\n",i,time(0));}
i++;
h=okUsbFrontPanel_Construct();
}
__________
results in:
efore constructor call
Inside okUsbFrontPanel() 1 time: 1247842762
Inside okUsbFrontPanel() 2 time: 1247842762
Inside okUsbFrontPanel() 3 time: 1247842762
Inside okUsbFrontPanel() 4 time: 1247842762
...
Inside okUsbFrontPanel() 21666 time: 1247842762
Inside okUsbFrontPanel() 21667 time: 1247842762
Inside okUsbFrontPanel() 21668 time: 1247842762
Inside okUsbFrontPanel() 21669
It is a very strange behaviour IMHO, never heard of constructor re
invoking themselves if something goes wrong.
Any hint??
On Sat, Jul 18, 2009 at 2:53 AM, Jon
Peatfield<[log in to unmask]> wrote:
> On Sat, 18 Jul 2009, Nicola Maggi wrote:
>
> <snip>
>>>
>>> About all I can suggest is adding -fPIC to the compilation of the .cc and
>>> the the link line - you didn't specify how that was being compiled...
>>
>> If you mean how do I compile my shared library sources here is an
>> excerpt from Makefile:
>> ______________________________
>> libReadoutModuleRAPS.so : okFrontPanelDLL.o raps.o DataChannelRAPS.o
>> ReadoutModuleRAPS.o
>> g++ -shared -fpic -LlibokFrontPanel.so -lROSCore -lers -lDFDebug
>> ${LIBDIR} ${LIBS} -o libReadoutModuleRAPS.so okFrontPanelDLL.o
>> ReadoutModuleRAPS.o DataChannelRAPS.o raps.o
>>
>> ReadoutModuleRAPS.o : ReadoutModuleRAPS.cpp
>> ${CC} ${INCLUDES} -c -DLINUX -DDEBUG_LEVEL=3 $<
>> DataChannelRAPS.o : DataChannelRAPS.cpp
>> ${CC} ${INCLUDES} -c -DLINUX -DDEBUG_LEVEL=3 DataChannelRAPS.cpp
>> raps.o: raps.cpp
>> g++ ${INCLUDES} -DDEBUG_LEVEL=3 -DLINUX -c $<
>> okFrontPanelDLL.o: okFrontPanelDLL.cpp
>> g++ -fPIC -DLINUX -c $<
>> ______________________________
>> Just ignore all the -l switches becouse those are other libraries
>> which works just fine..
>> the only important one is -LlibokFrontPanel.so which calls the FPGA
>> shared library.
>>
>> As you can see I'm already using -fPIC to compile the cpp library
>> wrapper but I don't really know if I should use it to compile the
>> other files too.
>
> Actually you are using -fpic on the line which links/creates the shared
> library, but are not specifying pic for _compiling_ all the code which is
> going into it.
>
> ie try adding -fPIC to the lines which generate ReadoutModuleRAPS.o,
> DataChannelRAPS.o and raps.o - since they need to be pic as well since they
> are going into the final .so file (as well as okFrontPanelDLL.o which is
> being compiled -fPIC).
>
> BTW while on many system -fpic and -fPIC generate the same code you should
> be consistent and pick one - at the moment you have both -fpic and -fPIC
> which may clash.
>
> -- Jon
>
|
|
|