tags:

views:

60

answers:

2

Hello,

I've encountered a strange behavior in __declspec(dllexport) in my project. I have a C++ project that uses classes, namespaces, try-catches and more cpp elements. When exporting any dummy function in this DLL, no other C project will be able to load it with LoadLibrary (Getting error 'module not found').

Is it possible to load dynamically C++ dlls through C projects? These projects are Windows Mobile projects, but they should behave the same as on regular PC win32.

I'm stuck on it and any help will be appreciated.

Thank you, Emil.

+3  A: 

LoadLibrary is completely oblivious to the language used to compile a module. If LoadLibrary says it can't find the module, then it's very likely the case that it really can't find it. Make sure you've specified the right file name. If you've included a drive and path, make sure they're correct, too. If you haven't included a drive or path, then make sure the file exists somewhere where LoadLibrary can find it. The places it searches are listed in Dynamic-Link Library Search Order. Also consider whether Windows Vista's directory-virtualization feature might be interfering.

Once the DLL is loaded, you may have any number of other issues in using the C++ DLL from your C code. The C++ compiler may have mangled the function names, so you'll need to provide the right names when you call GetProcAddress. The C++ code might use a different calling convention from what your C code expects, so you may need to change declarations in the C++ code, the C code, or both. If the C++ functions expect to receive pointers to classes or other C++-specific types, you'll need to change your C++ code so that its API is compatible with C. If your DLL allocates memory that the host program should free, or vice versa, you'll need to make sure that both modules can use the same memory manager.

All that is separate from the problem you're reporting, though, which is simply that the OS can't find your file. Focus on that first.

Rob Kennedy
I export just one function:extern "C" __declpesc(dllexport) int test();and I can't even get to GetProcAddress... LoadLibrary give an error.If I comment this function, and I don't have any export, then LoadLibrary works great. So it's probably a problem with the settings of the projects or C-C++ compatibility.
A: 

I found the problem. It was really a dependency dll problem. It was not found in the directory of the loading DLL. Thank you all.