Please wait...
×

Error

Posted Mon, 10 Feb 2014 03:02:34 GMT by mwtoews
I have C++ source for an IFM plugin that I developed with MS Visual C++ 2010 Express which I'd like to use for FEFLOW 6.1 under Linux (CentOS via RPMs) for some batch runs. How can this module be compiled? Here is what I've tried, using the older HelloWorld example from outdated documentation for the Motif interface ([url=http://www.feflow.info/fileadmin/FEFLOW/download/other_docs/ifm_example.pdf]http://www.feflow.info/fileadmin/FEFLOW/download/other_docs/ifm_example.pdf[/url]):

In the directory with the various source files HelloWorld.cpp/.h/.def, here are my shell commands:
[code]
g++ -fPIC -I/opt/wasy/sdk/ifm/include -c -o HelloWorld.o HelloWorld.cpp
g++ -fPIC -shared HelloWorld.o -o HelloWorld.so
[/code]

There are no errors from any of the commands. The problem is that the objects are not linked up, so when I try to register this module in the feflow61q GUI, I can browse to the HellowWorld.so file, but I have a FEFLOW ERROR dialog:
[quote]
Cannot load "/path/to/HelloWorld.so": /path/to/HelloWorld.so: undefined symbol: IfmRegisterModule
[/quote]

Obviously there is some kind of library linking error. Note when I compiled the module, I specified the include directory, but not a library, since I don't know where this is. It was not provided by wasy-feflow_ifm_devel-6.1-10.noarch.rpm, as the /opt/wasy/sdk/ifm/lib directory is empty. What am I missing?

[hr]
[b]Some progress[/b]: It appears that libifm.a can be built somewhat following /opt/wasy/sdk/ifm/src/Imakefile (I don't have imake, or root access, thus I do my work in a different directory with copies of the source files):
[code]
cd /path/to/wasy/sdk/ifm/src
gcc -fPIC -I../include -I../include/xdk -c *.c
ar rcs ../lib/libifm.a *.o
[/code]
Then libifm.a can be copied into the same directory as HelloWorld to recompile with the new bits:
[code]
cp /path/to/wasy/sdk/ifm/lib/libifm.a .
g++ -fPIC -I/opt/wasy/sdk/ifm/include -I/opt/wasy/sdk/ifm/include/xdk -c -o HelloWorld.o HelloWorld.cpp
g++ -fPIC -shared HelloWorld.o libifm.a -o HelloWorld.so
[/code]

And following the same registration procedure as above, I now get an error dialog with "undefined symbol: XtDisplay". I feel like I'm getting closer, but I can't say I know much about the X11 library, nor do I care. I don't require graphics for my objective. Dropping -lX11 in at various places didn't seem to do anything.
Posted Sun, 16 Feb 2014 23:40:10 GMT by mwtoews
[b]SOLVED[/b]. I found the correct link flag for the last step: -lXt

Here are the complete steps.

[i]Step 1:[/i] compile libifm from the SDK (this can be done in /opt/wasy/sdk/ifm/src if you have the privileges):
[code]
cd /path/to/wasy/sdk/ifm/src
gcc -fPIC -I../include -I../include/xdk -c *.c
ar rcs ../lib/libifm.a *.o
[/code]

[i]Step 2:[/i] compile the custom IFM Add-In:
[code]
cp /path/to/wasy/sdk/ifm/lib/libifm.a .
g++ -fPIC -I/opt/wasy/sdk/ifm/include -I/opt/wasy/sdk/ifm/include/xdk -c -o HelloWorld.o HelloWorld.cpp
g++ -fPIC -shared HelloWorld.o libifm.a -lXt -o HelloWorld.so
[/code]

Then open FEFLOW, register HelloWorld.so ... works!

You must be signed in to post in this forum.