4 Replies Latest reply on Oct 11, 2016 5:35 PM by Rick E Johnson

    shared libraries using constants from other plugins? :-/

    Rick E Johnson Level 1

      A shared library is somehow using constants from other plugins while running in debug mode (and I'd presume would when running in real-time).

       

      I've been using shared libraries with AI plugins for over 20 years, but this is a new one for me. Using Xcode 7 targeting Illustrator CS6, I have an included .hpp and .cpp file from a shared directory for a class that reads and writes a preference file separate from AI's own file. In able for each plugin to have its own prefs file name, the shared class pulls the plugin name from a #define in Globals. When I have one or more plugins installed that also use this method, one of their global values are usually used instead of my current project's. I thought it might be from some common cache that I've been unable to identify, but when I simply remove other plugins from AI's Plugins folder, all is well. All other plugins are compiled as release versions. I thought all plugins operated entirely within their own space...

       

      I'm an old hand (please don't tease me about my age) at C, but fairly new to C++. My plugins are written within their own namespace. Although it's the same name for most private classes (e.g., globals, geometry functions), the main class that includes all of the others has a unique namespace. The shared libraries, of course, are all the same files so they obviously have the same namespace. Once loaded into AI, can they somehow merge?

       

      I should mention that this project is built largely with Hot Door CORE, but with a prefix header that imports key SDK suites. I'm certain that the problem isn't CORE, though, that it's me. Relative to another recent post about different tool plugins sharing the same tool group, if this inter-plugin behavior can be repeated and controlled, it could turn out to be a good thing.

       

      Any suggestions would be much appreciated.

        • 1. Re: shared libraries using constants from other plugins? :-/
          LeoTaro Level 4

          Sorry, me again!

           

          Illustrator plugins are simply dynamic shared libraries that are loaded at runtime into the Illustrator process address space. So, yes plugins can share code and data as they do when they interact with the SDK suites and document art. There is not a separate copy of the suites and document for each plugin.

           

          I am not sure exactly what is going on with the shared libraries used by your plugins, some code might help. Are they dynamically or statically linked to your plugins? In general, if they are statically linked each plugin will get its own copy of the code/data, whereas if the shared library is dynamic, there will be only one copy of the code/data. But you say the plugin name comes from a #define, which is a preprocessor directive that will replace the symbol before compilation, so I don't see how this could change at runtime.

          • 2. Re: shared libraries using constants from other plugins? :-/
            Rick E Johnson Level 1

            Oh good! You again! :-)

             

            I'm using Hot Door's CORE which, as you know, is mostly a collection of wrappers for the Adobe suites, which I guess makes it sort of a hybrid static/dynamic. I define the name of the plugin using #define kPluginName "Yet Another Plugin" much as is done in the Adobe SDK samples, along with other globals but not in a namespace. I then have a preferences class which is created with the  "new" constructor.

             

            In the Preferences class, a string variable stores the path to the preferences file. A CORE function returns the path to the preferences folder where I append my preferences filename to the variable prefPath:

             

                this->prefPath.append kPluginName;

             

            This has worked for months when the .cpp and .hpp files were with the rest of the plugins' source files. Since I moved the files to a common folder and added the files to the project as well as added the new folder to the user header search paths, I "clean" the project and launch it under the debugger. When I step through the code, I see the value of kPluginName is another installed plugin, not the one I just built. After putting std::cout statements in various places in this and other plugins, then running in debug mode without breakpoints, I found that things appear to function normally and in the proper order.

             

            I guess for now I'll treat it as an Xcode anomaly and hope it doesn't come back later to bite.

             

            Thanks, Leo!

            • 3. Re: shared libraries using constants from other plugins? :-/
              btempleton1982 Level 2

              I have had similar issues with XCode header search paths. Make sure it is pulling your included files from the correct location. It sounds like that could cause exactly the problems you're experiencing.

              • 4. Re: shared libraries using constants from other plugins? :-/
                Rick E Johnson Level 1

                That makes perfect sense: drilling into another project's files could make a real mess. I checked my search paths and they look good. Thanks for the suggestion, though, it's a very good one!