Linking Error E2597 in Delphi std::__ndk1::__next_prime(unsigned int)
Solution to Linking Error E2597 in Delphi
When developing applications in Delphi, you might encounter linking errors. One common error is:
1 |
[DCC Error] E2597: undefined reference to 'std::__ndk1::__next_prime(unsigned int)' |
Introduction
The E2597 error can be caused by various factors, including:
- Incorrect runtime package configurations.
- Missing dependencies or conflicts between libraries.
- Incorrect inclusion of static libraries, such as
libc++
.
Issues with Static Libraries
When you include a static library like libc++
in your Delphi project, you might encounter the E2597 error due to unresolved references. This happens because the libc++
static library might not be properly configured for full static linking.
The Solution
The solution is to avoid including the libc++
library statically and instead pass the -lstdc++
parameter to the linker, ensuring that the libc++
library is included in the deployment so it will be dynamically linked.
Steps to the Solution
1. Modify Linker Options
Open the project options and add the -lstdc++
parameter to the linker options:
1 |
Project > Options > Delphi Compiler > Linking > Link with dynamic RTL: True |
2. Update Deployment
Ensure that the libc++
library is included in the project deployment. You can do this by going to the project options and adding the libc++_shared.so
library:
1 |
Project > Deployment > Add Files > libc++_shared.so |
3. Example Configuration in the .dproj File
You can also directly modify the .dproj
file to ensure the linker parameter is included:
1 2 3 4 5 |
<LinkOptions> <ExtraOptions>-lstdc++</ExtraOptions> </LinkOptions> |
Conclusion
By following these steps, you should be able to resolve the E2597 linking error in Delphi. Remember to also check other possible causes of the error, such as missing dependencies or package conflicts. Proper configuration of linker options and deployment will ensure that your project runs smoothly.
Note: If the problem persists, it may be helpful to recompile the involved static libraries or further check the project dependencies to identify any other causes of the error.