8

I ended up spending several hours for compiling cpabe package from its source code in Ubuntu 12.10, with gmp and pbc dependencies. The following error message seemed to be the problem of many people in the Web(even for compiling other packages that required installation of libgmp as a dependency!). Yet, I couldn't find any workable solution there:

...
/usr/bin/ld: /usr/local/lib/libpbc.so: undefined reference to symbol '__gmpz_init'
/usr/bin/ld: note: '__gmpz_init' is defined in DSO /usr/lib/gcc/x86_64-linux-gnu/4.6/../../../x86_64-linux-gnu/libgmp.so so try adding it to the linker command line
/usr/lib/gcc/x86_64-linux-gnu/4.6/../../../x86_64-linux-gnu/libgmp.so: could not read symbols: Invalid operation
collect2: ld returned 1 exit status
Simon Wright
  • 25,108
  • 2
  • 35
  • 62
happyMar
  • 113
  • 1
  • 6

4 Answers4

6

It might be trivial for some of you, but policy_lang.y is missing a semicolon in line 67, hence the compilation fails with:

 policy_lang.y: In function ‘yyparse’:
 policy_lang.y:67:38: error: expected ‘;’ before ‘}’ token
 result: policy { final_policy = $1 }

It can be fixed by changing line 67 to

 result: policy { final_policy = $1; }
kammann
  • 76
  • 1
  • 1
3

Adding lgmp was necessary, but all other used libraries needed to be linked as well. I finally solved the problem by specifying those libraries in the LDFLAGS environment variable while issuing the make command. So, after installation of gmp, pbc, bswabe or any other required dependencies, the compilation steps was as follows:

  • ./configure -with-pbc-include=path -with-pbc-lib=path (the paths where pbc.h and libpbc were installed )

  • make LDFLAGS="-lgmp -lpbc -lcrypto -L/usr/lib/x86_64-linux-gnu -lglib -lbswabe -lgmp"

  • make install

happyMar
  • 113
  • 1
  • 6
  • I tried doing this, I ran into error gcc -o cpabe-setup setup.o common.o -lgmp -lpbc -lcrypto -L/usr/lib/x86_64-linux-gnu -lglib -lbswabe -lgmp /usr/bin/ld: cannot find -lglib collect2: error: ld returned 1 exit status make: *** [cpabe-setup] Error 1 How do I resolve this? – user3388925 Oct 09 '16 at 14:53
3

Mine was a slight variation of MarAlavi's, for linux Mint 16:

  • ./configure -with-pbc-include=path -with-pbc-lib=path (the paths where pbc.h and libpbc were installed )
  • make LDFLAGS="-lgmp -lpbc -lcrypto -L/usr/lib/x86_64-linux-gnu -lglib-2.0 -lbswabe -lgmp"
  • make install

Notice the "-lglib-2.0".

SamB
  • 9,039
  • 5
  • 49
  • 56
Locksmith
  • 41
  • 2
0

try adding it to the linker command line

Did you try adding -lgmp to the link command line as the error suggests?

Employed Russian
  • 199,314
  • 34
  • 295
  • 362