I love the JUCE library so far. It seems so much more simple and quite a bit cleaner than wxWidgets.
I’d love to start using it for my little hobby projects, but I’m not sure how I would set one up, using Code::Blocks. Something leads me to believe that all I would have to do is make sure that under ‘Search Directories’, the location to the library file created when I compiled the library is in there. I opened up the sample project created for… MSVC++, and it failed to compile, giving me:
Ick.
Basically what I’m getting at is this: what do I need to set under compiler, linker, settings and directories?
I’m using C::B without any issues - Like you, I also removed the forcedinline definitions from the library and compiled without issues.
I used the C::B projects included with the Juce distribution - I can’t remember if they’re included by default, but check you have gdi32, user32 and kernel32 as additional libraries to the linker (though that doesn’t seem to be your problem there)
The other issue seems to be to do with precompiled headers - I found I had to set the option “Generate PCH in directory alongside original header” otherwise it wouldn’t compile correctly.
Finally, in the project itself (not the library), my linker search path has …/…/bin/codeblocks added and the linker has the following libraries:
[quote=“DialTone”]I’m using C::B without any issues - Like you, I also removed the forcedinline definitions from the library and compiled without issues.
I used the C::B projects included with the Juce distribution - I can’t remember if they’re included by default, but check you have gdi32, user32 and kernel32 as additional libraries to the linker (though that doesn’t seem to be your problem there)
The other issue seems to be to do with precompiled headers - I found I had to set the option “Generate PCH in directory alongside original header” otherwise it wouldn’t compile correctly.
Finally, in the project itself (not the library), my linker search path has …/…/bin/codeblocks added and the linker has the following libraries:
This actually worked for me. I didn’t have to set the “Generate PCH in directory alongside original header option”. I did had to remove the forcedinline definitions when I compiled Juce though and was getting the same errors you were at the beginning. Explicitly adding the 12 libraries mentioned above to “Settings/Compiler and Debugger settings” under the Global compiler settings in the Linker Settings tab did the trick and I was able to compile The Jucer from the VC8 Project File. I was also able to compile the C::B Project of the Demo. Now that I’ve spent 4 hours trying to figure out how to compile something I guess I will start learning C++. I figured I would post this in case someone else is trying to do it and wants to know if it actually makes a difference.
Alright, so I am a complete newb to both C++ and Programming in general. I have a desire to do as much as I can using open source software though including the compiler and IDE so I am trying to learn this without Microsoft. My logic is that if I can do it without any hand-holding from Visual Studio then I will be a better developer because of it. I could be completely misguided but because of this approach I’ve already learned about compilers and linkers which Visual Studio never made me do (not sure if that is good or bad yet).
Anyway, this is relevant to this post because working with Juce in Code::Blocks requires that you have a clue about linking in order to get it to work. Instead of providing a list of links that happened to work for me, I thought I would post how I was able to figure out what was missing in the hope that others going forward would have better luck figuring it out for themselves.
The first post in here was missing links to juce. You can tell because it says, “undefined reference to `juce::JUCEApplication::JUCEApplication()” From what I gather, you are reading what the linker is having a problem with. Basically, it can’t find the library that contains juce code and therefore it can’t finish building the executable. That one is pretty obvious as far as figuring out what library you need to put in your linker. You probably compiled Juce but didn’t add the library to your configuration. When whatever you try to build goes looking for those juce libraries, it can’t find them and it chokes.
Logically speaking, is is probably a better practice to add to Linker Settings of the Project you want to build rather than adding it to all of them via Settings so that the libraries you are using are explicitly defined; however, I am not sure if that is true. I am going to assume that it is. Because of that, I am going to provide instructions for adding it to the Project.
Choose Project from the top of the Screen
Choose Build Options
Choose the Linker Settings tab
Click the Add button under the Link libraries list.
Enter the Path or Browse to wherever your juce lib file is. (It will be called libjuce.a or libjucedebug.a, you can search for it if you can’t find it.)
You can repeat that step for any library you appear to be missing; so, for example, when I went to compile The Jucer after importing the VS8 Project into Code::Blocks, I got the following error:
Initially this meant nothing to me. If you look at the Message though, it says undefined reference to `_DoDragDrop@16’. I did a search on google and found out that DoDragDrop is in the OLE32 Library. (I searched google for “DoDragDrop mingw lib” and eventually stumbled upon it. The mingw lib bolted on to the end of the search was to find a library that was part of mingw that contained DoDragDrop as a function or Class inside. If you go look in your mingw directory you’ll find that if you search for libole32 you will quickly find libole32.a. The reason I searched for that is because all the libraries in mingw start with lib. I then just bolted the name of the library referenced in google onto the end of lib and came up with libole32.
Create a link to that using the steps I posted above and build the project again. It will likely move past the DoDragDrop error to a new annoying error which you will have to get around. Google that value with mingw lib on the end and you will likely find the name of the next lib file you need or a reference to the library it is in at least. After a while you’ll end up with a list of 10 or 12 linked libraries (*.a) files and your project will build and run. My list included the following libraries but yours may vary:
Anyway, that is it for now. Again, I am completely new at this so I could be incorrect in what I call things or what I understand is happening; however, I’ve had a tough time cobbling this together so I figured I would post it and hopefully save someone some effort later on. It seems like C++ developers tend to just know a lot of stuff that isn’t common knowledge to people just getting started and since I am just getting started, it seemed like a good time to post it. Anyway, good luck.