Thread: Making a plugin-based application...?

  1. #1
    Registered User Firelark's Avatar
    Join Date
    Aug 2005
    Posts
    3

    Question Making a plugin-based application...?

    Hello I want to make a program that can be extended with plugins. The plugis should also be able to call functions and objects in the main app, if this is possible.

    Does any one know of a good tutorial or book on making an API? Also I need to know how to compile these plugins, Im using Dev-C++ and MingW compiler.

    Thankfull for any help.
    Karl

  2. #2
    Linker.exe64
    Join Date
    Mar 2005
    Location
    Croatia,Pozega
    Posts
    37
    You can find some tutorials here -> http://codeproject.com/dll/ . Look under general section.
    Code:
     
         .J?+.                             ?`+.
       .+1P .++.                         ,+` 4++.
      .+zq\ .:.?i                      .!`?  .yz+.
      ?zdd ..:.^`J.                   ,!..?...Kyz+	
     .+dXM ..!p^.N.+                 ,,^.a..`.#XO+.
     .zwWM ^`.Mc`JMhJ.             .:JF`JM..^.#WOz`
      jwpMr`..NF.JMMM,!           .JMMF.dJ..`JNWrc
       0Wgb `!B:.MMMMM,:         ,.MMMF.j$.` NHSZ`
        TWMp`.+;`MMMMMM.:       ;.MMMMM.;+``JHW=	
          7Mh,``JMMMM"`          .TMMMMb``.H#"`
    

  3. #3
    Quote Originally Posted by Firelark
    Hello I want to make a program that can be extended with plugins.
    what program are you working on?

    The plugis should also be able to call functions and objects in the main app, if this is possible.
    yes, it is. function pointers is a possible solution.
    winamp input plugins does this for example.

    Does any one know of a good tutorial or book on making an API? Also I need to know how to compile these plugins, Im using Dev-C++ and MingW compiler.
    i'm also using devcpp/mingw right now so if you have specific
    questions just ask. also feel free to let me take a look at your
    API and i'll let you know what i think should be improved.

  4. #4
    Registered User Firelark's Avatar
    Join Date
    Aug 2005
    Posts
    3
    Hello hartwork. I dont anything worth showing yet but I need to know how to design and compile an api for a programming project that Im about to start. (Its a graphical application).

    I acctually found a usefull tutorial on how to make and use a DLL with mingw, and so far I have been able to make and dynamically link a dll at runtime through this tutorial:

    The Tutorial

    I also found this tutorial which I havent tried yet but it seems to be good:

    The other tutorial

    I also talked with a guy over at the cgtalk forum and he said you could make a plugin use functions and objects from the main app if those functios and objects are also located in an dll (with a headerfile) which both the main app and the plugin shares. This sounds like logic to me but I havent had time to try it out yet. What do you think?

    When ever I got something to show, whould you like to have a look and maybe give me some comments?

    Thanks
    Karl Hansson

  5. #5
    Quote Originally Posted by Firelark
    I also talked with a guy over at the cgtalk forum and he said you could make a plugin use functions and objects from the main app if those functios and objects are also located in an dll (with a headerfile) which both the main app and the plugin shares. This sounds like logic to me but I havent had time to try it out yet. What do you think?
    i don't fully understand this. are you sure he does not mean statically linking the dll?

    Quote Originally Posted by Firelark
    When ever I got something to show, whould you like to have a look and maybe give me some comments?
    yes, sure!

  6. #6
    Registered User Firelark's Avatar
    Join Date
    Aug 2005
    Posts
    3
    Well, at cgtalk i asked the same question as above and he responded:

    [QUOTE]Compiler dependent or independent? Dependent is easy, as you can use any compiler you want and use any of its language/compiler features. Typically you make a DLL with shared classes and functions and link these to both your app and plugin. When the app wants to load a plugin, it calls a plugin entry point function (with no name mangling) that must exist for every plugin. The plugin then modifies data passed from the entry point function.
    Independent is harder, as you have to be careful you don't use any compiler-specific language features/keywords. You also have to be wary of any compiler settings as well. For example, last I used Borland C++ (version 5, not Builder), it treated static variables in DLLs differently than VC++ (though you could change this behavior in the compiler settings). You just have to watch out.[\QUOTE]

    Link to the CGTalk thread

    As I understand it, he says the functions and objects in the main app that is also going be called from the plugin needs be in a statically linked dll, which is linked to both the main app and the plugin who needs them. But the plugin itself is dynamiclly linked (ie linked at runtime) to the main app. Am I getting this right?

  7. #7
    As I understand it, he says the functions and objects in the main app that is also going be called from the plugin needs be in a statically linked dll, which is linked to both the main app and the plugin who needs them. But the plugin itself is dynamiclly linked (ie linked at runtime) to the main app. Am I getting this right?
    i didn't understand Stevemeister at all but the way you seem to
    have understood it can be used to solve this. the disadvantage is
    you have to reorganize your host application a bit (moving stuff
    to the static library) which isn't the case when passing function
    pointers to the plugin. also there are two interfaces then that
    could possibly change in the future: the shared library's and the
    plugin's. other than this i thinks it's a good idea.

    just choose the way you like better - both should work for you.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Search a Softwrae Dev Guide System Which based on Web application....
    By userpingz in forum A Brief History of Cprogramming.com
    Replies: 0
    Last Post: 06-10-2009, 07:55 PM
  2. Creating a Dialog Based Application without MFC
    By MitchellH in forum C++ Programming
    Replies: 8
    Last Post: 05-21-2005, 10:02 AM
  3. 2d non tile based
    By DavidP in forum Game Programming
    Replies: 4
    Last Post: 02-01-2002, 12:51 PM
  4. About Unix Programming - Making a career desision
    By null in forum C Programming
    Replies: 0
    Last Post: 10-14-2001, 07:37 AM
  5. Win application not very portable
    By swed in forum Windows Programming
    Replies: 5
    Last Post: 10-01-2001, 11:17 AM