OK after reading around the forums and included documentation I simply cannot get even a basic “empty” application to compile. I know it’s not my build environment because the demos build properly.
To start off with I have a single file, “pcano.cpp” which contains this code:
#include "juce_amalgamated.h"
class PianoWindow : public DocumentWindow
{
public:
PianoWindow() : DocumentWindow(T("PCAno"), Colour(0.5f,0.5f,0.5f,1.0f), closeButton, true)
{
};
};
class PCAnoApp : public JUCEApplication
{
PianoWindow* MainWindow;
public:
PCAnoApp() : MainWindow(0)
{
}
~PCAnoApp()
{
}
void initialise(const String& CommandLine)
{
MainWindow = new PianoWindow();
MainWindow->setBounds(100,100,720,128);
MainWindow->setVisible(true);
}
void shutdown()
{
delete MainWindow;
}
const String getApplicationName()
{
return T("PCAno");
}
const String getApplicationVersion()
{
return T("0.4.0");
}
};
START_JUCE_APPLICATION (PCAnoApp)
I have a makefile containing this code:
pcano:
gcc -I.. -o./bin/pcano -DLINUX pcano.cpp -lfreetype -lpthread -lX11
I’m using Linux, and GCC is working perfectly.
Output is:
/tmp/cc55Rp0U.o: In function `main':
pcano.cpp:(.text+0x4a): undefined reference to `juce::JUCEApplication::main(int, char**, juce::JUCEApplication*)'
/tmp/cc55Rp0U.o: In function `PCAnoApp::PCAnoApp()':
pcano.cpp:(.text._ZN8PCAnoAppC1Ev[PCAnoApp::PCAnoApp()]+0xd): undefined reference to `juce::JUCEApplication::JUCEApplication()'
/tmp/cc55Rp0U.o: In function `PCAnoApp::getApplicationVersion()':
pcano.cpp:(.text._ZN8PCAnoApp21getApplicationVersionEv[PCAnoApp::getApplicationVersion()]+0x18): undefined reference to `juce::String::String(wchar_t const*)'
/tmp/cc55Rp0U.o: In function `PCAnoApp::getApplicationName()':
pcano.cpp:(.text._ZN8PCAnoApp18getApplicationNameEv[PCAnoApp::getApplicationName()]+0x18): undefined reference to `juce::String::String(wchar_t const*)'
/tmp/cc55Rp0U.o: In function `PianoWindow::PianoWindow()':
pcano.cpp:(.text._ZN11PianoWindowC1Ev[PianoWindow::PianoWindow()]+0x33): undefined reference to `juce::Colour::Colour(float, float, float, float)'
pcano.cpp:(.text._ZN11PianoWindowC1Ev[PianoWindow::PianoWindow()]+0x46): undefined reference to `juce::String::String(wchar_t const*)'
pcano.cpp:(.text._ZN11PianoWindowC1Ev[PianoWindow::PianoWindow()]+0x6f): undefined reference to `juce::DocumentWindow::DocumentWindow(juce::String const&, juce::Colour const&, int, bool)'
pcano.cpp:(.text._ZN11PianoWindowC1Ev[PianoWindow::PianoWindow()]+0x80): undefined reference to `juce::String::~String()'
pcano.cpp:(.text._ZN11PianoWindowC1Ev[PianoWindow::PianoWindow()]+0x8b): undefined reference to `juce::Colour::~Colour()'
pcano.cpp:(.text._ZN11PianoWindowC1Ev[PianoWindow::PianoWindow()]+0xc2): undefined reference to `juce::String::~String()'
pcano.cpp:(.text._ZN11PianoWindowC1Ev[PianoWindow::PianoWindow()]+0xd9): undefined reference to `juce::Colour::~Colour()'
/tmp/cc55Rp0U.o: In function `PCAnoApp::initialise(juce::String const&)':
pcano.cpp:(.text._ZN8PCAnoApp10initialiseERKN4juce6StringE[PCAnoApp::initialise(juce::String const&)]+0x55): undefined reference to `juce::Component::setBounds(int, int, int, int)'
/tmp/cc55Rp0U.o: In function `PianoWindow::~PianoWindow()':
pcano.cpp:(.text._ZN11PianoWindowD0Ev[PianoWindow::~PianoWindow()]+0x28): undefined reference to `juce::DocumentWindow::~DocumentWindow()'
/tmp/cc55Rp0U.o: In function `PianoWindow::~PianoWindow()':
pcano.cpp:(.text._ZN11PianoWindowD1Ev[PianoWindow::~PianoWindow()]+0x28): undefined reference to `juce::DocumentWindow::~DocumentWindow()'
/tmp/cc55Rp0U.o: In function `PCAnoApp::~PCAnoApp()':
pcano.cpp:(.text._ZN8PCAnoAppD0Ev[PCAnoApp::~PCAnoApp()]+0x28): undefined reference to `juce::JUCEApplication::~JUCEApplication()'
/tmp/cc55Rp0U.o: In function `PCAnoApp::~PCAnoApp()':
pcano.cpp:(.text._ZN8PCAnoAppD1Ev[PCAnoApp::~PCAnoApp()]+0x28): undefined reference to `juce::JUCEApplication::~JUCEApplication()'
/tmp/cc55Rp0U.o:(.rodata._ZTV8PCAnoApp[vtable for PCAnoApp]+0x10): undefined reference to `juce::JUCEApplication::getNextCommandTarget()'
/tmp/cc55Rp0U.o:(.rodata._ZTV8PCAnoApp[vtable for PCAnoApp]+0x14): undefined reference to `juce::JUCEApplication::getAllCommands(juce::Array<int, juce::DummyCriticalSection>&)'
/tmp/cc55Rp0U.o:(.rodata._ZTV8PCAnoApp[vtable for PCAnoApp]+0x18): undefined reference to `juce::JUCEApplication::getCommandInfo(int, juce::ApplicationCommandInfo&)'
/tmp/cc55Rp0U.o:(.rodata._ZTV8PCAnoApp[vtable for PCAnoApp]+0x1c): undefined reference to `juce::JUCEApplication::perform(juce::ApplicationCommandTarget::InvocationInfo const&)'
/tmp/cc55Rp0U.o:(.rodata._ZTV8PCAnoApp[vtable for PCAnoApp]+0x30): undefined reference to `juce::JUCEApplication::moreThanOneInstanceAllowed()'
/tmp/cc55Rp0U.o:(.rodata._ZTV8PCAnoApp[vtable for PCAnoApp]+0x34): undefined reference to `juce::JUCEApplication::anotherInstanceStarted(juce::String const&)'
/tmp/cc55Rp0U.o:(.rodata._ZTV8PCAnoApp[vtable for PCAnoApp]+0x38): undefined reference to `juce::JUCEApplication::systemRequestedQuit()'
/tmp/cc55Rp0U.o:(.rodata._ZTV8PCAnoApp[vtable for PCAnoApp]+0x3c): undefined reference to `juce::JUCEApplication::unhandledException(std::exception const*, juce::String const&, int)'
/tmp/cc55Rp0U.o:(.rodata._ZTV8PCAnoApp[vtable for PCAnoApp]+0x40): undefined reference to `juce::JUCEApplication::actionListenerCallback(juce::String const&)'
/tmp/cc55Rp0U.o:(.rodata._ZTV8PCAnoApp[vtable for PCAnoApp]+0x54): undefined reference to `non-virtual thunk to juce::JUCEApplication::actionListenerCallback(juce::String const&)'
/tmp/cc55Rp0U.o:(.rodata._ZTI8PCAnoApp[typeinfo for PCAnoApp]+0x8): undefined reference to `typeinfo for juce::JUCEApplication'
/tmp/cc55Rp0U.o:(.rodata._ZTV11PianoWindow[vtable for PianoWindow]+0x10): undefined reference to `juce::Component::mouseMove(juce::MouseEvent const&)'
/tmp/cc55Rp0U.o:(.rodata._ZTV11PianoWindow[vtable for PianoWindow]+0x14): undefined reference to `juce::Component::mouseEnter(juce::MouseEvent const&)'
/tmp/cc55Rp0U.o:(.rodata._ZTV11PianoWindow[vtable for PianoWindow]+0x18): undefined reference to `juce::Component::mouseExit(juce::MouseEvent const&)'
/tmp/cc55Rp0U.o:(.rodata._ZTV11PianoWindow[vtable for PianoWindow]+0x1c): undefined reference to `juce::ResizableWindow::mouseDown(juce::MouseEvent const&)'
/tmp/cc55Rp0U.o:(.rodata._ZTV11PianoWindow[vtable for PianoWindow]+0x20): undefined reference to `juce::ResizableWindow::mouseDrag(juce::MouseEvent const&)'
/tmp/cc55Rp0U.o:(.rodata._ZTV11PianoWindow[vtable for PianoWindow]+0x24): undefined reference to `juce::Component::mouseUp(juce::MouseEvent const&)'
/tmp/cc55Rp0U.o:(.rodata._ZTV11PianoWindow[vtable for PianoWindow]+0x28): undefined reference to `juce::DocumentWindow::mouseDoubleClick(juce::MouseEvent const&)'
/tmp/cc55Rp0U.o:(.rodata._ZTV11PianoWindow[vtable for PianoWindow]+0x2c): undefined reference to `juce::Component::mouseWheelMove(juce::MouseEvent const&, float, float)'
/tmp/cc55Rp0U.o:(.rodata._ZTV11PianoWindow[vtable for PianoWindow]+0x34): undefined reference to `juce::DocumentWindow::setName(juce::String const&)'
/tmp/cc55Rp0U.o:(.rodata._ZTV11PianoWindow[vtable for PianoWindow]+0x38): undefined reference to `juce::Component::setVisible(bool)'
/tmp/cc55Rp0U.o:(.rodata._ZTV11PianoWindow[vtable for PianoWindow]+0x3c): undefined reference to `juce::ResizableWindow::visibilityChanged()'
/tmp/cc55Rp0U.o:(.rodata._ZTV11PianoWindow[vtable for PianoWindow]+0x40): undefined reference to `juce::TopLevelWindow::addToDesktop(int, void*)'
/tmp/cc55Rp0U.o:(.rodata._ZTV11PianoWindow[vtable for PianoWindow]+0x44): undefined reference to `juce::DocumentWindow::userTriedToCloseWindow()'
/tmp/cc55Rp0U.o:(.rodata._ZTV11PianoWindow[vtable for PianoWindow]+0x48): undefined reference to `juce::Component::minimisationStateChanged(bool)'
/tmp/cc55Rp0U.o:(.rodata._ZTV11PianoWindow[vtable for PianoWindow]+0x4c): undefined reference to `juce::DocumentWindow::parentHierarchyChanged()'
/tmp/cc55Rp0U.o:(.rodata._ZTV11PianoWindow[vtable for PianoWindow]+0x50): undefined reference to `juce::Component::childrenChanged()'
/tmp/cc55Rp0U.o:(.rodata._ZTV11PianoWindow[vtable for PianoWindow]+0x54): undefined reference to `juce::Component::hitTest(int, int)'
/tmp/cc55Rp0U.o:(.rodata._ZTV11PianoWindow[vtable for PianoWindow]+0x58): undefined reference to `juce::Component::contains(int, int)'
/tmp/cc55Rp0U.o:(.rodata._ZTV11PianoWindow[vtable for PianoWindow]+0x5c): undefined reference to `juce::DocumentWindow::lookAndFeelChanged()'
/tmp/cc55Rp0U.o:(.rodata._ZTV11PianoWindow[vtable for PianoWindow]+0x60): undefined reference to `juce::Component::createFocusTraverser()'
/tmp/cc55Rp0U.o:(.rodata._ZTV11PianoWindow[vtable for PianoWindow]+0x64): undefined reference to `juce::Component::enablementChanged()'
/tmp/cc55Rp0U.o:(.rodata._ZTV11PianoWindow[vtable for PianoWindow]+0x68): undefined reference to `juce::Component::getMouseCursor()'
/tmp/cc55Rp0U.o:(.rodata._ZTV11PianoWindow[vtable for PianoWindow]+0x6c): undefined reference to `juce::DocumentWindow::paint(juce::Graphics&)'
/tmp/cc55Rp0U.o:(.rodata._ZTV11PianoWindow[vtable for PianoWindow]+0x70): undefined reference to `juce::Component::paintOverChildren(juce::Graphics&)'
/tmp/cc55Rp0U.o:(.rodata._ZTV11PianoWindow[vtable for PianoWindow]+0x74): undefined reference to `juce::Component::keyPressed(juce::KeyPress const&)'
/tmp/cc55Rp0U.o:(.rodata._ZTV11PianoWindow[vtable for PianoWindow]+0x78): undefined reference to `juce::Component::keyStateChanged()'
/tmp/cc55Rp0U.o:(.rodata._ZTV11PianoWindow[vtable for PianoWindow]+0x7c): undefined reference to `juce::Component::modifierKeysChanged(juce::ModifierKeys const&)'
/tmp/cc55Rp0U.o:(.rodata._ZTV11PianoWindow[vtable for PianoWindow]+0x80): undefined reference to `juce::Component::focusGained(juce::Component::FocusChangeType)'
/tmp/cc55Rp0U.o:(.rodata._ZTV11PianoWindow[vtable for PianoWindow]+0x84): undefined reference to `juce::Component::focusLost(juce::Component::FocusChangeType)'
/tmp/cc55Rp0U.o:(.rodata._ZTV11PianoWindow[vtable for PianoWindow]+0x88): undefined reference to `juce::TopLevelWindow::focusOfChildComponentChanged(juce::Component::FocusChangeType)'
/tmp/cc55Rp0U.o:(.rodata._ZTV11PianoWindow[vtable for PianoWindow]+0x8c): undefined reference to `juce::DocumentWindow::resized()'
/tmp/cc55Rp0U.o:(.rodata._ZTV11PianoWindow[vtable for PianoWindow]+0x90): undefined reference to `juce::ResizableWindow::moved()'
/tmp/cc55Rp0U.o:(.rodata._ZTV11PianoWindow[vtable for PianoWindow]+0x94): undefined reference to `juce::ResizableWindow::childBoundsChanged(juce::Component*)'
/tmp/cc55Rp0U.o:(.rodata._ZTV11PianoWindow[vtable for PianoWindow]+0x98): undefined reference to `juce::ResizableWindow::parentSizeChanged()'
/tmp/cc55Rp0U.o:(.rodata._ZTV11PianoWindow[vtable for PianoWindow]+0x9c): undefined reference to `juce::Component::broughtToFront()'
/tmp/cc55Rp0U.o:(.rodata._ZTV11PianoWindow[vtable for PianoWindow]+0xa0): undefined reference to `juce::Component::handleCommandMessage(int)'
/tmp/cc55Rp0U.o:(.rodata._ZTV11PianoWindow[vtable for PianoWindow]+0xa4): undefined reference to `juce::Component::canModalEventBeSentToComponent(juce::Component const*)'
/tmp/cc55Rp0U.o:(.rodata._ZTV11PianoWindow[vtable for PianoWindow]+0xa8): undefined reference to `juce::Component::inputAttemptWhenModal()'
/tmp/cc55Rp0U.o:(.rodata._ZTV11PianoWindow[vtable for PianoWindow]+0xac): undefined reference to `juce::Component::colourChanged()'
/tmp/cc55Rp0U.o:(.rodata._ZTV11PianoWindow[vtable for PianoWindow]+0xb4): undefined reference to `juce::Component::internalRepaint(int, int, int, int)'
/tmp/cc55Rp0U.o:(.rodata._ZTV11PianoWindow[vtable for PianoWindow]+0xb8): undefined reference to `juce::Component::createNewPeer(int, void*)'
/tmp/cc55Rp0U.o:(.rodata._ZTV11PianoWindow[vtable for PianoWindow]+0xbc): undefined reference to `juce::Component::handleMessage(juce::Message const&)'
/tmp/cc55Rp0U.o:(.rodata._ZTV11PianoWindow[vtable for PianoWindow]+0xc0): undefined reference to `juce::DocumentWindow::activeWindowStatusChanged()'
/tmp/cc55Rp0U.o:(.rodata._ZTV11PianoWindow[vtable for PianoWindow]+0xc4): undefined reference to `juce::DocumentWindow::getDesktopWindowStyleFlags() const'
/tmp/cc55Rp0U.o:(.rodata._ZTV11PianoWindow[vtable for PianoWindow]+0xc8): undefined reference to `juce::DocumentWindow::getBorderThickness()'
/tmp/cc55Rp0U.o:(.rodata._ZTV11PianoWindow[vtable for PianoWindow]+0xcc): undefined reference to `juce::DocumentWindow::getContentComponentBorder()'
/tmp/cc55Rp0U.o:(.rodata._ZTV11PianoWindow[vtable for PianoWindow]+0xd0): undefined reference to `juce::DocumentWindow::closeButtonPressed()'
/tmp/cc55Rp0U.o:(.rodata._ZTV11PianoWindow[vtable for PianoWindow]+0xd4): undefined reference to `juce::DocumentWindow::minimiseButtonPressed()'
/tmp/cc55Rp0U.o:(.rodata._ZTV11PianoWindow[vtable for PianoWindow]+0xd8): undefined reference to `juce::DocumentWindow::maximiseButtonPressed()'
/tmp/cc55Rp0U.o:(.rodata._ZTV11PianoWindow[vtable for PianoWindow]+0xec): undefined reference to `non-virtual thunk to juce::Component::handleMessage(juce::Message const&)'
/tmp/cc55Rp0U.o:(.rodata._ZTI11PianoWindow[typeinfo for PianoWindow]+0x8): undefined reference to `typeinfo for juce::DocumentWindow'
collect2: ld returned 1 exit status
make: *** [pcano] Error 1
The “-I…” part is because I have juce_amalgamated.h/.cpp in the parent directory, they are getting included just fine.
When I run this, however, I get a bazillion errors from GCC about undefined references! Yet this code is practically the same as the demos I’ve seen, it just doesn’t do anything yet other than create and display a window.
I don’t want to copy and paste anything because I’m not learning anything that way, so could someone please explain this to me?