Link Error


#1

Hi, i’m currently trying to compile a program on MacOS. I’ve initially written this program on Windows and it perfectly works. To compile it on Mac I’m using XCode 2.3.

After a moment i succeed in the compilation step but I still have an error at Linking that I don’t understand.
Here is this error:

/usr/bin/ld: Undefined symbols:
juce::ResizableWindow::addAndMakeVisible(juce::Component*, int)
/Users/davidgros/Desktop/baptiste/PartitionTestJuceMac/PartitionTestJuce/build/PartitionTestJuce.build/Release/Test.build/Objects-normal/ppc/MainWindow.o reference to undefined juce::ResizableWindow::addAndMakeVisible(juce::Component*, int)
collect2: ld returned 1 exit status
/usr/bin/ld: Undefined symbols:
juce::ResizableWindow::addAndMakeVisible(juce::Component*, int)
/Users/davidgros/Desktop/baptiste/PartitionTestJuceMac/PartitionTestJuce/build/PartitionTestJuce.build/Release/Test.build/Objects-normal/ppc/MainWindow.o reference to undefined juce::ResizableWindow::addAndMakeVisible(juce::Component*, int)
collect2: ld returned 1 exit status

So this error comes because I’m calling the addAndMakeVisible() function in a ResizableWindow object, but why the linking step failed ? (I precise that i’ve compiled and then run successfully The Juce Demo application on Mac).

Do you know how can I solve this problem ?

Thanks.

Bouba

PS: Sorry if it’s difficult to understand me, I’m french :wink:


#2

Have a careful read of the comments for ResizableWindow::addAndMakeVisible! You shouldn’t actually be calling it, and should have had an assertion failure on windows when you tried to run it.

It only gets compiled in debug mode, so I suppose you’re trying to link a debug build of your app to a release build of the library.


#3

Ok, I had’nt seen this function before. In fact I was obligated to make a call to this function because I have a slider in the title bar of the Window. So I’ve read the comment of the addAndMakeVisible() function of the ResizableWindow class. To solve the problem I’ve simply done that

MainWindow : public DocumentWindow {

public:
void addAndMakeVisible (Component* const child, int zOrder) {
((Component*)this)->addAndMakeVisible(child, zOrder);
}

};

Thanks a lot for your help, it works now.

Bouba


#4

There’s no need to add your own method - just add “Component::” in front of your addAndMakeVisible call, to explicitly call the superclass’s function.


#5

OK, thanks.


#6