Receiving Linker error when trying to compile the main component tutorial file


#1

Hello all,

I was trying to compile the main component tutorial code given online. When I tried to run it on Xcode after adding the NewComponent files in introjucer I recieved multiple errors. So I created a blank project and wrote the exact same code myself in it. I also made sure that I generated the required header and .cpp files in introjucer before writing the code in Xcode. However when I compile this project I get the following linker error- linker command failed with exit code 1. 

Do any of you have a suggestion on how to deal with it? Have anyone of you been in a similar situation before??

Any help is appreciated....

 


#2

Whats the rest of the error? Often thats due to mismatched or missing class names between a header and cpp file.


#3

This is the complete error...

ld: warning: ignoring file /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/System/Library/Frameworks//QuickTime.framework/QuickTime, file was built for i386 which is not the architecture being linked (x86_64): /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/System/Library/Frameworks//QuickTime.framework/QuickTime

duplicate symbol _main in:

    /Users/kannanmenon/Library/Developer/Xcode/DerivedData/MainComponent-gnwtvhxyydszddgkxfcejdkxafdp/Build/Intermediates/MainComponent.build/Debug/MainComponent.build/Objects-normal/x86_64/Main.o

    /Users/kannanmenon/Library/Developer/Xcode/DerivedData/MainComponent-gnwtvhxyydszddgkxfcejdkxafdp/Build/Intermediates/MainComponent.build/Debug/MainComponent.build/Objects-normal/x86_64/juce_audio_basics.o

ld: 1 duplicate symbol for architecture x86_64

clang: error: linker command failed with exit code 1 (use -v to see invocation)

 

I see that I am able to build successfully until I write final line in main.cpp which is a macro. This is the line for the macro..

START_JUCE_APPLICATION (MainWindowTutorialApplication)


#4

Bumping this. I'm getting the same error when trying to compile the Jordan Harris project "VAStateVariableFilter": https://github.com/JordanTHarris/VAStateVariableFilter


#5

...in that one there need to 'static' or 'inline' qualifiers for all of the functions in the DspUtilities.h file.

For example:

double pitchToFreq(double pitch)
{
    return pow(2, (pitch - 69) / 12) * 440;
}

needs to be

inline double pitchToFreq(double pitch)
{
    return pow(2, (pitch - 69) / 12) * 440;
}


or

static double pitchToFreq(double pitch)
{
    return pow(2, (pitch - 69) / 12) * 440;
}

 

 


#6

 

 

 


#7

Perhaps you have two instances of a START_JUCE_APPLICATION (MainWindowTutorialApplication) or START_JUCE_APPLICATION(..something..). They must be in different files otherwise this would be a compiler, rather than linker error.

This would create two main() functions therefore there are duplicate symbols when linked.