Forum

Page 4 of 5 FirstFirst ... 2345 LastLast
Results 46 to 60 of 66
  1. #46
    Join Date
    September 2005
    Location
    Germany / Dortmund
    Posts
    1,369
    Quote Originally Posted by Jhhhj_original View Post
    On the shutdown callback, I should clear the buffers and free the memorys I guess?
    It's totally on you, what to do there. But yes, if you created memory on the heap, you should free it there. Init and shutdown are called once, when the plugin was requested to start/stop.

    Quote Originally Posted by Jhhhj_original View Post
    And is there anything needed in the body of the init function? (is there even a body needed?)
    You need to at least return 0, to yield a successful init. Otherwise you'll get an error when trying to start your plugin.

  2. #47
    Join Date
    October 2015
    Location
    Germany, Bavaria
    Posts
    125
    Clientlog:

    Code:
    27.02.2017 08:56:29	Plugins	Info	Required plugin function name(), version(), apiVersion(), author() or description() not found in plugin: C:\[...]\TS3Client\plugins\myplugin.dll
    But they are in there... And thats what I don't get.
    I also included the init and shutdown functions, still not working...

    Every needed function is referenced in the header...
    The OnClientTextmessage is also referenced...

    Still not working...

  3. #48
    Join Date
    September 2012
    Posts
    6,060
    You didn't implement ts3plugin_name() function, at least not according to your post above
    Last edited by Chris; February 27th, 2017 at 10:31 AM.
    When sending PMs please make sure to include a reference link to the thread in question in the body of your message.

  4. #49
    Join Date
    October 2015
    Location
    Germany, Bavaria
    Posts
    125
    But what did I do in my Main and Header file then?

    Or different:
    What do you mean with implement, and how do I do it then?

  5. #50
    Join Date
    September 2012
    Posts
    6,060
    Ok, I missed it in your header, but it is missing from the .cpp file I would assume (at least it's missing from the portion you posted).

    If the compiler doesn't find an implementation it will probably discard that function from the output. You need to implement it in the same way you did with ts3plugin_description, it needs to be present in the .cpp file too and return something.

    Code:
    const char* ts3plugin_name() {
    	return "";
    }
    
    const char* ts3plugin_version() {
    	return "";
    }
    
    int ts3plugin_apiVersion() {
    	return 21;
    }
    
    const char* ts3plugin_author() {
    	return "";
    }
    
    const char* ts3plugin_description() {
    	return "";
    }
    
    void ts3plugin_setFunctionPointers(const struct TS3Functions funcs) {
    	// Set Function Pointers
    	ts3Functions = funcs;
    }
    
    int ts3plugin_init() {
    	return 0;
    }
    
    void ts3plugin_shutdown() {
    }
    When sending PMs please make sure to include a reference link to the thread in question in the body of your message.

  6. #51
    Join Date
    October 2015
    Location
    Germany, Bavaria
    Posts
    125
    My C file (Its a C file, not cpp though... Does that make a difference?) has pretty much exactly that code.

    Code:
    const char* ts3plugin_name() {
    #ifdef _WIN32
    	static char* result = NULL;
    	if (!result) {
    		const wchar_t* name = L"Test Plugin";
    		if (wcharToUtf8(name, &result) == -1) {
    			result = "vc_ts3_test";
    		}
    	}
    	return result;
    #else
    	return "Test Plugin";
    #endif
    }
    
    const char* ts3plugin_version() {
        return "0.0.1";
    }
    
    int ts3plugin_apiVersion() {
    	return 21;
    }
    
    const char* ts3plugin_author() {
        return "WhOoKie";
    }
    
    const char* ts3plugin_description() {
        return "Test plugin";
    }
    
    static struct TS3Functions ts3libfuncs;
    
    void ts3plugin_setFunctionPointers(const struct TS3Functions functions) {
        ts3libfuncs = functions;
    }
    
    int ts3plugin_init() {
    	return 0;
    }
    
    void ts3plugin_shutdown() {
    }

  7. #52
    Join Date
    September 2012
    Posts
    6,060
    I don't think that really makes a difference.

    You did include the plugin.h file in your .c file right?
    If so then it should work and the client should load the plugin.
    When sending PMs please make sure to include a reference link to the thread in question in the body of your message.

  8. #53
    Join Date
    October 2015
    Location
    Germany, Bavaria
    Posts
    125
    plugin.c includes the plugin.h file...

    Does it make a difference if I write

    Code:
    #ifdef __cplusplus
    [...]
    or
    Code:
    #ifdef __c //(Or whatever it would be)

  9. #54
    Join Date
    September 2005
    Location
    Germany / Dortmund
    Posts
    1,369
    I guess you mean this part:
    Code:
    #ifdef __cplusplus
    extern "C" {
    #endif
    
    //...your exported function declarations here
    
    #ifdef __cplusplus
    }
    #endif
    Yes, it makes a huge difference. The plugin sdk is a standard C api, so the client expects C symbols in your plugin.

    By using extern C around your declarations, you tell your C++ compiler (I assume, you are using one), to use C name mangling. Otherwise your compiler will use its own implementation of name mangling (which is then compiler dependent).

    An example: if you activate C name mangling for your function ts3plugin_name, your DLL will export exactly that name "ts3plugin_name". If you are using a C++ compiler and don't wrap it inside extern C, your compiler will most likely prepend some kind of prefix to the symbol name. I'm not that familiar with MSVC, so I don't know, how the symbol will look like. Dependency walker can show you the symbol names (or readelf on Unix).

  10. #55
    Join Date
    October 2015
    Location
    Germany, Bavaria
    Posts
    125
    Well, that is not quite what I meant...
    I can understand that the extern "C" is necessary, but I am asking about the #ifdef part...
    I have
    Code:
    #ifdef __cplusplus
    extern "C" {
    #endif
    
    //[...]
    
    #ifdef __cplusplus
    }
    #endif
    But is the __cplusplus part important? Should it be __c or something, or is __cplusplus fine?

    Its just, that controls if it goes inside the declaration... And if #ifdef __cplusplus == false then it won't go into the declaration at all...
    So that seems like the problem... Not certain though...

  11. #56
    Join Date
    September 2005
    Location
    Germany / Dortmund
    Posts
    1,369
    No. Notice, that there are two conditional preprocessor directives to wrap your declarations in. If the preprocessor directive __cplusplus is not defined, only the "extern C" will be skipped.

    So your code posted in #43 should be fine for that matter.

    Again, I highly suggest checking your symbols with dependency walker!

  12. #57
    Join Date
    October 2015
    Location
    Germany, Bavaria
    Posts
    125
    DepWalker does not show any exported functions to me... Which is weird...
    I just don't have any idea why...

  13. #58
    Join Date
    September 2012
    Posts
    6,060
    It should be exactly __cplusplus btw.
    Are you sure the compiler is using the correct plugin.h file?
    I'm assuming you defined WIN32 in your project settings? Since otherwise it shouldn't compile in the first place (at least not using MSVC).
    The plugin.h uses the wrong define in the example. Only _WIN32 is defined but not WIN32 (at least by MSVC, not sure about others).
    When sending PMs please make sure to include a reference link to the thread in question in the body of your message.

  14. #59
    Join Date
    October 2015
    Location
    Germany, Bavaria
    Posts
    125
    What do you mean by "define"? Do you mean
    Code:
    #define _WIN32
    #define WIN32
    or what exactly?
    Does not really make a whole lot of sense to define like that I guess...

  15. #60
    Join Date
    May 2016
    Location
    Idar-Oberstein
    Posts
    155
    Chris referred to Project Properties -> C/C++ Preprocessor Definitions, which is where the Test Plugin gets this define from.
    _WIN32 is defined by the compiler, and while possible, it's illegal to define stuff with an underscore (it's reserved).

    In any case, if it'd be just the define, it'd go to #else and be heavily confused on what to do with this attribute thingie (i.e. compilation error).

    Do you have an #include "plugin.h" in your plugin.c/cpp file? It'll happily compile without doing so, without desirable result though.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Creating plugin Java
    By Retzugil in forum Client Plugins / Lua Scripts
    Replies: 1
    Last Post: May 15th, 2014, 07:23 AM
  2. Creating my first TS3 plugin and it won't load
    By DrPastah in forum Client Plugins / Lua Scripts
    Replies: 5
    Last Post: March 12th, 2014, 11:14 AM
  3. Problems while creating a plugin..
    By Loreman in forum General Questions
    Replies: 0
    Last Post: October 6th, 2013, 03:45 PM
  4. Creating complex GUI with Plugin
    By TigerSnail in forum General Questions
    Replies: 3
    Last Post: May 23rd, 2013, 08:43 AM

Tags for this Thread

Posting Permissions

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