Ingo
Ingo

Reputation: 89

Linux gcc compile problems

I am new to Linux and I tried to compile a library. CMAKE works great to configure but when compile with make I get errors like this:

error: ‘____stat64’ was not declared in this scope ____stat64 statbuf; error: ‘____stat64’ was not declared in this scope ____stat64 statbuf; error: ‘getcwd’ was not declared in this scope if (NULL != getcwd(chFile, _MAX_PATH))

Maybe I have a problem with missing header files? My gcc version is Thread model: posix gcc version 5.4.0 20160609 (Ubuntu 5.4.0-6ubuntu1~16.04.11)

Thanks, Ingo

Upvotes: 0

Views: 897

Answers (2)

ranu
ranu

Reputation: 652

Verify that you have the linux headers installed on your machine. To make sure they are installed, on Debian based distros, run:

sudo apt-get install linux-headers-generic

Also verify that you are including unistd header as Michael Surette already showed. For clarity you would include the header mentioned as the code below:

#include <unistd.h>

int main() {
    ...
}

Upvotes: 0

Michael Surette
Michael Surette

Reputation: 711

If you type man 3p getcwd in a terminal, you will find that you need

#include <unistd.h>

to call getcwd.

The modern C++ cross-platform way to do this is to use the filesystem header and the current_path() function.

Upvotes: 1

Related Questions