Linking Error E2597 in Delphi std::__ndk1::__next_prime(unsigned int)
![](https://synaptica.info/wp-content/uploads/2024/07/DALL·E-2024-07-25-17.11.53-A-vibrant-neon-colored-cover-image-for-a-blog-post-discussing-the-Delphi-linking-error-DCC-Error-E2597_-undefined-reference-to-std____ndk1____next.webp)
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.