Code::Blocks

I can’t reproduce this, i never installed gcc lower then 4.7 on the laptop i have, and i saw this error and i remember replacing “zerostruct” with the code that’s inside this function.

But i have a different problem, i created a brand new VST plugin project and wanted to compile it in codeblocks, 3 issues came up

This is the GCC version i use:

C:\MinGW\bin>"mingw32-c++.exe" -v
Using built-in specs.
COLLECT_GCC=mingw32-c++.exe
COLLECT_LTO_WRAPPER=c:/mingw/bin/../libexec/gcc/mingw32/4.7.2/lto-wrapper.exe
Target: mingw32
Configured with: ../gcc-4.7.2/configure --enable-languages=c,c++,ada,fortran,obj
c,obj-c++ --disable-sjlj-exceptions --with-dwarf2 --enable-shared --enable-libgo
mp --disable-win32-registry --enable-libstdcxx-debug --disable-build-poststage1-
with-cxx --enable-version-specific-runtime-libs --build=mingw32 --prefix=/mingw
Thread model: win32
gcc version 4.7.2 (GCC)
  1. the VST sdk path is not added to the include paths of the project
  2. in the debug configuration the -g flag is not turned on (no debugging symbols are created)
  3. This error shows up:
[ 45.8%] mingw32-g++.exe -Wno-strict-aliasing -Wno-strict-overflow -march=pentium4 -O0 -std=gnu++0x -D__MINGW__=1 -D__MINGW_EXTENSION= -DJUCER_CODEBLOCKS_20734A5D=1 -I. -I..\..\JuceLibraryCode -Ic:\devel\vstsdk2.4 -IC:\devel\Morf\JuceLibraryCode\modules\juce_audio_plugin_client\VST -c C:\devel\Morf\JuceLibraryCode\modules\juce_audio_plugin_client\VST\juce_VST_Wrapper.cpp -o obj\Debug\JuceLibraryCode\modules\juce_audio_plugin_client\VST\juce_VST_Wrapper.o
C:\devel\Morf\JuceLibraryCode\modules\juce_audio_plugin_client\VST\juce_VST_Wrapper.cpp:66:0: warning: "__cdecl" redefined [enabled by default]
C:\devel\Morf\JuceLibraryCode\modules\juce_audio_plugin_client\VST\juce_VST_Wrapper.cpp:1:0: note: this is the location of the previous definition
C:\devel\Morf\JuceLibraryCode\modules\juce_audio_plugin_client\VST\juce_VST_Wrapper.cpp:287:29: warning: multi-character character constant [-Wmultichar]
In file included from C:\devel\Morf\JuceLibraryCode\modules\juce_audio_plugin_client\VST\juce_VST_Wrapper.cpp:78:0:
c:\devel\vstsdk2.4/public.sdk/source/vst2.x/audioeffectx.cpp: In member function 'virtual void AudioEffectX::resume()':
c:\devel\vstsdk2.4/public.sdk/source/vst2.x/audioeffectx.cpp:307:69: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
C:\devel\Morf\JuceLibraryCode\modules\juce_audio_plugin_client\VST\juce_VST_Wrapper.cpp: In function 'LRESULT {anonymous}::mouseWheelHookCallback(int, WPARAM, LPARAM)':
C:\devel\Morf\JuceLibraryCode\modules\juce_audio_plugin_client\VST\juce_VST_Wrapper.cpp:174:19: error: 'MOUSEHOOKSTRUCTEX' does not name a type
C:\devel\Morf\JuceLibraryCode\modules\juce_audio_plugin_client\VST\juce_VST_Wrapper.cpp:176:93: error: 'hs' was not declared in this scope
C:\devel\Morf\JuceLibraryCode\modules\juce_audio_plugin_client\VST\juce_VST_Wrapper.cpp: At global scope:
C:\devel\Morf\JuceLibraryCode\modules\juce_audio_plugin_client\VST\juce_VST_Wrapper.cpp:1553:43: warning: first argument of 'int main(audioMasterCallback)' should be 'int' [-Wmain]
C:\devel\Morf\JuceLibraryCode\modules\juce_audio_plugin_client\VST\juce_VST_Wrapper.cpp:1553:43: warning: 'int main(audioMasterCallback)' takes only zero or two arguments [-Wmain]
Process terminated with status 1 (0 minute(s), 13 second(s))
2 error(s), 5 warning(s) (0 minute(s), 13 second(s))

Maybe you’re using some kind of 3rd party header that’s #defining a symbol and messing up the build?

Re: building VSTs in CodeBlocks, if you want to find a way to get it going and let me know what you needed to do, that’d be awesome, but it’s too low-priority for me to look at it myself.

Looks like this might be an issue with MinGW, if i add the MOUSEHOOKSTRUCTEX definition to winuser.h it seems to compile, i found that definition here: http://sourceforge.net/apps/trac/mingw-w64/browser/stable/v2.x/mingw-w64-headers/include/winuser.h?rev=4451

#ifdef __cplusplus
  typedef struct tagMOUSEHOOKSTRUCTEX : public tagMOUSEHOOKSTRUCT {
    DWORD mouseData;
  } MOUSEHOOKSTRUCTEX,*LPMOUSEHOOKSTRUCTEX,*PMOUSEHOOKSTRUCTEX;
#else
  typedef struct tagMOUSEHOOKSTRUCTEX {
    MOUSEHOOKSTRUCT _unnamed;
    DWORD mouseData;
  } MOUSEHOOKSTRUCTEX,*LPMOUSEHOOKSTRUCTEX,*PMOUSEHOOKSTRUCTEX;
#endif

Also the WM_APPCOMMAND issue is still there, it’s described here (i had to add the defintion to the WM_ commadn on top of juce_VSTPluginFormat.cpp)
http://www.rawmaterialsoftware.com/viewtopic.php?f=3&t=4222&start=0

The bigger issue is in the same file:

C:\devel\JUCE\modules\juce_audio_processors\format_types/juce_VSTPluginFormat.cpp: In member function 'virtual void juce::VSTPluginWindow::paint(juce::Graphics&)':
C:\devel\JUCE\modules\juce_audio_processors\format_types/juce_VSTPluginFormat.cpp:2053:66: error: 'class juce::ComponentPeer' has no member named 'getScreenPosition'
Process terminated with status 1 (0 minute(s), 1 second(s))
1 error(s), 19 warning(s) (0 minute(s), 1 second(s))

Now i tried a bit of a hacky way and just commented out the offending line

peer->addMaskedRegion (getScreenBounds() - peer->getScreenPosition());

It compiled fine, the Plugin Host demo got build, then a Hello World Plugin got build and i was able to load the DLL in the Audio Plugin Host. So it works i just don’t know why that method is not visible in that file.

It could be declared at the start of the cpp file inside an #if JUCE_MINGW. Could you try it and suggest some code that compiles? I don’t have time to put together a codeblocks plugin project myself.

For building an Audio Plugin, in juce_VST_Wrapper.cpp, at line 38, add

#ifdef __MINGW32__
#include <windows.h>
#ifdef __cplusplus
  typedef struct tagMOUSEHOOKSTRUCTEX : public tagMOUSEHOOKSTRUCT {
    DWORD mouseData;
  } MOUSEHOOKSTRUCTEX,*LPMOUSEHOOKSTRUCTEX,*PMOUSEHOOKSTRUCTEX;
#else
  typedef struct tagMOUSEHOOKSTRUCTEX {
    MOUSEHOOKSTRUCT _unnamed;
    DWORD mouseData;
  } MOUSEHOOKSTRUCTEX,*LPMOUSEHOOKSTRUCTEX,*PMOUSEHOOKSTRUCTEX;
#endif
#endif // __MINGW32__

For building a Plugin Host, in juce_VSTPluginFormat.cpp, at line 69 (isnide the JUCE_MINGW block) add

 #ifndef WM_APPCOMMAND
 #define WM_APPCOMMAND 0x0319
 #endif

At line 2052 comment out (i don’t know why this fails, i also don’t know what will happen on other platforms if you comment this out, it seems to work)

peer->addMaskedRegion (getScreenBounds() - peer->getScreenPosition());

Thanks. (The maskedregion thing was actually just a mistake which I fixed a few mins ago)

I’ve also been fiddling around with building VSTs in CodeBlocks.

One issue I have noticed, that is easy to fix, is that the CodeBlocks project the Introjucer makes is set up to build a GUI application rather than a dynamic library.

I have another problem as well which I have no idea why exists. I have created a simple gain plugin project in the Introjucer to test a few things. Just one parameter controlling gain and no editor.

At first my processBlock looked like this:

Nice and simple. This works fine when I build in Visual Studio. But the plugin causes the host to crash if I build in CodeBlocks.

Changing it to something like this:

[code]const int numSamples = buffer.getNumSamples();
for (int channel = 0; channel < getNumInputChannels(); ++channel)
{
float* channelData = buffer.getSampleData (channel);

    for (int i = 0; i < numSamples; ++i)
    {
        channelData[i] *= gain;
    }
}[/code]

Everything seems to work fine when building in CodeBlocks.

Any reason this might be the case?

Maybe try debugging into the FloatVectorOperations class - could be that some of the SSE intrinsics aren’t being correctly compiled by mingw?

That was indeed the problem. Adding the -mstackrealign flag to the build options sorted it.

Ok, thanks… I guess I should add that flag by default then.

The change you made to juce_VST_Wrapper.cpp causes a problem

C:\devel\JUCE\modules\juce_audio_plugin_client\VST\juce_VST_Wrapper.cpp: In function 'LRESULT {anonymous}::mouseWheelHookCallback(int, WPARAM, LPARAM)':
C:\devel\JUCE\modules\juce_audio_plugin_client\VST\juce_VST_Wrapper.cpp:184:96: error: 'const struct MOUSEHOOKSTRUCTEX' has no member named 'pt'
C:\devel\JUCE\modules\juce_audio_plugin_client\VST\juce_VST_Wrapper.cpp:184:105: error: 'const struct MOUSEHOOKSTRUCTEX' has no member named 'pt'
C:\devel\JUCE\modules\juce_audio_plugin_client\VST\juce_VST_Wrapper.cpp:187:72: error: 'const struct MOUSEHOOKSTRUCTEX' has no member named 'pt'
C:\devel\JUCE\modules\juce_audio_plugin_client\VST\juce_VST_Wrapper.cpp:187:93: error: 'const struct MOUSEHOOKSTRUCTEX' has no member named 'pt'
C:\devel\JUCE\modules\juce_audio_plugin_client\VST\juce_VST_Wrapper.cpp: At global scope:

I think that you need to inherit from other structures so you can see all members of it

Oh yes, sorry. Try again now.

I also noticed some weird stuff.

When compiling with GCC on windows, i can’t get the DLL path inside the plugin it always returns the host path. When i use the MS compiler with codeblocks, it works (i have both installed, MS compiler is just faster, they’re both free and i can’t install visual studio cause i don’t have admin privileges on my workstation).

Also i can’t debug using CDB or GDB when compiling with GCC, i know this isn’t JUCE related, but maybe someone has an idea on how to debug VST plugins with GCC/GDB, GDB does not load new symbols when a VST is loaded in the host (i use the Plugin Host from the extras dir). I don’t see the debug output (anything that comes from Logger::writeToLog) in the debugger console, i re-compiled the Plugin Host with debugging enabled, that didn’t help. I thought that the host should be built without debugging symbols and just the plugins should have the debugging symbols so they don’t cause problems. I can load additional symbols to gdb using “symbols-file” command but when i do that the host doesn’t start with Memory I/O errors. Anyone knows how to deal with that ?

host.exe is a compiled and rename Plugin Host.exe

[debug]> dll-symbols c:/devel/VstPlugins/MoRf_Synth1.dll
[debug]>>>>>>cb_gdb:
[debug]> directory C:/devel/morf/Builds/CodeBlocks/
[debug]Source directories searched: C:/devel/morf/Builds/CodeBlocks;$cdir;$cwd
[debug]>>>>>>cb_gdb:
[debug]> directory C:/devel/
[debug]Source directories searched: C:/devel;C:/devel/morf/Builds/CodeBlocks;$cdir;$cwd
[debug]>>>>>>cb_gdb:
[debug]> run
[debug]Starting program: c:\devel\morf\host.exe 

Child process PID: 4968

[debug][New Thread 4968.0x1630]
[debug]Warning:
[debug]Cannot insert breakpoint 1.
[debug]Error accessing memory address 0x6fb2793c: Input/output error.
[debug]>>>>>>cb_gdb:

Error accessing memory address 0x6fb2793c: Input/output error.

I have a couple of additions to jucer_ProjectExport_CodeBlocks.h to set up the CodeBlocks project correctly.

To ensure the CodeBlocks project will build a dynamic library when you have made an audio plugin project via the Introjucer I added this at line 189:

Also to make sure that the debug config in CodeBlocks will compile with debugging symbols I added this at line 134:

Perhaps that’s not the best place to add that but it seems to work for me.

Thanks!

If possible could Introjucer not use compiler flags but IDE specific flags. For example Codeblocks knows how to enable debug symbols on almost all compilers, but if you add “-g” it will fail with MS compiler. The same goes for all other flags that introjucer adds to the generated project.

I know very little about how codeblocks works, so am relying on you guys for tips here - any idea how to change it to do that?

As far as I am aware this is a problem with CodeBlocks itself. Even if you create a project solely within CodeBlocks changing the compiler will mess up all the flags.

I think you could possibly add a new build target to the CodeBlocks project which uses the compiler you want. Having the Introjucer create CodeBlocks projects which have a target for each compiler seems a bit silly to me though.

Well no Introjucer should no export project for ALL compilers, i don’t event think that Introjucer should have an option to choose a compiler. But the codeblocks projects are compiler independent, i switch between GCC and MSVC all the time, i’ve seen no real problems with that. Event if it is problematic Introjucer is export a Codeblocks project not a GCC project, so it should use Codeblocks flags not GCC flags just as it does for XCode and MSVC.

Having said that, now that i look at the .cbp file i don’t think it’s possible, it specifies compiler specific flags inside the file, so the IDE just adds/removes those flags whenever you pick the compiler.

Forget it then :slight_smile: it makes no sense to implement this, it’s Codeblocks that’s doing this all wrong.