“jinma” <matthew.jin@fmcti-dot-com.no-spam.invalid> wrote in message
news:cspgio$2i8$1@inn.qnx.com…
wow~ thanks a lot for your help Lerch, you are better than the QNX
support stuff
Thanks, but that’s a bit unfair. It’s easy for me to explain this stuff
because I designed and implemented it. They have to learn about it the hard
way…
I will do as you have suggested, but before we conclude on this
discussion, I would like to confirm my understanding on this topic.
If you feel that I am missing something please tell me.
My steps of creating DLL out of PhAB and using it.
- Create a GUI base window with bunch of stuff (ie menu, buttons
etc…) also call this base window DLL_window
- Create a DLL initialization function as described (with
ApAddcontext, ApCreatModule(ABM_DLL_window,…);
Just a question on this part. Can I make this
initialization from PhAB like this
a) go to project → properties
No. The initialization function and setup function in there are what main()
runs at startup. Your DLL will not execute its main(). Instead, you need
to go to Project → Internal links, create an internal link for your window,
and specify the setup function there. ApCreateModule() needs an internal
link.
b) in there, you can create setup functions, add global
header, and Initialization function
The global header, OK. The other two, no.
c) type in the initialize_DLL in the Initialization
function
No, that would generate a prototype for initialize_DLL that’s incompatible
with how you want to define the function. Your function has nothing to do
with what PhAB thinks of as “the” Initialization function. PhAB’s
Initialization function is what the PhAB-generated main() uses to parse the
command-line arguments. Your DLL will not run its main, and won’t have any
command-line arguments to parse.
d) open the initialize_DLL.c file that PhAB has
generated and do my initialization routine as described.
Just write your initialize_DLL function by hand. Add it to the source file
that has your setup function in it. Or to some other source file, it
doesn’t matter. PhAB doesn’t need to know about your function. PhAB
doesn’t even need to know that you’re creating a DLL rather than an
application. That’s why PhAB keeps generating a main() for you. But that’s
not a problem. Just don’t make it unnecessarily large by adding PhAB
initialization functions and setup modules…
-
Now I have working GUI that has all the widgets I need with all
the callbacks, and initialization function, and lets say that my work
is stored in /work/DLL_GUI/
-
go to /work/ directory and type “addvariant”, which creates teh
x86.so directory
No, go to /work/DLL_GUI and type “addvariant dll”, which should create the
x86/dll directory.
- now I can go to /work/DLL_GUI/x86/x86.so/ which has DLL_GUI.so and
DLL_GUIS.a and DLL_GUI.a
- another question here, how come there are three library
made here? According to you I can only use DLL_GUI.so so
should I ignor the share static and static library?
If you do it my way, it shouldn’t create the .a’s.
- Rename DLL_GUI.so to DLL_GUI.dll so that I don’t have to do
-Bsymbolic linker option
Rename it if you want, but since it’s been linked already, it’s too late to
change the linker option. If you specify “dll” to addvariant, you’ll see
the -Bsymbolic option when make builds DLL_GUI.so.
- Now we have a GUI shared library ready to be used.
> Create another PhAB application which will just call (dlopen) this
DLL_GUI.dll library
- just create an base window
- In the setup function of this base window make a main program
which will
a) dlopen the DLL_GUI.dll
b) declears the function pointers that points to the DLL
initialization function and assign it using dlsym()
c) finally calls this DLL initialzation function to
display the GUI I have created in DLL_GUI.dll
Do you need to ever unload the DLL before the main application exits? If
you do, that’s another big topic…