Undefined registerKernelFactories in Plugin

The functionality of OpenMM will (eventually) include everything that one would need to run modern molecular simulation.
POST REPLY
User avatar
Andrea Zonca
Posts: 17
Joined: Tue Aug 19, 2014 1:32 pm

Undefined registerKernelFactories in Plugin

Post by Andrea Zonca » Wed Jan 17, 2018 6:13 am

Hi,

I've created the CPU platform for my plugin, at runtime it finds the plugin ".so" library but `dlsym` returns a NULL handle for registerKernelFactories.

I defined the function as:

Code: Select all

extern "C" OPENMM_EXPORT void registerKernelFactories() {                                                                       std::cout << "Executing registerKernelFactories of CPU MBPol" << std::endl;                                             
    for( int ii = 0; ii < Platform::getNumPlatforms(); ii++ ){                                                              
        Platform& platform = Platform::getPlatform(ii);                                                                     
        if( platform.getName() == "CPU" ){                                                                                  
                                                                                                                            
             MBPolCpuKernelFactory* factory = new MBPolCpuKernelFactory();                                                             
             std::cout << "Registered CPU CalcMBPolElectrostaticsForceKernel::Name" << std::endl;                           
        }                                                                                                                   
    }                                                                                                                       
} 
I see that it is exported in the library:

Code: Select all

nm -gC /usr/local/openmm/lib/plugins/libOpenMMMBPolCPU.so | grep registerKernelFactories
00000000000237b7 T registerKernelFactories
all of the code is here: https://github.com/paesanilab/mbpol_ope ... n/pull/115

Do you have suggestions on how to debug this?
Thanks!

User avatar
Peter Eastman
Posts: 2588
Joined: Thu Aug 09, 2007 1:25 pm

Re: Undefined registerKernelFactories in Plugin

Post by Peter Eastman » Wed Jan 17, 2018 11:08 am

That's strange. You've declared it as extern "C", and it looks like it's spelled correctly, so it should be found. Are you certain that /usr/local/openmm/lib/plugins/libOpenMMMBPolCPU.so is actually the library that it's loading when it fails to find the function?

User avatar
Andrea Zonca
Posts: 17
Joined: Tue Aug 19, 2014 1:32 pm

Re: Undefined registerKernelFactories in Plugin

Post by Andrea Zonca » Wed Jan 17, 2018 11:46 am

yes, it is the only location where that is available beside the build folder.

User avatar
Peter Eastman
Posts: 2588
Joined: Thu Aug 09, 2007 1:25 pm

Re: Undefined registerKernelFactories in Plugin

Post by Peter Eastman » Wed Jan 17, 2018 11:51 am

That's not quite what I meant. How did you determine that dlsym() was returning NULL? Did you modify the code for initializePlugins() and have it print out the result? If so, then have it also print out the full path to the plugin it's loading to make sure it's really what you expect. If not, then what leads you to believe it's returning NULL?

User avatar
Andrea Zonca
Posts: 17
Joined: Tue Aug 19, 2014 1:32 pm

Re: Undefined registerKernelFactories in Plugin

Post by Andrea Zonca » Wed Jan 17, 2018 12:46 pm

Nevermind, I found the issue, I misread the logs, it was actually failing to load the plugin due to a linking error.

POST REPLY