Click here to Skip to main content
15,881,248 members
Please Sign up or sign in to vote.
2.50/5 (2 votes)
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
-------------
C++
#include "floatfann.h"
.
.
.
{
    struct fann *ann = fann_create_standard(3,2,4,1);
    
    fann_destroy(ann);
}
Posted
Updated 17-Nov-11 8:11am
v2
Comments
Sergey Alexandrovich Kryukov 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 17-Nov-11 14:18pm    
Odds are, C++ function name mangling issue.
vahidmn 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 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 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/

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.
 
Share this answer
 
Comments
vahidmn 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 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 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 17-Nov-11 16:27pm    
post the floatfann.h file so we can see what the definitons look like
Albert Holguin 17-Nov-11 17:23pm    
I just went to look at that website... don't see anything named what he says. :doh:
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:

C++
#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
 
Share this answer
 
Comments
vahidmn 17-Nov-11 17:01pm    
But it was as yours!
Albert Holguin 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 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 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 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!

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900