happyMar
happyMar

Reputation: 113

Error in linking gmp while compiling cpabe package from its source code

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

Upvotes: 8

Views: 4309

Answers (4)

kammann
kammann

Reputation: 76

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; }

Upvotes: 6

Locksmith
Locksmith

Reputation: 41

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".

Upvotes: 3

happyMar
happyMar

Reputation: 113

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

Upvotes: 3

Employed Russian
Employed Russian

Reputation: 213375

try adding it to the linker command line

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

Upvotes: 0

Related Questions