RSS/Atom feed Twitter
Site is read-only, email is disabled

How to Compile Plug-in Under MS VC++ 5.0 (was Re: Threshold Crop Plug-in)

This discussion is connected to the gimp-user-list.gnome.org mailing list which is provided by the GIMP developers and not related to gimpusers.com.

This is a read-only list on gimpusers.com so this discussion thread is read-only, too.

1 of 2 messages available
Toggle history

Please log in to manage your subscriptions.

How to Compile Plug-in Under MS VC++ 5.0 (was Re: Threshold Crop Plug-in) Kevin Myers 16 Oct 07:08
017801c273b0$b2a9b560$66c8a... 07 Oct 20:15
Kevin Myers
2002-10-16 07:08:50 UTC (over 21 years ago)

How to Compile Plug-in Under MS VC++ 5.0 (was Re: Threshold Crop Plug-in)

Hi folks,

After quite a few downloads and some trial and error, I was able to eventually get my new plug-in to compile successfully. After adding a UI to specify the threshold settings, and perhaps a bit more performance tweaking I will plan to submit it for public evaluation. Just how you go about doing that I don't know yet, but hopefully I can find some web pages to give me a clue.

Meanwhile, for the record I wanted to try to document the basic steps that I used to make this process work. Hopefully this may be somewhat useful to others. I am working under MS Windows 2K, with MS Visual C++ 5.0. Steps as follows:

1. Download and install the Windows installer binary gimp and GTK+ images off of the links from Jernej Simoncic's page at http://www2.arnes.si/~sopjsimo/gimp/. After all, a gimp plug-in isn't much good unless you've got gimp to run it with, right? Installation for both of these was pretty simple and went off without a hitch. Thanks a lot for providing these easy to install images!!!

2. Install MS VC++ 5.0. Can be tricky in and of itself, because v5.0 is somewhat outdated now days. Had to reinstall MS Jet and MDAC from www.microsoft.com/data after doing this to replace the obsolete versions that VC 5.0 installed. Am worried that other obsolete gunk may have also been installed, but couldn't specifically find anything else out of sync.

3. Download and unzip the following include and library packages from Tor Lillqvist's downloads page at
http://www.gimp.org/~tml/gimp/win32/downloads.html: gimp-dev-1.2.4-20020907.zip, glib-dev-2.0.6-20020802.zip, gettext-dev-0.10.40-20020904.zip.

4. Download and unzip the following source packages from Tor Lillqvist's downloads page at http://www.gimp.org/~tml/gimp/win32/downloads.html (same page as above): gimp-1.2.4-tml-20020907-src.zip

5. Fire up MS VC++ 5.0, and create a new Win32 project, noting the project directory that is created.

6. Copy autocrop.c from the gimp-1.2.4\PLUG-INS\COMMON source subdirectory to the project directory.

7. Copy config.h.win32 from the gimp-1.2.4 subdirectory to the project directory and rename to config.h .

8. Copy glibconfig.h from the LIB\GLIB-2.0\INCLUDE glib subdirectory to the project directory.

9. Add each of the above files to my VC project via the RMB->Add Files to Project... menu item.

10. Edit GTYPES.H in the INCLUDE\GLIB-2.0\GLIB glib subdirectory and change the reference to "glibconfig.h". That probably shouldn't have been necessary, but I wasn't sure what other means would have been a better approach to have the compiler locate glibconfig.h in another directory. Moving glibconfig.h to the main glib include directory didn't seem like the appropriate thing to do, since it includes installation-specific settings.

11. RMB Settings... on the project, change Setting For to All Configurations.

12. On the C/C++ tab, Category: Preprocessor, add the paths for each of the three include subdirectories of the previously downloaded packages to the Additional include directories field (the glib include path ends in include\glib-2.0).

13. On the Link tab, Category: Input, add gimp.lib, intl.lib, and glib-2.0.lib to the Object/library modules, and add the paths for each of the three lib subdirectories of the previously downloaded packages to the Additional library path field.

14. Hit OK in the Project Settings window.

15. Select Build->Set Active Configuration from the VC menu, and select the Win32 Release configuration then click OK.

16. Select Build->Build .exe from the VC menu. Should build with no warnings or errors. You've now successfully built a duplicate of the autocrop plug-in.

17. Now copy autocrop.c to threshcrop.c (my new plug-in name), make some desired changes in the code, and provide a new location for the plug-in in the gimp menu structure by changing the approrpriate, easily recognizable argument to gimp_install_procedure, and re-build. Oops, almost forgot to mention that you need to go into Settings..., General tab for autocrop.c and select Exclude from build to avoid problems with duplicate main(), etc.

18. Copy the .exe file from your project directory to the Program Files\GIMP\lib\gimp\1.2\plug-ins directory.

19. Fire up gimp and load an image. RMB on the image and if everything worked right, then your new plug-in should be found in the gimp menu structure where you placed it in step 17. Click on the menu item for the plug-in, and it should execute, taking whatever action that it was intended to perform. Mine is a minor modification to autocrop which does cropping based on user-specified threshold values, rather than assuming that the entire border area must have only a single color. My version is MUCH better for scanned images. Still needs some minor additional development and tweaking before I'll be ready to release it for general consumption though.

One problem that I ran into was how to debug my application. Not being a C, Windows, and GIMP development guru, I wasn't sure how to do that since the plug-in could not be executed directly under the control of the debugger, as it must be executed by the gimp instead. Also, since the plug-in is a Win32 app, and not a console app, I didn't have any kind of console window to echo debugging messages. I could have created a duplicate console app specifically for debugging, but that would have required a duplicate VC project with all of the same setup, and would have been somewhat of a minor pain. So, what I did instead was really ugly: I used the text area of the gimp progress indicator to display my debugging messages! That worked, but was definitely painful, and not highly recommended.

Please note that I am NOT an experienced C developer. I wouldn't be surprised if there were some other changes to project settings in VC that might have been appropriate for performance, etc. Also, I specifically did NOT download or install everything that might be necessary to build any conceivable plugin. I only used that components that I specifically needed for this particular project. So, other folks may have additional/better suggestions, or you may need additional components besides those that I have specified here. Hopefully though, at least this will give some of you a bit of a starting point.

By the way, I did NOT use gimptool, or any other tools or make files, etc. I don't know whether any of those might have made my task any easier or not. I suspect not in this specific case, but that might be a completely different story for a more complex plug-in.

Wanted to say thanks once again to Tor Lillqvist for all of the info and files on his web site related to porting the gimp to Windows. Without that I would have been completely stuck.

s/KAM

----- Original Message -----
From: "Kevin Myers"
To: "gimp users"
Sent: Monday, October 14, 2002 10:23 AM Subject: [Gimp-user] Threshold Crop Plug-in

Hello,

I would like to develop (or preferably locate) a tool somewhat similar

to

the default gimp autocrop, but with this difference: It would allow you

to

specify a threshold range in some manner for the border that is to be cropped. If it handles RGB that would be fine, but in my case all that

I

really care about is grayscale.

I've searched the gimp registry and didn't see anything similar, so I'm considering writing one of my own by using the existing autocrop plug-in

as

a starting point. I've done some preliminary looking at the code and

have

written pseudo-code for the primary changes that would be needed.

However,

I can't seem to locate any docs on what you actually need in order to compile a plug-in...

In autocrop libgimp is the only external library that is used, and I

don't

think that I need anything else either, at least for a simple initial version with hardcoded threshold values and no user interface.

I would think that I can easily locate and download the header file(s)

for

libgimp. But I'm an inexperienced C developer, and don't know what else

if

anything that I may need. I will be mucking with tiff files, but since

gimp

itself will be doing all of the actual file interaction, I don't think

that

I should need libtiff or anything like that, right? Also, I don't need

the

libgimp source other than the header files, do I?

Finally, I will be doing my work under Windows. I have several

compilers

available, including a couple of versions of Microsoft Visual C++. I

don't

want my plug-in to be dependent on Cygwin libraries or anything like

that,

so I don't plan to use Cygwin for this development. By default (because

I

don't know any better) I was planning to MSVC++ 6.0 to write and compile

the

plug-in. Will this work? Are there any other tools that I am likely to need in order to develop this extremely simple plug-in?

After compiling, I believe that all I should need to do to run the

plug-in

is to locate it in the proper gimp subdirectory on my machine, right?

Thanks in advance for any tips.

Kevin M. Round Rock, Texas