Search code examples
ubuntucompilationlinkergmp

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

Solution

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