views:

46

answers:

2

Hi all. I have a strange error that has bothered me all day. I have a library function that I have compiled. I statically link the library to test it in a separate console application and everything builds and works ok. It is just a simple sqrt function called sqrtval at the moment. However, when I include this library in a larger graphical project then I get linker errors. I have set the Additional library directories and Additional dependency settings identically in both the console app (that works) and the graphical main app (that does not work). The error is as follows.

1

Microsoft (R) Windows (R) Resource Compiler Version 6.1.6723.1 1>Copyright (C) Microsoft Corporation. All rights reserved. 1>Linking... 1>MainAppWindow.obj : error LNK2019: unresolved external symbol "double __cdecl sqrtval(double)" (?sqrtval@@YANN@Z) referenced in function "public: virtual void __thiscall MainComponent::sliderValueChanged(class juce::Slider *)" (?sliderValueChanged@MainComponent@@UAEXPAVSlider@juce@@@Z) 1>....\bin\Debug\tutorial.exe : fatal error LNK1120: 1 unresolved externals

+1  A: 

What does the linker command line look like? Is your library listed on the linker command for the GUI application?

ceretullis
I'd never noticed the linker command line before you left this comment. Thanks.
learnvst
+1  A: 

If your library is written in plain C, you have to declare sqrtval as:

extern "C" double sqrtval(double);
Frédéric Hamidi
Thankyou, thankyou so much!
learnvst
I love this website and all you wonderful coders.
learnvst