Linker problem with source file


#1

Hi,
I’m still learning how to use Juce, and what I did was to start from the Juce demo.
Let’s say I want to implement a class that process a stream of audio.
Eventually, I want to write a class which inherits the class AudioSource, as e.g. IIRFilterAudioSource.
But for now, I just use a copy of IIRFilterAudioSource, rename all members, include this in my project.
Everything compiles nicely, but does not link: symbols not found.
Hm.
Any idea why this does happen?
Best,
Chris


#2

Simpler method:

In your project, add the source file: juce_amalgamated.cpp
then # inclue <juce_amalgamated.h> in every cpp…

Hope to help you solve the problem.


#3

thanks, SwingCoder
yes, I have these included: JuceHeader.h includes the amalgamated header, and the cpp are “included” via JuceLibraryCode.mm, it’s all there from the Juce demo project.
And everything worked fine - until I include a copy of IIRFilterAudioSource, all members renamed.
I include this, it compiles, but gives the linker error.
If I include any of my classes, it links.
It must be something specific to objective C, maybe? But I have no experience with objective C.
But something like “the symbol names are different if the code comes from the amalgamated sources”?
Unfortunately I don’t know where to look for the symbol names, which the compile generates. I did no coding for quite some time, and my knowledge of XCode is very limited.


#4

To be a bit more clear:
The linker error comes when I do this
m_process = new SpecProcAudioSource(&transportSource , 0);
to make an instance of a class which inherits AudioSource.
If I do the same with e.g. the class IIRFilterAudioSource, it works.
It does not with my class.

“SpecProcAudioSource::SpecProcAudioSource(juce::AudioSource*, bool)”, referenced from:
AudioDemoSpecProcPage::AudioDemoSpecProcPage(juce::AudioDeviceManager&)in AudioDemoSpecProcPage.o
AudioDemoSpecProcPage::AudioDemoSpecProcPage(juce::AudioDeviceManager&)in AudioDemoSpecProcPage.o
ld: symbol(s) not found
collect2: ld returned 1 exit status

Any ideas?


#5

As far as I understand, it won’t link as soon as you use your self-written classes. It seems that you have a constructor SpecProcAudioSource(juce::AudioSource*, bool) declared but not defined since ld can’t find it but you don’t get any compiler errors. Maybe you just have to add another cpp file containing this class to your project.

Chris


#6

thanks,
I have implemented the constructor and it is is included (and visible) in the project.
It’s not defined (as the linker says), but I can’t see why.


#7

maybe the problems is where I make the instance of my class.

I tried it like this
SpecProcAudioSource m_process(AudioSource* , bool);

but when doing
audioSourcePlayer.setSource (m_process);

it fails to compile, with this error
AudioDemoSpecProcPage.cpp:205: error: no matching function for call to ‘juce::AudioSourcePlayer::setSource()’

this does compile but gives the linker error:
ScopedPointer m_process;


#8

I have the feeling that this problem has something to do with having the code in my cpp-file wrapped in

BEGIN_JUCE_NAMESPACE

END_JUCE_NAMESPACE

Does this make sense?
Hm.


#9

Looking at the object files, the objets in myclass.o are named
juce::myclass

In the object file of the class which uses myclass (and is responsible for the linker error), it has symbols
myclass

Does this give a hint to a solution?
Thanks


#10

ok, this was a problem with a namespace.
Cheers