Trouble linking simple Juce application


#1

I’m trying to build a simple juce program in Anjuta, but I’m getting link errors:

mike@ubuntu:~/Desktop/Development/Juce/juce1$ make
make  all-recursive
make[1]: Entering directory `/home/mike/Desktop/Development/Juce/juce1'
Making all in src
make[2]: Entering directory `/home/mike/Desktop/Development/Juce/juce1/src'
g++ -I/opt/juce -I/opt/juce/src -g -O2   -o juce1 -L/opt/juce/bin/libjuce_debug.a main.o  
main.o: In function `JUCEHelloWorldApplication':
/home/mike/Desktop/Development/Juce/juce1/src/main.cc:101: undefined reference to `juce::JUCEApplication::JUCEApplication()'
main.o: In function `main':
/home/mike/Desktop/Development/Juce/juce1/src/main.cc:163: undefined reference to `juce::JUCEApplication::main(int, char**, juce::JUCEApplication*)'
main.o: In function `JUCEHelloWorldApplication::getApplicationVersion()':

I’m sure I have the linker option -L setup properly and it points to the library file. So any ideas what I’m doing wrong?

Thanks


#2

I’ll have to check to make sure the library was linked correctly and contains all the right symbols.


#3

I think the problem may be in the Linux build somehow.

/home/mike/Desktop/Development/Juce/juce22/src/main.cc:70: undefined reference to `juce::DocumentWindow::~DocumentWindow()’

nm libjuce_debug.a | grep DocumentWindow U _ZN4juce14DocumentWindow16mouseDoubleClickERKNS_10MouseEventE U _ZN4juce14DocumentWindow18getBorderThicknessEv U _ZN4juce14DocumentWindow18lookAndFeelChangedEv U _ZN4juce14DocumentWindow21maximiseButtonPressedEv U _ZN4juce14DocumentWindow21minimiseButtonPressedEv U _ZN4juce14DocumentWindow22userTriedToCloseWindowEv U _ZN4juce14DocumentWindow25activeWindowStatusChangedEv U _ZN4juce14DocumentWindow25getContentComponentBorderEv U _ZN4juce14DocumentWindow5paintERNS_8GraphicsE U _ZN4juce14DocumentWindow7setNameERKNS_6StringE U _ZNK4juce14DocumentWindow26getDesktopWindowStyleFlagsEv U _ZN4juce14DocumentWindow16mouseDoubleClickERKNS_10MouseEventE U _ZN4juce14DocumentWindow18getBorderThicknessEv U _ZN4juce14DocumentWindow18lookAndFeelChangedEv U _ZN4juce14DocumentWindow21minimiseButtonPressedEv U _ZN4juce14DocumentWindow22userTriedToCloseWindowEv U _ZN4juce14DocumentWindow25activeWindowStatusChangedEv U _ZN4juce14DocumentWindow25getContentComponentBorderEv U _ZN4juce14DocumentWindow5paintERNS_8GraphicsE U _ZN4juce14DocumentWindow7resizedEv U _ZN4juce14DocumentWindow7setNameERKNS_6StringE U _ZN4juce14DocumentWindowC2ERKNS_6StringERKNS_6ColourEib U _ZN4juce14DocumentWindowD2Ev 00001daa T _ZN4juce18MultiDocumentPanel23createNewDocumentWindowEv U _ZNK4juce14DocumentWindow26getDesktopWindowStyleFlagsEv U _ZTIN4juce14DocumentWindowE 00004f1e T _ZN4juce11LookAndFeel26createDocumentWindowButtonEi 00005494 T _ZN4juce11LookAndFeel26drawDocumentWindowTitleBarERNS_14DocumentWindowERNS_8GraphicsEiiiiPKNS_5ImageEb 00004dcc T _ZN4juce11LookAndFeel29positionDocumentWindowButtonsERNS_14DocumentWindowEiiiiPNS_6ButtonES4_S4_b U _ZN4juce11LookAndFeel26drawDocumentWindowTitleBarERNS_14DocumentWindowERNS_8GraphicsEiiiiPKNS_5ImageEb 000001a4 T _ZN4juce20OldSchoolLookAndFeel26createDocumentWindowButtonEi 00000022 T _ZN4juce20OldSchoolLookAndFeel29positionDocumentWindowButtonsERNS_14DocumentWindowEiiiiPNS_6ButtonES4_S4_b U _ZN4juce14DocumentWindow16mouseDoubleClickERKNS_10MouseEventE U _ZN4juce14DocumentWindow18getBorderThicknessEv U _ZN4juce14DocumentWindow18lookAndFeelChangedEv U _ZN4juce14DocumentWindow21maximiseButtonPressedEv U _ZN4juce14DocumentWindow21minimiseButtonPressedEv U _ZN4juce14DocumentWindow22userTriedToCloseWindowEv U _ZN4juce14DocumentWindow25activeWindowStatusChangedEv U _ZN4juce14DocumentWindow25getContentComponentBorderEv U _ZN4juce14DocumentWindow5paintERNS_8GraphicsE U _ZN4juce14DocumentWindow7setNameERKNS_6StringE U _ZNK4juce14DocumentWindow26getDesktopWindowStyleFlagsEv U _ZN4juce14DocumentWindow16mouseDoubleClickERKNS_10MouseEventE U _ZN4juce14DocumentWindow18closeButtonPressedEv U _ZN4juce14DocumentWindow18getBorderThicknessEv U _ZN4juce14DocumentWindow18lookAndFeelChangedEv U _ZN4juce14DocumentWindow21maximiseButtonPressedEv U _ZN4juce14DocumentWindow21minimiseButtonPressedEv U _ZN4juce14DocumentWindow22userTriedToCloseWindowEv U _ZN4juce14DocumentWindow25activeWindowStatusChangedEv U _ZN4juce14DocumentWindow25getContentComponentBorderEv U _ZN4juce14DocumentWindow5paintERNS_8GraphicsE U _ZN4juce14DocumentWindow7resizedEv U _ZN4juce14DocumentWindow7setNameERKNS_6StringE U _ZN4juce14DocumentWindowC2ERKNS_6StringERKNS_6ColourEib U _ZN4juce14DocumentWindowD2Ev U _ZNK4juce14DocumentWindow14getCloseButtonEv U _ZNK4juce14DocumentWindow26getDesktopWindowStyleFlagsEv U _ZTIN4juce14DocumentWindowE juce_DocumentWindow.o: 00000be0 T _ZN4juce14DocumentWindow10setMenuBarEPNS_12MenuBarModelEi 00000d38 T _ZN4juce14DocumentWindow15repaintTitleBarEv 00000206 T _ZN4juce14DocumentWindow16mouseDoubleClickERKNS_10MouseEventE 00000dc0 T _ZN4juce14DocumentWindow17setTitleBarHeightEi 00000b96 T _ZN4juce14DocumentWindow18closeButtonPressedEv 0000033c T _ZN4juce14DocumentWindow18getBorderThicknessEv 000003fa T _ZN4juce14DocumentWindow18lookAndFeelChangedEv 000000bc T _ZN4juce14DocumentWindow19ButtonListenerProxy13buttonClickedEPNS_6ButtonE 0000009e T _ZN4juce14DocumentWindow19ButtonListenerProxyC1Ev 00000080 T _ZN4juce14DocumentWindow19ButtonListenerProxyC2Ev 00000000 W _ZN4juce14DocumentWindow19ButtonListenerProxyD0Ev 00000000 W _ZN4juce14DocumentWindow19ButtonListenerProxyD1Ev 00000b52 T _ZN4juce14DocumentWindow21maximiseButtonPressedEv 00000b7a T _ZN4juce14DocumentWindow21minimiseButtonPressedEv 00000d9a T _ZN4juce14DocumentWindow22setTitleBarTextCentredEb 00000064 T _ZN4juce14DocumentWindow22userTriedToCloseWindowEv 0000036c T _ZN4juce14DocumentWindow25activeWindowStatusChangedEv 000002a2 T _ZN4juce14DocumentWindow25getContentComponentBorderEv 00000000 T _ZN4juce14DocumentWindow26setTitleBarButtonsRequiredEib 0000083c T _ZN4juce14DocumentWindow5paintERNS_8GraphicsE 000006cc T _ZN4juce14DocumentWindow7resizedEv 00000df4 T _ZN4juce14DocumentWindow7setIconEPKNS_5ImageE 00000e7a T _ZN4juce14DocumentWindow7setNameERKNS_6StringE 0000127e T _ZN4juce14DocumentWindowC1ERKNS_6StringERKNS_6ColourEib 0000139a T _ZN4juce14DocumentWindowC2ERKNS_6StringERKNS_6ColourEib 00000ebe T _ZN4juce14DocumentWindowD0Ev 00000ffe T _ZN4juce14DocumentWindowD1Ev 0000113e T _ZN4juce14DocumentWindowD2Ev 0000015e T _ZNK4juce14DocumentWindow13getBorderSizeEv 0000003a T _ZNK4juce14DocumentWindow14getCloseButtonEv 00000056 T _ZNK4juce14DocumentWindow17getMaximiseButtonEv 00000048 T _ZNK4juce14DocumentWindow17getMinimiseButtonEv 000001bc T _ZNK4juce14DocumentWindow17getTitleBarHeightEv 00000674 T _ZNK4juce14DocumentWindow26getDesktopWindowStyleFlagsEv 00000000 V _ZTIN4juce14DocumentWindow19ButtonListenerProxyE 00000000 V _ZTIN4juce14DocumentWindowE 00000000 V _ZTSN4juce14DocumentWindow19ButtonListenerProxyE 00000000 V _ZTSN4juce14DocumentWindowE 00000000 V _ZTVN4juce14DocumentWindow19ButtonListenerProxyE 00000000 V _ZTVN4juce14DocumentWindowE 00000000 W _ZThn4_N4juce14DocumentWindowD0Ev 00000000 W _ZThn4_N4juce14DocumentWindowD1Ev


#4

does the demo app compile for you if you use the included makefiles?


#5

The demo app and jucer both compile and link. It’s something weird about my app but I’m darned if I can find it.

I’m using Anjuta by the way.

I either get undefined references for Juce objects, or a lot of linker errors for Freetype and X libraries, which is weird:

make all-recursive make[1]: Entering directory `/home/mike/Desktop/Development/Juce/juce22' Making all in src make[2]: Entering directory `/home/mike/Desktop/Development/Juce/juce22/src' /bin/bash ../libtool --tag=CXX --mode=link g++ -I/opt/juce -g -O2 -o juce22 -L/opt/juce/bin -ljuce main.o g++ -I/opt/juce -g -O2 -o juce22 main.o -L/opt/juce/bin -ljuce /opt/juce/bin/libjuce.a(juce_linux_Fonts.o): In function `juce::Typeface::initialiseTypefaceCharacteristics(juce::String const&, bool, bool, bool)': juce_linux_Fonts.cpp:(.text+0x5ba): undefined reference to `FT_Get_First_Char' juce_linux_Fonts.cpp:(.text+0x5e6): undefined reference to `FT_Get_Next_Char' /opt/juce/bin/libjuce.a(juce_linux_Fonts.o): In function `juce::FreeTypeInterface::addGlyph(FT_FaceRec_*, juce::Typeface&, unsigned int)': juce_linux_Fonts.cpp:(.text._ZN4juce17FreeTypeInterface8addGlyphEP11FT_FaceRec_RNS_8TypefaceEj[juce::FreeTypeInterface::addGlyph(FT_FaceRec_*, juce::Typeface&, unsigned int)]+0x1a): undefined reference to `FT_Get_Char_Index' juce_linux_Fonts.cpp:(.text._ZN4juce17FreeTypeInterface8addGlyphEP11FT_FaceRec_RNS_8TypefaceEj[juce::FreeTypeInterface::addGlyph(FT_FaceRec_*, juce::Typeface&, unsigned int)]+0x6e): undefined reference to `FT_Load_Glyph' juce_linux_Fonts.cpp:(.text._ZN4juce17FreeTypeInterface8addGlyphEP11FT_FaceRec_RNS_8TypefaceEj[juce::FreeTypeInterface::addGlyph(FT_FaceRec_*, juce::Typeface&, unsigned int)]+0x218): undefined reference to `FT_Get_First_Char' juce_linux_Fonts.cpp:(.text._ZN4juce17FreeTypeInterface8addGlyphEP11FT_FaceRec_RNS_8TypefaceEj[juce::FreeTypeInterface::addGlyph(FT_FaceRec_*, juce::Typeface&, unsigned int)]+0x22f): undefined reference to `FT_Get_Next_Char' juce_linux_Fonts.cpp:(.text._ZN4juce17FreeTypeInterface8addGlyphEP11FT_FaceRec_RNS_8TypefaceEj[juce::FreeTypeInterface::addGlyph(FT_FaceRec_*,


#6

how are you creating the makefile?

If you aren’t using premake to do the gruntwork, you might be missing libraries that are being used by JUCE but you aren’t necessarily thinking about. OpenGL, FreeType etc.

I can’t recall the libraries that JUCE needs, but if you look at the makefile that is generated for the demo, or better still the lua script for premake, you’ll see a bunch of stuff other than just the JUCE lib being linked.


#7

as valley said, is better that you first look the jucedemo “premake.lua” file, so you can look which kind of library do you need to link with, then after generate your anjuta project based on that…


#8

At the moment the problem is only with the Juce library:

mike@ubuntu:~/Desktop/Development/Juce/juce22$ make make all-recursive make[1]: Entering directory `/home/mike/Desktop/Development/Juce/juce22' Making all in src make[2]: Entering directory `/home/mike/Desktop/Development/Juce/juce22/src' /bin/bash ../libtool --tag=CXX --mode=link g++ -I/opt/juce -g -O2 -o juce22 -L/opt/juce/bin/libjuce.a main.o g++ -I/opt/juce -g -O2 -o juce22 main.o -L/opt/juce/bin/libjuce.a main.o: In function `JUCEHelloWorldApplication': /home/mike/Desktop/Development/Juce/juce22/src/main.cc:101: undefined reference to `juce::JUCEApplication::JUCEApplication()' main.o: In function `main': /home/mike/Desktop/Development/Juce/juce22/src/main.cc:163: undefined reference to `juce::JUCEApplication::main(int, char**, juce::JUCEApplication*)' main.o: In function `JUCEHelloWorldApplication::getApplicationVersion()': /home/mike/Desktop/Development/Juce/juce22/src/main.cc:147: undefined reference to `juce::String::String(wchar_t const*)' main.o: In function `JUCEHelloWorldApplication::getApplicationName()': /home/mike/Desktop/Development/Juce/juce22/src/main.cc:142: undefined reference to `juce::String::String(wchar_t const*)' main.o: In function `~HelloWorldWindow': /home/mike/Desktop/Development/Juce/juce22/src/main.cc:70: undefined reference to `juce::DocumentWindow::~DocumentWindow()' /home/mike/Desktop/Development/Juce/juce22/src/main.cc:70: undefined reference to `juce::DocumentWindow::~DocumentWindow()' main.o: In function `HelloWorldWindow::closeButtonPressed()': /home/mike/Desktop/Development/Juce/juce22/src/main.cc:77: undefined reference to `juce::JUCEApplication::quit(bool)' main.o: In function `HelloWorldWindow': /home/mike/Desktop/Development/Juce/juce22/src/main.cc:57: undefined reference to `juce::String::String(wchar_t const*)' /home/mike/Desktop/Development/Juce/juce22/src/main.cc:57: undefined reference to `juce::Colours::lightgrey' /home/mike/Desktop/Development/Juce/juce22/src/main.cc:57: undefined reference to `juce::DocumentWindow::DocumentWindow(juce::String const&, juce::Colour const&, int, bool)' /home/mike/Desktop/Development/Juce/juce22/src/main.cc:57: undefined reference to `juce::String::~String()'


#9

Could someone else try building a simple Juce application on Linux, preferably Ubuntu? Without Anjuta is fine.

Thanks


#10

People here build JUCE applications in Linux all the time.

My entire day job is spent developing an app that is cross compiled between Linux and Windows[1]. I’ve been doing that for 2 years now. Linux builds, both Mandrake/Mandriva and Ubuntu, have all been working successfully throughout.

[1] I’d do Mac too if I had enough clue to make it all work with the other libraries I use.


#11

Check out NiallTunes (or any of the other Juce apps on that page) - they’re all built with Anjuta. All the libraries you need to link against should get checked for in the configure script (see configure.ac).

I could post a stripped down example project demonstrating how to use autoconf or Anjuta, if that would be useful to anyone?

  • Niall.

#12

[quote=“NiallM”]Check out NiallTunes (or any of the other Juce apps on that page) - they’re all built with Anjuta. All the libraries you need to link against should get checked for in the configure script (see configure.ac).

I could post a stripped down example project demonstrating how to use autoconf or Anjuta, if that would be useful to anyone?

  • Niall.[/quote]

A stripped down Anjuta project would be most appreciated.


#13

Here you are.

  • Niall.

#14