0

I have written my program by using pbc library in dev c++.While compiling the program I got the error that "undefined reference to element_printf(char const*,....)".How to solve this error?

sinu
  • 1
  • 1

1 Answers1

0

element_printf is a function of the pbc library, so did you add the library to the required libraries in your project? (Project->Options->Parameters->Linker)

lostbard
  • 5,065
  • 1
  • 15
  • 17
  • Thank you for your answer but I can't understand what you exactly meant .so I have now sent my written code – sinu Jun 21 '17 at 05:48
  • this is the part of my code # include "pbc.h" pairing_t pairing; element_t public_key,secret_key,s.g; element_init_G1(g,pairing); element_init_G1(s,pairing); element_init_G1(public_key,pairing); element_init_Zr(secret_key,pairing); element_random(g); element_printf("%B ",g); element_random(secret_key); element_printf("Private key=%B\n",secret_key); element_pow_zn(public_key,g,secret_key); element_printf("public key=%B \n",public_key); – sinu Jun 21 '17 at 05:58
  • I have got error in all these element_printf sentence that undefined reference to "element_printf(char const*,...)" – sinu Jun 21 '17 at 06:00
  • lostbard, can you please answer my currently asked question again? I will be highly helpful to you. – sinu Jun 22 '17 at 12:57
  • The undefined reference is either from the compiler saying it doesn't know what that function is, OR the linker, saying it cant find the function (or library) with that function in it. If the library isn't being linked in, then thats the linker problem – lostbard Jun 22 '17 at 16:01
  • how to solve this problem? If there is linker problem or compiler problem then there should be also error message when I call element_mul or element_pow_zn or element_pairing functions in my code.But there are no such error only there is error about the undefined reference to element_printf function-so how to solve this? Looking forward your quick reply. – sinu Jun 23 '17 at 10:28
  • I have an one more question about gmp library.There is no explicit declaration of mpz_t or mpz_q data types in the gmp.h header file then how can we use this header file while using mpz_t or mpz_q datatype in our program while using pbc library? Looking forward for your quick reply. – sinu Jun 23 '17 at 14:34
  • Look at pbc.h - it include gmp.h – lostbard Jun 23 '17 at 17:54
  • pbc_field.h header file also include gmp.h header file but when I compile pbc_field.h header file it is shown that mpz_t is not declared in this scope.How to solve this error? – sinu Jun 24 '17 at 11:10
  • you mean include not compile? You do also include the pbc.h file ? – lostbard Jun 24 '17 at 11:17
  • Yes I have included gmp.h and pbc.h both header file in the pbc_field.h header file but still when I compile pbc_field.h header file it has been shown that mpz_t is not declared in this scope. – sinu Jun 25 '17 at 04:22
  • And also I can't resolve the element_printf part.Here I have sent my code and when it is complied it has been shown that undefined reference to the element_printf function.You have mentioned about the linker or compiler problem but if it is so then it should also give error message when compiling the other functions.So how to solve this error-below is my code – sinu Jun 25 '17 at 05:19
  • #include "pbc.h" #include "pbc_test.h" #include int main(int argc, char **argv) { pairing_t pairing; element_t s,g public_key,secret_key; pbc_demo_pairing_init(pairing, argc, argv); element_init_G1(g,pairing); element_init_G1(s,pairing); element_init_G1(public_key,pairing); element_init_Zr(secret_key,pairing); element_random(g); element_printf( "%B", g); element_random(secret_key); element_printf("Private key=%B\n",secret_key); element_pow_zn(public_key,g,secret_key); element_printf("public key=%B \n",public_key); – sinu Jun 25 '17 at 05:30
  • Looking forward for a quick reply – sinu Jun 25 '17 at 13:45
  • Please someone give answer.It's truly urgent for me. – sinu Jun 26 '17 at 10:25
  • I have written simple code by using pbc library in dev c++ and compile against the compiler TDM_Gcc 4.9.2 64 -bit Release.I have used simple printf function in my program but when I run the program it does not show any output only shows a blank output. How to solve this error?Looking forward for quick answer.It's very urgent for me. – sinu Jun 26 '17 at 13:47