Philippe Canal wrote: > > > I also tried the following approach: > > > > Func_t test2 = gSystem->DynFindSymbol( > > "/home/sas/src/ana/macros/test2.so", "test2" ); > > I answer this last question for completness but recommend against using something > like that. > Func_t is a pointer to a function, could you cast it to > the proper type (assuming you know it) and use it like: > > typedef int (*testfunct)(); > > .... > testfunc test2 = (testfunc)gSystem-> > DynFindSymbol("/home/sas/src/ana/macros/test2.so", "test2" ); > .... Hi Philippe, thanks for your reply. Your "class approach" is actually more or less what I had in mind, when I started to test this "runtime compiling procedure". Up to now I had used the Dictionary mechanisms in a black box fashion as it wasn't really clear to me what you gain. I beginning to see this now thanks to your example (altough I still have problems, see below). I found out about Func_t after I posted my message and agree that I don't want to use that. Especially since the symbol is not "test2" but "test2__Fv" for a void function and changes to "test2__FPi" for a void function passing a pointer to int... I don't want to guess or "nm | grep" for the symbol every time I change the parameter list... :-) So I immediately set out and tried your example last night. I ran into the following problem. Compiling the thing works, but running gives (sorry for the lengthy pastes): ------------------------------------------------- sas@galileo:~/src/ana/macros > ./test Compiling... Creating shared library /home/sas/src/ana/macros/AllTasks.so /tmp/fileLfq2y1.C:1: /home/sas/src/ana/macros/AllTasks.C++: No such file or directory Warning: link requested for unknown srcfile /home/sas/src/ana/macros/./AllTasks.h FILE:/tmp/fileawxUBDlinkdef.h LINE:11 Warning: link requested for unknown srcfile /home/sas/src/ana/macros/AllTasks.C++ FILE:/tmp/fileawxUBDlinkdef.h LINE:12 Note: operator new() masked 1c Note: operator delete() masked 1c g++: fileotApTT.C++: linker input file unused since linking not done g++: fileotApTT.o: No such file or directory Creating shared library /home/sas/src/ana/macros/test2.so /tmp/fileQvujrK.C:1: /home/sas/src/ana/macros/test2.C++: No such file or directory Warning: link requested for unknown srcfile /home/sas/src/ana/macros/test2.C++ FILE:/tmp/filea9glRelinkdef.h LINE:11 Note: operator new() masked 1c Note: operator delete() masked 1c g++: filezJsUaI.C++: linker input file unused since linking not done g++: filezJsUaI.o: No such file or directory *** Break *** segmentation violation Aborted ------------------------------------------------- I'm using root-2.25.03, compiled from source on linux/ppc. I figured CompileMacro chokes on the "++", so I removed it and got ------------------------------------------------- sas@galileo:~/src/ana/macros > ./test Compiling... Creating shared library /home/sas/src/ana/macros/AllTasks.so Note: operator new() masked 1c Note: operator delete() masked 1c Class AllTasks::R__Init: Streamer() not declared Class AllTasks::R__Init: ShowMembers() not declared dlopen error: /home/sas/src/ana/macros/AllTasks.so: undefined symbol: Dictionary__8AllTasks Load Error: Dynamic link library /home/sas/src/ana/macros/AllTasks.so can not load /usr/lib/crt1.o(.rodata+0x4): undefined reference to `main' filelqQLZk.o: In function `operator>>(TBuffer &, AllTasks *&)': filelqQLZk.o(.text+0x74): undefined reference to `AllTasks::Class(void)' filelqQLZk.o: In function `AllTasks::ShowMembers(TMemberInspector &, char *)': filelqQLZk.o(.text+0xf4): undefined reference to `AllTasks::Class(void)' filelqQLZk.o: In function `G__AllTasks_Class_3_0__FP8G__valuePCcP8G__parami': filelqQLZk.o(.text+0x654): undefined reference to `AllTasks::Class(void)' filelqQLZk.o: In function `G__AllTasks_Dictionary_6_0__FP8G__valuePCcP8G__parami': filelqQLZk.o(.text+0x714): undefined reference to `AllTasks::Dictionary(void)' filelqQLZk.o: In function `G__AllTasks_ImplFileName_2_1__FP8G__valuePCcP8G__parami': filelqQLZk.o(.text+0x948): undefined reference to `AllTasks::ImplFileName(void)'filelqQLZk.o: In function `G__AllTasks_ImplFileLine_3_1__FP8G__valuePCcP8G__parami': filelqQLZk.o(.text+0x998): undefined reference to `AllTasks::ImplFileLine(void)'filelqQLZk.o(.got2+0x34): undefined reference to `AllTasks::Dictionary(void)' filelqQLZk.o(.got2+0x220): undefined reference to `AllTasks::Dictionary(void)' filelqQLZk.o: In function `AllTasks::IsA(void) const': filelqQLZk.o(.AllTasks::gnu.linkonce.t.IsA(void) const+0xc): undefined reference to `AllTasks::Class(void)' collect2: ld returned 1 exit status Creating shared library /home/sas/src/ana/macros/test2.so Note: operator new() masked 1c Note: operator delete() masked 1c Class MyTask::R__Init: Streamer() not declared Class MyTask::R__Init: ShowMembers() not declared dlopen error: /home/sas/src/ana/macros/test2.so: undefined symbol: __ti4TAna Load Error: Dynamic link library /home/sas/src/ana/macros/test2.so can not load /usr/lib/crt1.o(.rodata+0x4): undefined reference to `main' fileRz0iqc.o: In function `MyTask::Streamer(TBuffer &)': fileRz0iqc.o(.text+0x240): undefined reference to `TAna::Streamer(TBuffer &)' fileRz0iqc.o: In function `MyTask::ShowMembers(TMemberInspector &, char *)': fileRz0iqc.o(.text+0x2c4): undefined reference to `TAna::ShowMembers(TMemberInspector &, char *)' fileRz0iqc.o(.got2+0x254): undefined reference to `TAna type_info node' fileRz0iqc.o: In function `MyTask type_info function': fileRz0iqc.o(.gnu.linkonce.t.__tf6MyTask+0x38): undefined reference to `TAna type_info function' /home/sas/src/ana/macros/AllTasks.so: undefined reference to `AllTasks::ImplFileLine(void)' /home/sas/src/ana/macros/AllTasks.so: undefined reference to `AllTasks::Class(void)' /home/sas/src/ana/macros/AllTasks.so: undefined reference to `AllTasks::Dictionary(void)' /home/sas/src/ana/macros/AllTasks.so: undefined reference to `AllTasks::ImplFileName(void)' collect2: ld returned 1 exit status *** Break *** segmentation violation Aborted ------------------------------------------------- If I compare this setup to my Eventlib thing, I note that the rootcint stuff to generate the LinkDef.C is missing. Is this generated by CompileMacro automatically? I tried adding it by hand but it wouldn't help. I admit this Dictionary thing is still a bit of a mystery to me. I'm looking forward to the new docs ;-) TIA, Sven
This archive was generated by hypermail 2b29 : Tue Jan 02 2001 - 11:50:36 MET