Microsoft Developer Network > Forums Home > Visual Studio Express Editions Forums > Visual C++ Express Edition > Visual Studio C++ Express Edition 2008 - Creating a DLL with a C project

Answered Visual Studio C++ Express Edition 2008 - Creating a DLL with a C project

  • Wednesday, May 20, 2009 5:04 PM
     
     
    Hi everybody,
    I would like to create a DLL not with a C++ project, but a C project.
    Is anybody able to post the code for a sample DLL,
    which can then be used by another C-program, using VS C++ 2008 Express Edition?

    Thanks a lot for every hint!

    Julian Dieterle

Answers

  • Wednesday, May 20, 2009 6:34 PM
     
     Answered
    Use the "Win32 Project" project template. In the project wizard, change the application type to DLL. check "Export symbols".
    In solution explorer, rename every .cpp file to .c
    Compile. You will get some compiling errors about a class created by the wizard. Remove that class.
    Compile again. You now have a clean DLL project that you can start working on.


    MSMVP VC++
    • Marked As Answer by Wesley Yao Wednesday, May 27, 2009 6:22 AM
    •  
  • Thursday, May 21, 2009 1:48 AM
    Moderator
     
     Answered
    Yup.  Or just write C++ code and use the extern "C" declarator on your exports.

    extern "C" __declspec(dllexport)
    void NoTroubleUsingThisInC() {
      //...
    }

    No classes of course.

    Hans Passant.
    • Marked As Answer by Wesley Yao Wednesday, May 27, 2009 6:22 AM
    •  

All Replies

  • Wednesday, May 20, 2009 6:34 PM
     
     Answered
    Use the "Win32 Project" project template. In the project wizard, change the application type to DLL. check "Export symbols".
    In solution explorer, rename every .cpp file to .c
    Compile. You will get some compiling errors about a class created by the wizard. Remove that class.
    Compile again. You now have a clean DLL project that you can start working on.


    MSMVP VC++
    • Marked As Answer by Wesley Yao Wednesday, May 27, 2009 6:22 AM
    •  
  • Thursday, May 21, 2009 1:48 AM
    Moderator
     
     Answered
    Yup.  Or just write C++ code and use the extern "C" declarator on your exports.

    extern "C" __declspec(dllexport)
    void NoTroubleUsingThisInC() {
      //...
    }

    No classes of course.

    Hans Passant.
    • Marked As Answer by Wesley Yao Wednesday, May 27, 2009 6:22 AM
    •  
  • Sunday, January 15, 2012 12:25 AM
     
     
    Thanks, this may be helpful to me in creating a Caligari Truespace TSX plugin; essentially it's a renamed DLL that functions as a Truespace plugin addon. I'm attempting to compile a Softimage XSI version 1 ASCII text based exporter for Truespace. I don't realy have much to go on just yet, but as I gather more information I will attempt to create the DLL for use with Truespace version 6.6. I have the SDK and the C++ TS 6.6 header files and other related files already. If anyone has any suggestions to help me along thenak you in advance. Leroy. 
  • Sunday, January 15, 2012 5:39 PM
     
     
    You need to ask caligari for help about the interface they designed.

    The following is signature, not part of post
    Please mark the post answered your question as the answer, and mark other helpful posts as helpful, so they will appear differently to other users who are visiting your thread for the same problem.
    Visual C++ MVP