Closed echaskaris closed 2 years ago
Putting -lm at the end of the gcc line fixes it.
Not seeing the issue on my end, maybe we have different linker versions and it's parsing the options differently?
Same for me CPU 1900X Ubuntu 18.04 LTS gcc version 7.4.0 (Ubuntu 7.4.0-1ubuntu1~18.04.1)
The mentionned fix isn't working for me :/
$ gcc -Wall -pedantic -Wextra -std=c99 -O2 -lm amdctl.c -o amdctl
/tmp/cc7tiYiQ.o : Dans la fonction « northBridge » :
amdctl.c:(.text+0x10f1) : référence indéfinie vers « pow »```
This command works though
gcc -Wall -pedantic -Wextra -std=c99 -O2 amdctl.c -o amdctl -lm
Confirm the problem, I also need to put -lm at the end
I'm also having this issue now, I've never had it before. I'm on Pop_OS!, with the latest versions of make, gcc etc. and linux kernel 5.8 if that's relevant. I previously used it without issue on Solus and Manjaro. I've checked the file CMakeLists.txt and the line that @hyperfraise put is there, without the word gcc. What's wrong? Any help is much appreciated.
gcc -Wall -pedantic -Wextra -std=c99 -O2 amdctl.c -o amdctl -lm Try running this in terminal @ulfw2020
gcc -Wall -pedantic -Wextra -std=c99 -O2 amdctl.c -o amdctl -lm Try running this in terminal @ulfw2020
Thanks for your response, I tried it, here's what it returned: gcc -Wall -pedantic -Wextra -std=c99 -O2 amdctl.c -o amdctl -Im
/usr/bin/ld: /tmp/ccNRcSw4.o: in function northBridge': amdctl.c:(.text+0x1196): undefined reference to
pow'
collect2: error: ld returned 1 exit status
amdctl.zip Here is my binary
Thanks, how do I use this? Forgive me for my incompetence haha.
Np, run it as you would run an executable: ./amdctl This shows a help page You will want to run it as this to get information about clock speeds and voltages: sudo ./amdctl -g (probably you will need to make the file executable, I think chmod +x amdctl will work or Right click on your script and choose Properties -> Permissions -> Allow executing file as program)
Oh yeah, I forgot about that. Working now. Thanks for your help.
Shoot, while you're here. How do I make the changes permanent? I can set them using the commands, but when I restart they reset.
:) In Ubuntu I had to play with services I believe, In other distros it is something else, google how to execute a script at startup
Mint, thanks.
undervoltScript.zip Here is my script. Good luck
Thanks, gave yours a try, but it keeps saying the msr module isn't loaded. I've tried adding sudo modprobe msr to the script, but it gives me the same error. Any ideas? Also, is the best method of running the script on boot just moving it to /etc/init.d? Thanks. @echaskaris
Google how to load module on startup i guess, I think for me it is loaded automatically
Managed to sort that issue by adding msr to /etc/modules, but now the script doesn't want to load on boot. It works fine when I run it manually using ./undervoltScript. I moved it to /etc/init.d. How do you get yours to load on boot? Thanks for the help. @echaskaris
I didn't use init.d, can't help :P
Most distros use systemd these days, if yours does, you can create a systemd unit file to run the script.
https://wiki.debian.org/systemd/Services
https://wiki.archlinux.org/index.php/systemd#Writing_unit_files
@ulfw2020 First you want to find the values for your cpu, to know what values are stable
Thanks, that part's all sorted. Managed to undervolt from a max of 12.81W to 6.25W with no effects that I noticed. Just trying to figure out the bootable part, looking at systemd like @kevinlekiller suggested.
#cat /etc/systemd/system/cpuvoltage.service
[Unit]
Description=Sets the voltage of the CPU.
[Service]
ExecStart=/usr/local/sbin/cpuvoltage.sh
Type=oneshot
Restart=no
RemainAfterExit=yes
[Install]
WantedBy=multi-user.target
Start it with sudo systemctl --now enable cpuvoltage.service
Make sure /usr/local/sbin/cpuvoltage.sh
is executable (chmod +x /usr/local/sbin/cpuvoltage.sh
)
Thanks Kevin, so I assume I create a file in /etc/systemd/system called cpuvoltage.service? Then I paste those contents in and change the path of ExecStart to where my script is located? (/home/ulfwennstroem/undervoltScript) thanks.
I did the above, and ended up in a new situation. It doesn't work on boot, but if I run that systemctl command to enable it, it works fine. Any ideas?
That's right, alternatively, if you put it in ~/.config/systemd/user/
and run systemctl --user
with the rest of the commands, then the script will run when you log in with your user account.
I did the above, and ended up in a new situation. It doesn't work on boot, but if I run that systemctl command to enable it, it works fine. Any ideas?
It's probably a timing issue, you can either try like I mentioned above, a user unit or maybe put a sleep in the script to delay the execution.
You can also check the output: systemctl status -l cpuvoltage.service
Not an issue anymore with 47001bfee5ec4b4ddddee686e4552382567268a9
$ make gcc -Wall -pedantic -Wextra -std=c99 -O2 -lm amdctl.c -o amdctl /usr/bin/ld: /tmp/ccAmmJxI.o: in function `northBridge': amdctl.c:(.text+0x10ce): undefined reference to `pow' collect2: error: ld returned 1 exit status make: *** [: amdctl] Error 1
Ubuntu 19.04 gcc 4:8.3.0-1ubuntu3