is there a way to create a DLL without use __declspec dllexport at each functions ?
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6

Thread: is there a way to create a DLL without use __declspec dllexport at each functions ?

  1. #1
    Join Date
    Oct 2010
    Posts
    4

    Question is there a way to create a DLL without use __declspec dllexport at each functions ?

    any1 know if there is a way to create a dll project without use __declspec dllimport/dllexport at each function ?

    what i am actually need here is, convert a static lib project into a dll project. and this project contains couple hundred files.
    the only way that i am aware of to make a dll is by put __declspec dllimport/dllexport infront of each function. which will take me days to complete that task.

    so i'd like to ask if any1 know there is a way that i can get away with that ? maybe a macro or a way of build the project, so it will automatically grab all the functions and export them to a dll.

    Thanks

  2. #2
    Join Date
    Nov 2000
    Location
    Voronezh, Russia
    Posts
    6,051

    Re: is there a way to create a DLL without use __declspec dllexport at each functions

    First of all you need to know what functions really require to be exported, and later export only those ones required to be exposed at application level.

    Do you know anything about libraries? The fact that function is implemented in the library never means it is directly called by application. The same is applicable to dlls.

    And no, I'm not aware of a tool that would let you automate your task.
    Best regards,
    Igor

  3. #3
    Join Date
    Apr 1999
    Posts
    3,585

    Re: is there a way to create a DLL without use __declspec dllexport at each functions

    Does the library contain classes that you would like to expose? If so, you can save some time by exporting the classes and thus providing access to all of its public methods. Otherwise, you should follow Igor's advice.
    Gort...Klaatu, Barada Nikto!

  4. #4
    Join Date
    Oct 2010
    Posts
    4

    Re: is there a way to create a DLL without use __declspec dllexport at each functions

    ty for the replies.
    im not too sure how many classes are there in my project, but there are close to 9 thousand non-class functions need to be exported.

    i am going to write a little tool to do this **** task for me. its not going to be fun if i need to open every single file and modify them.

    thank you.

  5. #5
    Join Date
    Oct 2010
    Posts
    4

    Re: is there a way to create a DLL without use __declspec dllexport at each functions

    Quote Originally Posted by Igor Vartanov View Post
    First of all you need to know what functions really require to be exported, and later export only those ones required to be exposed at application level.

    Do you know anything about libraries? The fact that function is implemented in the library never means it is directly called by application. The same is applicable to dlls.

    And no, I'm not aware of a tool that would let you automate your task.
    unfortunately, every single function in the project need to be exported. coz this project is kinda like a bridge project in between two programs, one is called "Action", one is called "Command", and they need something in between to link them together, and this is also why, i need to export all the functions in the project.

    and also lucky, this will make save me sometime to create the customized tool to export all the functions.

  6. #6
    Join Date
    Nov 2000
    Location
    Voronezh, Russia
    Posts
    6,051

    Re: is there a way to create a DLL without use __declspec dllexport at each functions

    Okay, maybe this information will make your tool be a bit easier: __declspec(dllexport) is not an only available way for exporting functions. Old good DEF file still remains in effect, end every single function whose name matches to the name mentioned in EXPORTS section appears exported. So, you never need to modify your library sources. In fact you need to compose a simple textual file like this:
    Code:
    LIBRARY <dll name goes here>
    EXPORTS
      Function1
      Function2
    . . .
      FunctionN
    This file should have a name with .def extension and needs to be included into project sources. Good luck!

    Ah! BTW, the list of functions contained in a library might be obtainad by means of dumpbin.exe tool (you need SYMBOLS).
    Last edited by Igor Vartanov; October 15th, 2010 at 02:44 PM.
    Best regards,
    Igor

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center