kevinlekiller / amdctl

Set P-State voltages and clock speeds on recent AMD CPUs on Linux.
GNU General Public License v3.0
241 stars 22 forks source link

Make fails - undefined reference to 'pow' #13

Closed echaskaris closed 2 years ago

echaskaris commented 5 years ago

$ 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

echaskaris commented 5 years ago

Putting -lm at the end of the gcc line fixes it.

kevinlekiller commented 5 years ago

Not seeing the issue on my end, maybe we have different linker versions and it's parsing the options differently?

dmenig commented 4 years ago

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 »```
dmenig commented 4 years ago

This command works though

gcc -Wall -pedantic -Wextra -std=c99 -O2 amdctl.c   -o amdctl -lm
cmpute commented 4 years ago

Confirm the problem, I also need to put -lm at the end

ghost commented 3 years ago

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.

echaskaris commented 3 years ago

gcc -Wall -pedantic -Wextra -std=c99 -O2 amdctl.c -o amdctl -lm Try running this in terminal @ulfw2020

ghost commented 3 years ago

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 topow' collect2: error: ld returned 1 exit status

echaskaris commented 3 years ago

amdctl.zip Here is my binary

ghost commented 3 years ago

Thanks, how do I use this? Forgive me for my incompetence haha.

echaskaris commented 3 years ago

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)

ghost commented 3 years ago

Oh yeah, I forgot about that. Working now. Thanks for your help.

ghost commented 3 years ago

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.

echaskaris commented 3 years ago

:) 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

ghost commented 3 years ago

Mint, thanks.

echaskaris commented 3 years ago

undervoltScript.zip Here is my script. Good luck

ghost commented 3 years ago

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

echaskaris commented 3 years ago

Google how to load module on startup i guess, I think for me it is loaded automatically

ghost commented 3 years ago

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

echaskaris commented 3 years ago

I didn't use init.d, can't help :P

kevinlekiller commented 3 years ago

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

echaskaris commented 3 years ago

@ulfw2020 First you want to find the values for your cpu, to know what values are stable

ghost commented 3 years ago

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.

kevinlekiller commented 3 years ago
#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)

ghost commented 3 years ago

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.

ghost commented 3 years ago

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?

kevinlekiller commented 3 years ago

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.

kevinlekiller commented 3 years ago

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

kevinlekiller commented 2 years ago

Not an issue anymore with 47001bfee5ec4b4ddddee686e4552382567268a9