Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: MFC VC++ Intelligence
I have made libfann and attached it to my project
and also I've wrote these code, but due the compilation it gives these 3 linker errors! Why?
 

 
Error 8 error LNK2019: unresolved external symbol __imp__fann_destroy@4 referenced in function "public: void __thiscall CTTSPDlg::OnBnClickedButton2(void)" (?OnBnClickedButton2@CTTSPDlg@@QAEXXZ) TTS-PDlg.obj
-------
Error 9 error LNK2019: unresolved external symbol __imp__fann_create_standard referenced in function "public: void __thiscall CTTSPDlg::OnBnClickedButton2(void)" (?OnBnClickedButton2@CTTSPDlg@@QAEXXZ) TTS-PDlg.obj
-------------
Error 10 fatal error LNK1120: 2 unresolved externals D:\TTS\Programming\Delete1\Debug\TTS-P.exe
-------------
#include "floatfann.h"
.
.
.
{
    struct fann *ann = fann_create_standard(3,2,4,1);
    
    fann_destroy(ann);
}
Posted 17-Nov-11 8:54am
vahidmn359
Edited 17-Nov-11 9:11am
v2
Comments
SAKryukov at 17-Nov-11 14:00pm
   
This is linker errors. Without looking at your project file, who knows how you tried to include libfann in your project? It's done via project build options.
--SA
Albert Holguin at 17-Nov-11 14:18pm
   
Odds are, C++ function name mangling issue.
vahidmn at 17-Nov-11 14:30pm
   
Thanks, but i don't know about mangling problem! please for avoiding it, explain extern "C" method more(in my code)!
vahidmn at 17-Nov-11 14:17pm
   
yes, I've added it via project properties -> Linker -> Input -> Additional Dependencies.
And I've made the library file via debugging the Source Files which I'd downloaded from internet before!
Chuck O'Toole at 18-Nov-11 11:12am
   
The site you reference also has a complete and active Forum section where people who are expert in this thing lurk. You'll probably get better answers there. http://leenissen.dk/fann/forum/
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Your linker errors are telling you that the linker can't find anything that matches the function signatures.
 
This can be caused if:
0. Forgot to include your .lib file for the linker
1. The function signatures don't match (search for C++ function decorations/mangling for information), if you want to keep it simple, avoid the mangling by wrapping your dll functions with the extern "C" method.
  Permalink  
Comments
vahidmn at 17-Nov-11 14:29pm
   
Thanks, but i don't know about mangling problem! please for avoiding it, explain extern "C" method more(in my code)!
Albert Holguin at 17-Nov-11 14:54pm
   
First off, did you write this library or is it someone else' library that you're trying to tie into your code.
vahidmn at 17-Nov-11 15:50pm
   
No i didn't write it!
I just debug the FANN Solution (http://leenissen.dk/fann/wp/) which is for implementing neural network and then copy the libfann.lib to my project and then link it.
Chuck O'Toole at 17-Nov-11 16:27pm
   
post the floatfann.h file so we can see what the definitons look like
Albert Holguin at 17-Nov-11 17:23pm
   
I just went to look at that website... don't see anything named what he says. :doh:
Albert Holguin at 17-Nov-11 17:20pm
   
I just went to the website here[^] and I don't see where there's even a function fann_create_standard() or fann_destroy(), I only see create_standard() and destroy(). Are you sure those aren't the ones you want?
vahidmn at 18-Nov-11 10:34am
   
I use fann2.1. and the address which you have seen is related to fan2.2. and i don't know where can i download it?!
Albert Holguin at 18-Nov-11 10:53am
   
You really think they would change the function names in .x release difference?
vahidmn at 18-Nov-11 11:02am
   
yes! unfortunately function names in version 2.2.0 is different than version 2.1.0!
Albert Holguin at 18-Nov-11 16:17pm
   
I find that hard to believe... in any case... why don't you use the newest one then?
Albert Holguin at 18-Nov-11 16:19pm
   
These sound like issues you should take up in the library forums that Chuck pointed out to you. This is really just a problem specific to how you're using that library.
vahidmn at 18-Nov-11 10:12am
   
I don't know how I can post it! please download it from this URL: http://leenissen.dk/fann/wp/download/
after downloading "FANN Library Version 2.1.0" you can see the header files in src folder!
Chuck O'Toole at 18-Nov-11 11:11am
   
The site you reference also has a complete and active Forum section where people who are expert in this thing lurk. You'll probably get better answers there. http://leenissen.dk/fann/forum/
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

It seems that you have the "C++ Decorated Name" problem.
 
If the library was written in C and your app is in C++, then you need to tell the compiler to generate C style calls (and names) to the library functions.
 
You need to wrap the function declarations in the .h file like this:
 
#ifdef _MSC_VER                         /* MicroSoft C++ compiles, declare externals as "C" calling standard */
#ifdef __cplusplus
extern "C" {
#endif
#endif
 
// place the declarations / function prototypes for fann_create_standard and fann_destroy here

#ifdef _MSC_VER
#ifdef __cplusplus
}
#endif
#endif
  Permalink  
Comments
vahidmn at 17-Nov-11 17:01pm
   
But it was as yours!
Albert Holguin at 17-Nov-11 17:13pm
   
What do you mean it was "as yours"? ...you mean the functions in the header are already wrapped in the extern "C" code? If so, is there a #define that is required to pull in the functions correctly, looking at the error, there's some sort of decoration in front of the function name.
Chuck O'Toole at 17-Nov-11 19:38pm
   
I asked you to post the floatfann.h file. Have you done so? We're just guessing at what the .h file looks like so don't be surprised if we guess wrong until you post it.
Chuck O'Toole at 17-Nov-11 19:47pm
   
PS, I went to the web site, there are hundreds of entries in that library. I'm not going to spend a lot of my time (actually, not any of my time) digging through all that. You are either calling functions that do not exist in that library at all as Albert suggests or there is some other issue that we cannot yet see. Provide the additional details as requested.
vahidmn at 18-Nov-11 10:24am
   
I don't know how I can post it! please download it from this URL: http://leenissen.dk/fann/wp/download/
after downloading "FANN Library Version 2.1.0" you can see the header files in src folder!
Chuck O'Toole at 18-Nov-11 11:11am
   
The site you reference also has a complete and active Forum section where people who are expert in this thing lurk. You'll probably get better answers there. http://leenissen.dk/fann/forum/

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 277
1 Maciej Los 210
2 BillWoodruff 205
3 Jochen Arndt 180
4 DamithSL 165
0 OriginalGriff 5,130
1 DamithSL 4,157
2 Maciej Los 3,670
3 Kornfeld Eliyahu Peter 3,470
4 Sergey Alexandrovich Kryukov 2,821


Advertise | Privacy | Mobile
Web04 | 2.8.141216.1 | Last Updated 17 Nov 2011
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100