Ralph and Jeff:

Thanks for your replies to my questions about compiling a 32-bit MPI library 
for Forth.

Ralph wrote:

IIRC, you would need to write a wrapper to let Forth access C-based functions, yes? You could configure and build OMPI as a 32-bit library, and libmpi.so is C, so that isn?t an issue.

I'm using Microprocessor Engineering Ltd.'s Forth, which can import any executable image saved in a .so formatted file. In Forth, two commands make the link to the executable. The command:

LIBRARY <filename>

opens the library file.  Then the command:

EXTERN: <return value> name ( < list of passed parameters> )

makes the function callable from within Forth. (The parameters and return values are passed on the stack.) So, once you've got a usable library available, the process is trivial.


What compiler are you planning to use (as the cmd line options may vary a bit)?

I only have my machine here in the lab to work with, and I don't have a lot of information on it. Entering "mpicc --version" I get:

gcc (Debian 4.9.2-10) 4.9.2


Ralph's suggestion is exactly what I've tried so far. I've written a small C file where I include MPI.h and then write functions that are just wrappers for the MPI functions, such as:

int FMPI_Finalize()
{
  return MPI_Finalize():
}

Then I try to compile the library file in 32-bit mode.  The first command is:

mpicc -fPIC -m32 -c libtest.c

Then the second is:

mpicc -shared -m32 -o libmpi.so libtest.o

As you can see below, compiling the object file works. But the second command, linking libtest.o and writing the shared library, fails. Can you see what's wrong?

rwagner@tuxcfd10:~/engrhome/CSU/LibTests$ mpicc -fPIC -m32 -c libtest.c
rwagner@tuxcfd10:~/engrhome/CSU/LibTests$ mpicc -shared -m32 -o libmpi.so 
libtest.o
/usr/bin/ld: skipping incompatible /usr//lib/libmpi.so when searching for -lmpi
/usr/bin/ld: skipping incompatible /usr/lib/openmpi/lib/libmpi.so when 
searching for -lmpi
/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-linux-gnu/4.9/../../../libmpi.so when searching for -lmpi
/usr/bin/ld: skipping incompatible //usr/lib/libmpi.so when searching for -lmpi
/usr/bin/ld: cannot find -lmpi
/usr/bin/ld: cannot find -lhwloc
collect2: error: ld returned 1 exit status

And for added info, these two commands succeed when I don't use the -m32 switch. The library comes out as you'd expect it to, but as a 64-bit version.


Regards,

Rich Wagner
Aerospace Engineer
Grad Student
Montrose, CO, Fort Collins, CO and points elsewhere...

Reply via email to