mersenneforum.org

mersenneforum.org (https://www.mersenneforum.org/index.php)
-   GMP-ECM (https://www.mersenneforum.org/forumdisplay.php?f=55)
-   -   Can't bind libecm.a with C++ files (https://www.mersenneforum.org/showthread.php?t=5631)

poire 2006-03-20 15:41

Can't bind libecm.a with C++ files
 
When I try to bind libecm.a with a C++ file, I get
[CODE] undefined reference to `ecm_factor(__mpz_struct*, __mpz_struct*, double, __ecm_param_struct*)'[/CODE]

I know that gcc finds the right libecm.a file because there's a different error message when I delete or rename it.

The library works fine when I use it in C files.

I'm using:
gmp-ecm 6.0.1
gmp 4.1.4
gcc 3.3.4 on x86 Linux

Any help is greatly appreciated.

Thanks,
poire

cjohnsto 2006-03-21 11:57

C++ mangles names but C does not. I believe this is the reason for the problem.
To solve it change:
#include <ECM.h>
to
extern "C" {
#include <ECM.h>
}

I hope that helps. Basically this tells the linker to look for the unmangled version of these functions i.e. the C version.

Please tell us how you go with this fix. This is from memory so I hope it contains no mistakes.

poire 2006-03-21 14:41

This solves the problem.

Thanks a lot.


All times are UTC. The time now is 11:17.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2022, Jelsoft Enterprises Ltd.