PDA

View Full Version : How do I import and export namespace function in VC++?



lni
12th October 2009, 03:38
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

yogeshgokul
12th October 2009, 05:51
Can you check that DLL is loading properly on windows.
Probably you are calling load() from QLibrary. So check the return value.

nikhilqt
12th October 2009, 08:17
Try keyword ,

using namespace "namespace_name".

spud
12th October 2009, 12:21
Check that:

Compiling MyLibrary generates MyLibrary.lib and MyLibrary.dll
Load Mylibrary.dll with depends.exe (http://www.dependencywalker.com/) 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

LIBS += -L<PathToLib> -lMyLibrary

lni
14th October 2009, 04:28
Check that:

Compiling MyLibrary generates MyLibrary.lib and MyLibrary.dll
Load Mylibrary.dll with depends.exe (http://www.dependencywalker.com/) 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

LIBS += -L<PathToLib> -lMyLibrary

Thanks!!

I forgot to link to DLL1 when building DLL2. It works now.