When developing applications in Delphi, you might encounter linking errors. One common error is:
[DCC Error] E2597: undefined reference to 'std::__ndk1::__next_prime(unsigned int)'
The E2597 error can be caused by various factors, including:
libc++
.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 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.
Open the project options and add the -lstdc++
parameter to the linker options:
Project > Options > Delphi Compiler > Linking > Link with dynamic RTL: True
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:
Project > Deployment > Add Files > libc++_shared.so
You can also directly modify the .dproj
file to ensure the linker parameter is included:
<LinkOptions>
<ExtraOptions>-lstdc++</ExtraOptions>
</LinkOptions>
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.