Forum

Results 1 to 4 of 4
  1. #1
    Join Date
    January 2010
    Location
    Germany
    Posts
    21

    Can't I compile plugin.c with C++ compiler?

    Hello,

    I have a question about compiling the plugin.c file with a C++ compiler.
    When I do this Teamspeak 3 does not recognize the compiled plugin anymore.

    It works when compiling it with the C compiler option /TC which is the standard option of the Microsoft C/C++ compiler for .c files. But if I rename the file to plugin.cpp or even if change the compile option for plugin.c to /TP to compile C++ code Teamspeak 3 does not find the compiled plugin any more.

    Can Teamspeak 3 only find C compiled plugins? If this is the case, how can I use the QT libraries for creating a config window beacuse they are C++ based.

  2. #2
    Join Date
    June 2008
    Location
    Krün, Germany
    Posts
    510
    You can compile C++ plugins. Adding extern "C" to the plugin header should do the trick:

    Code:
    #ifndef PLUGIN_H
    #define PLUGIN_H
    
    #ifdef __cplusplus
    extern "C" {
    #endif
    
    // Function prototypes here...
    
    #ifdef __cplusplus
    }
    #endif
    
    #endif
    Look up extern "C" in any C++ book for details.
    Might be an idea to change the sample plugin.h like above to avoid confusion.

  3. #3
    Join Date
    January 2010
    Location
    Germany
    Posts
    21
    Thank you very much for the fast response, Peter.

    It works!

  4. #4
    Join Date
    January 2010
    Location
    Finland
    Posts
    1
    Another solution: Little fix to the definition of PLUGINS_EXPORTDLL!

    Code:
    #ifdef WIN32
    #ifdef __cplusplus
    #define PLUGINS_EXPORTDLL extern "C" __declspec(dllexport)
    #else
    #define PLUGINS_EXPORTDLL __declspec(dllexport)
    #endif
    #else
    #ifdef __cplusplus
    #define PLUGINS_EXPORTDLL extern "C" __attribute__ ((visibility("default")))
    #else
    #define PLUGINS_EXPORTDLL __attribute__ ((visibility("default")))
    #endif
    #endif
    Not sure will this work with linux or mac!

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Auto away plugin compile
    By Sandbird in forum Client Plugins / Lua Scripts
    Replies: 0
    Last Post: September 5th, 2013, 02:37 PM
  2. I can't seem to compile the TS3 sample plugin
    By waterfoul in forum Windows
    Replies: 4
    Last Post: February 19th, 2013, 11:48 PM
  3. How to compile a plugin for windows using linux???
    By shock_jpc in forum Client Plugins / Lua Scripts
    Replies: 0
    Last Post: December 25th, 2012, 06:17 PM
  4. [Solved] How to compile a plugin?
    By blophy in forum Client Plugins / Lua Scripts
    Replies: 5
    Last Post: December 13th, 2010, 06:52 PM

Posting Permissions

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