Results 1 to 5 of 5

Thread: How do I import and export namespace function in VC++?

  1. #1
    Join Date
    Dec 2006
    Posts
    426
    Thanks
    8
    Thanked 18 Times in 17 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default 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

  2. #2
    Join Date
    Dec 2007
    Posts
    628
    Thanks
    3
    Thanked 89 Times in 87 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default 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.

  3. #3
    Join Date
    Jan 2008
    Location
    Bengaluru
    Posts
    144
    Thanks
    8
    Thanked 7 Times in 7 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Windows

    Default Re: How do I import and export namespace function in VC++?

    Try keyword ,

    using namespace "namespace_name".

  4. #4
    Join Date
    Oct 2006
    Posts
    279
    Thanks
    6
    Thanked 40 Times in 39 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: How do I import and export namespace function in VC++?

    Check that:
    1. Compiling MyLibrary generates MyLibrary.lib and MyLibrary.dll
    2. Load Mylibrary.dll with depends.exe to see that your function has been successfully exported.
    3. 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
    Qt Code:
    1. LIBS += -L<PathToLib> -lMyLibrary
    To copy to clipboard, switch view to plain text mode 

  5. #5
    Join Date
    Dec 2006
    Posts
    426
    Thanks
    8
    Thanked 18 Times in 17 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Talking Re: How do I import and export namespace function in VC++?

    Quote Originally Posted by spud View Post
    Check that:
    1. Compiling MyLibrary generates MyLibrary.lib and MyLibrary.dll
    2. Load Mylibrary.dll with depends.exe to see that your function has been successfully exported.
    3. 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
    Qt Code:
    1. LIBS += -L<PathToLib> -lMyLibrary
    To copy to clipboard, switch view to plain text mode 
    Thanks!!

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

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.