Here is how to use msys2 to make 64-bit (and 32-bit) Windows DLLs for Xojo plugins. I use an iMac with OS X 10.11.2. Parallels has Windows 10 installed.
On your 64-bit Windows:
Go to https://msys2.github.io/ and download msys2-x86_64-20150916.exe. Run it and accept the defaults except to make sure msys64 is installed on Drive C:. The installation will take some time.
As youll see later, Im not sure the following is necessary. Open c:/msys64/etc/fstab with a text editor and add the line (without quotes) c:/msys64/mingw64 /mingw64 followed by a blank line.
In the msys64 folder open mingw64_shell. Youll see a terminal-like window. Notice it is Unix-like using / and not \ as does the Windows brand of Unix. In order to have the g++ command recognized give this command:
pacman -S mingw-w64-x86_64-toolchain
Accept the defaults. Again it will take some time.
- Close that terminal window and open the mingw32_shell. For 32-bit g++ to be recognized give the command:
pacman -S ming-w64-i686-toolchain
I could never get the msys2_shell recognize the g++ command, but the mingw shells are all that you need to make DLLs for Windows.
- Download Projects.zip from my website:
The Projects folder should be copied to the C: drive, but keep the original for later. It contains the makefile and files to create a DLL for a simple Xojo plugin which handles complex numbers.
The RBPlugins folder contains the latest GlueCode and Includes folders from Xojos PluginsSDK, but which have been modified. The modifications were necessary since two of the unmodified files gave make errors like:
In file included from C:/Projects/RBplugins/Includes/rb_plugin.h:21:0,
C:/Projects/RBplugins/Includes/rb_plugin_deprecated.h:391:123: error: conflictig declaration of C function ‘void REALDrawPicturePrimitive(REALgraphics, REALpiture, const Rect*, int)’
The errors were corrected in rb_plugin_deprecated.h and PluginMain.cpp by commenting out. The corrected errors in PluginMain.cpp were all in the section titled DEPRECATED FUNCTIONALITY so I suspect youll have no problem if you avoid certain deprecated functions.
- If you dont have a shortcut on the Desktop, open the msys64 folder and double-click mingw64_shell. Give the command:
Although you dont need to, give the command
You should see a listing of the complex project files and the makefile. Give the command
If all goes well the make should complete without error and give a command prompt. Close the shell and open the libComplex folder. There you should find libComplex.DLL. Copy it elsewhere and rename it libComplex32.DLL.
Copy the original Projects folder to the C: drive replacing the one there. This is necessary since that last folder contains the 64-bit object files which would confuse the next 32-bit make. In the libComplex folder use a text editor to open the makefile. Change the line
CC = g++ -m64
CC = g++ -m32
and save and close.
Open the mingw32_shell and repeat what you did for the 64-bit make. Rename the DLL as libComplex32.DLL.
To test your DLLs I have a Mac and Windows aware plugin on my website:
Replace .xojo_plugin by .zip and decompress. The resulting ComplexPlugin folder contains the folder Build Resources, which in turn contains five folders. In the Windows folder replace that 32-bit DLL by yours. In the Windows x86-64 folder replace with your 64-bit DLL. Compress the ComplexPlugin folder and replace .zip with .xojo_plugin.
Put that plugin in the Xojo Plugins folder. Create a project of some chosen name with three TextFields labelled x, y, and z. Also create four buttons Add, Sub, Mul, Div. The script for the Add button:
Dim x, y, z As Complex
x = new Complex(TextFieldx.text)
y = new Complex(TextFieldy.text)
z = x + y
TextFieldz.text = CStr(z) // or z.str
Do the same, with an obvious change, for the other buttons.
Now you can make Windows and Mac 32 and 64 bit Xojo applications for testing.
It might be useful to show some problems which arose before I was able to do a successful Windows make. I did not create that makefile; years ago I downloaded an example makefile for Windows from some website. The problem line in the makefile is:
$(CC) $(CFLAGS) -shared -o libComplex.DLL $(OBJS) -static
For years I used this version:
$(CC) $(CFLAGS) -shared -o libComplex.DLL $(OBJS)
My iMac running Windows 7 under Parallels crashed and could not be fixed. I did not have a copy of the Parallels installation, so on my new iMac I installed Parallels with Windows 10. I couldnt get the mays installation to work; it wouldnt recognize the g++ command. Eventually I found msys2. But that last makefiles command produced DLLs which wouldnt give working Xojo Windows applications. The Mac side always worked.
Finally I was able to produce successful DLLs for my (very large) fp Plugin with this internet-suggested makefiles line:
$(CC) $(CFLAGS) -shared -o libfpPlugin.DLL $(OBJS) -static-libgcc -static-libstdc++ -Wl,-Bstatic -lstdc++ -lpthread
Thinking I had solved the problem, I created a Xojo application using the Complex type (the above example). In Windows 10 when either the 32-bit or 64-bit version was double-clicked, there was some very brief action and then nothing happened. There was no error message or other sign that an .exe file had been double-clicked. Windows 10 was just in its normal waiting state. Using the right-click and troubleshoot compatibility gave no clues whatsoever. Nor did depends22_x86. Finally on the internet I found a suggestion that led to the successful makefile command:
$(CC) $(CFLAGS) -shared -o libComplex.DLL $(OBJS) -static
which appears to include all necessary static libraries. I remade my fp Plugin DLLs with the revised makefile and they were again successful in making working Xojo applications.
I hope the above is of help to others.