You are not logged in.
Hello,
I get following error while building from Powertop2 from AUR. Their are a few explanation/solution that I have no idea what to do about it. I have requested help but have not received so far. So, I am posting it here. Please help.
My Error
==> Starting build()...
patching file Makefile
patching file measurement/measurement.cpp
patching file measurement/sysfs.cpp
patching file measurement/sysfs.h
patching file Makefile
patch unexpectedly ends in middle of line
Hunk #1 succeeded at 38 with fuzz 2.
gcc -o csstoh csstoh.c
./csstoh powertop.css css.h
CC lib.cpp
CC main.cpp
main.cpp: In function ‘void do_sleep(int)’:
main.cpp:96:16: error: ‘sleep’ was not declared in this scope
main.cpp:104:14: error: ‘usleep’ was not declared in this scope
main.cpp: In function ‘void load_board_params()’:
main.cpp:207:23: error: ‘R_OK’ was not declared in this scope
main.cpp:207:27: error: ‘access’ was not declared in this scope
main.cpp: In function ‘int main(int, char**)’:
main.cpp:227:15: error: ‘getuid’ was not declared in this scope
main.cpp:234:57: warning: ignoring return value of ‘int system(const char*)’, declared with attribute warn_unused_result [-Wunused-result]
main.cpp:235:47: warning: ignoring return value of ‘int system(const char*)’, declared with attribute warn_unused_result [-Wunused-result]
main.cpp:236:76: warning: ignoring return value of ‘int system(const char*)’, declared with attribute warn_unused_result [-Wunused-result]
make: *** [main.o] Error 1
==> ERROR: A failure occurred in build().
Aborting...
@thestinger
The errors occur because gcc 4.7 removed a lot of unnecessary includes from the standard library headers.
You need to #include <unistd.h> in all the files that fail to compile.
With the addinclude utility, you can just do:
$ addinclude failing_file.cpp unistd
Thanks @thestinger. I had to add the following lines to PKGBUILD:
addinclude main.cpp unistd
addinclude -t html.cpp unistd
addinclude devices/device.cpp unistd
addinclude cpu/intel_cpus.cpp unistd
addinclude devices/alsa.cpp unistd
addinclude devices/rfkill.cpp unistd
addinclude devices/i915-gpu.cpp unistd
addinclude devices/thinkpad-fan.cpp unistd
addinclude devices/network.cpp unistd
addinclude devices/thinkpad-light.cpp unistd
ATTENTION: For some reason I had to use -t parameter for the file html.cpp, otherwise the include statement was somewhere in the file...
Thanks.
Last edited by donniezazen (2012-04-16 20:32:21)
Offline
Hi there
You build powertop using yaourt? If yes, you need answer "yes" when yaourt offer you to edit PKGBUILD. Then add lines between "patch" and "make". The part of PKGBUILD should look like this:
patch -p1 < ../powertop-1.98-sysfs.patch
patch -p1 < ../Makefile.patch
addinclude main.cpp unistd
addinclude -t html.cpp unistd
addinclude devices/device.cpp unistd
addinclude cpu/intel_cpus.cpp unistd
addinclude devices/alsa.cpp unistd
addinclude devices/rfkill.cpp unistd
addinclude devices/i915-gpu.cpp unistd
addinclude devices/thinkpad-fan.cpp unistd
addinclude devices/network.cpp unistd
addinclude devices/thinkpad-light.cpp unistd
make
Sorry for my bad English
Offline
Thanks @Copycat
Andrwe at AUR has already helped me with the issue without addinclude.
Hi,
add the following code above of 'make' within the build()-function:
for file in main.cpp html.cpp devices/{device.cpp,alsa.cpp,rfkill.cpp,i915-gpu.cpp,thinkpad-fan.cpp,network.cpp,thinkpad-light.cpp} cpu/intel_cpus.cpp
do
sed -i 's/\(#include .*\)/#include <unistd.h>\n\1/' "${file}"
done
That's a dirty hack which does in general the same as addinclude but you don't have to install addinclude.
Regards,
Andrwe
Offline