How do I import and export namespace function in VC++?
Hi,
I have a function defined in a namespace in one DLL (DLL 1), and try to call it from another DLL (DLL 2). In Linux, it works fine. But in Window it can't find that function. The program is written using Qt, which is intended for cross platform application.
The import and export are properly defined, as below:
In DLL 1
namespace MyDLL1 {
MY_DLL1_EXPORT float getGlobalPoint();
}
Where MY_DLL1_EXPORT is defined properly as Q_DECL_EXPORT when building the library, or Q_DECL_IMPORT when linking to the library.
However, it complains MyDLL1::getGlobalPoint is undefined when building DLL 2.
Can anyone help please?
Thanks
Re: How do I import and export namespace function in VC++?
Can you check that DLL is loading properly on windows.
Probably you are calling load() from QLibrary. So check the return value.
Re: How do I import and export namespace function in VC++?
Try keyword ,
using namespace "namespace_name".
Re: How do I import and export namespace function in VC++?
Check that:
- Compiling MyLibrary generates MyLibrary.lib and MyLibrary.dll
- Load Mylibrary.dll with depends.exe to see that your function has been successfully exported.
- Ensure that your makefile/.vcproj links to MyLibrary.lib
The last step is done by adding the following to the .pro file of DLL 2
Code:
LIBS += -L<PathToLib> -lMyLibrary
Re: How do I import and export namespace function in VC++?
Quote:
Originally Posted by
spud
Check that:
- Compiling MyLibrary generates MyLibrary.lib and MyLibrary.dll
- Load Mylibrary.dll with depends.exe to see that your function has been successfully exported.
- Ensure that your makefile/.vcproj links to MyLibrary.lib
The last step is done by adding the following to the .pro file of DLL 2
Code:
LIBS += -L<PathToLib> -lMyLibrary
Thanks!!
I forgot to link to DLL1 when building DLL2. It works now.