In recent years, open-source software and hardware have become increasingly popular in China. Go to open source China and check out that there is already a dedicated hardware open source zone. The 61ic code factory provides a lot of hardware (ARM, DSP, etc.)-related code. Under this trend, writing a software or algorithm from the beginning is already a matter of the last century. We will learn more or less from the open source code, even good algorithms or middleware can be used directly. Of course, you need to pay for the project, but there are a lot of websites that provide open source free code, the most famous one is sourceforge, github. I often download other people's code from github. Although the code in github is mixed, the long tail theory tells us that apart from the top-ranking excellent source code like Linux, the lower Repositories of star also have a lot of good code for us to learn and even directly use in the project, but we need to discover it.
Oh, it's a long journey. Go back to the question ...... Because we now have too many available code, we don't need to write it from scratch, but most of the work we need to do is porting (more professional is refactoring ), here, we will continue to record the problems encountered in the Self-transplantation Project (mainly the C/C ++ project) and the solution process, "three feet of digging is not a day's success ", this is an accumulation process.
1. A large number of link errors #10056: symbol "_ fann_set_scaling_params" redefined
[Situation]
When I linked a neural network's C language library fann, there were a lot of redefined errors similar to the above. The cause of the error was obvious: "_ fann_set_scaling_params repeated definitions", and I searched it in the project, the producer is indeed only defined in one place.
[Explanation]
_ Fann_set_scaling_params is compiled. the identifiers in the obj file (symbol, which generally start with an underscore). The above errors occur when the link is displayed, which indicates multiple. the _ fann_set_scaling_params definition is displayed in the obj file. We know that the C compiler is compiled according to the. c file (that is, a. c file generates a. obj, and the c compiler does not actively compile the header file ). The fann library is different. One of the floatfann. c files contains the following lines of code:
[Cpp]
# Include "fann. c"
# Include "fann_io.c"
# Include "fann_train.c"
# Include "fann_train_data.c"
# Include "fann_error.c"
# Include "fann_cascade.c"
# Include "fann. c"
# Include "fann_io.c"
# Include "fann_train.c"
# Include "fann_train_data.c"
# Include "fann_error.c"
# Include "fann_cascade.c" You are not mistaken. The c language can also contain the. c file. The. c file contained will also be compiled into a. obj file as a shared file. This is clear, I will include a few of the above. the c file is added to the project, and these files are included here. c file, the same. the c file is compiled twice, and the definition will be repeated.
[Solution]
The first method is to use. the c file is removed from the project. The second method is to remove the # include "**. c "comment out and add the corresponding source file to the project.
Note: This is the first problem. I remember that I have encountered many similar problems before, and I have been confused for a long time to solve them, even after the program compilation is passed, I am confused and don't know how to run it. I really regret that I didn't make a record early. This problem occurs when we port fann to the DSP this time. Remember.
2. fatal error #5: cocould not open source file "fann. h"
[Explanation]
Compared with the above compilation error, this is a link error, which means fann. h. The header file cannot be opened, or the header file does not exist at all (check whether the file name is wrong), or the header file path is not set correctly (the compiler does not find the header file ).
[Solution]
If this header file exists, the solution in eclipse C/C ++ is to right-click the project and choose Properities> Build> Compiler> Include Options, add the directory where the header file is located in the-I option. In this regard, if you have used the gcc compiler in Linux, you will find the file search path. The library search path is particularly sensitive. Therefore, it is strongly recommended that you learn how to use gcc for software (especially C/C ++ software), which is very useful for building projects.