i was working on a project on my windows PC, which included the possibility to show the path of a file and I used the "realpath()" function... I executed it but the terminal returned this error to me...
warning: implicit declaration of function 'realpath'
and also this one undefined reference to `realpath'
with collect2.exe: error ID returned 1 exit status
. Is there something to show the path of a file in C that works? Please help me I can't find the answer.
Asked
Active
Viewed 451 times
1

Face._.
- 21
- 3
-
1According to [this question](https://stackoverflow.com/questions/229012/getting-absolute-path-of-a-file) the Windows function is `GetFullPathName()` – Barmar Jan 31 '22 at 21:16
-
`realpath` is posix. Do you need a portable solution or Windows only ok? – kaylum Jan 31 '22 at 21:16
-
1[`GetFullPathName()`](https://learn.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-getfullpathnamea) – Andrew Henle Jan 31 '22 at 21:16
-
I was doing some tests, I developed this one on my Mac and it was working properly without errors, I opened it on my windows PC to have a .exe file but he couldn't even execute for this error, so yes, I was trying to give this executable to some of my friends but I can't. – Face._. Jan 31 '22 at 21:17
-
I'm developing on C not C++, I saw that ```GetFullPathName``` but I can't use it I think – Face._. Jan 31 '22 at 21:21
-
1Why can you not use it? – Cheatah Jan 31 '22 at 21:27
1 Answers
2
collect2.exe: error ID returned 1 exit status
It means that linker could not find the function realpath
and did not link the program to produce the executable. I happened because Windows libraries do not have this function. You need to use GetFullPathName()
function instead.
I was trying to give this executable to some of my friends but I can't
It is because the .exe file was not created.

0___________
- 60,014
- 4
- 34
- 74