Comprehensive sorting from networks.
In Linux, DLL conversion methods are similar to those in windows, but the names are different. In Linux, a dynamic link is called a standard object, and the generated Dynamic Link file is *. So. For more information, see related documents.
Development Environment: Eclipse 3.4.2
G ++: 4.3.2
1. Create a dynamic link library
(1) create a C ++ project in eclipse
File-> New-> Project-> C ++ project, and select shared library.
(2) createSource codeFile
File-> New-> source file, with the specified name shared. CC
(3) Compile the source code
/** Test. CC ** created on: Oct 10,200 9 * Author: created y*/# Include<Iostream>Using NamespaceSTD;VoidShow () {cout<"Shared library."<Endl ;}
The relocation r_x86_64_32 against 'a local sympost' error occurs during dynamic library compilation.
The following error occurs when compiling a dynamic library:
...
... Relocation r_x86_64_32 against 'a local symbol' can not be used when making a shared object; recompile with-FPIC
... Cocould not read symbols: Bad Value
Solution: the compiler prompts "recompile with-FPIC ".
But who should we re-compile with this parameter? After several times of hard work, I found the following situations:
1. When compiling the. o file, the parameter-FPIC is not added. This problem does not occur in GCC version 3.4.6. Maybe the compiler will add it by default.
2. CurrentProgramA static library is used. The static library does not include-FPIC when compiling the. o file (the static library is actually a. o file package ).
Note: I found that this problem is not solved even if-FPIC is not added when the makefile is handwritten. This problem is very depressing because it only appears when the. A file is compiled using automake.
If you understand the cause, the solution will naturally be available. Make sure that-FPIC is added when you compile the. o file so that you can compile the dynamic library.
For example, note: parameters must be added to the compiler and connector.