LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 09-30-2017, 11:13 AM   #1
BW-userx
Senior Member
 
Registered: Sep 2013
Location: MID-SOUTH USA
Distribution: Void Linux / Slackware 14.2
Posts: 4,737

Rep: Reputation: 876Reputation: 876Reputation: 876Reputation: 876Reputation: 876Reputation: 876Reputation: 876
C++ gnu 5.3.0 (?) no filesystem compiler error


I got this:
Code:
userx@~ <> ls /usr/include/c++/5.3.0/experimental/filesystem
/usr/include/c++/5.3.0/experimental/filesystem
in my compile line,
Code:
 g++ -std=gnu++11 *.cpp 
// and in a different page it shows
 g++ -std=gnu++1z *.cpp 
// to cover up coming 2017 standard
https://gcc.gnu.org/projects/cxx-status.html

both ways are giving me an error,
Code:
#include <filesystem>
//gets
files.cpp:3:22: fatal error: filesystem: No such file or directory
compilation terminated.
http://en.cppreference.com/w/cpp/filesystem

whereas other experimental do not give such error, ie. #include <algorithm>

does anyone know how to deal with that to eliminate this error?
 
Old 09-30-2017, 11:17 AM   #2
BW-userx
Senior Member
 
Registered: Sep 2013
Location: MID-SOUTH USA
Distribution: Void Linux / Slackware 14.2
Posts: 4,737

Original Poster
Rep: Reputation: 876Reputation: 876Reputation: 876Reputation: 876Reputation: 876Reputation: 876Reputation: 876
talk about....
Code:
#include </usr/include/c++/5.3.0/experimental/filesystem>
but that does not explain the why it is doing that for filesystem and not algorithm

because they are both in experimental and included in the same file.cpp even.

Last edited by BW-userx; 09-30-2017 at 11:31 AM.
 
Old 09-30-2017, 11:46 AM   #3
BW-userx
Senior Member
 
Registered: Sep 2013
Location: MID-SOUTH USA
Distribution: Void Linux / Slackware 14.2
Posts: 4,737

Original Poster
Rep: Reputation: 876Reputation: 876Reputation: 876Reputation: 876Reputation: 876Reputation: 876Reputation: 876
it is no longer giving me that error, until I go to use it,
Code:
#include <iostream>
#include <algorithm> 
#include </usr/include/c++/5.3.0/experimental/filesystem>
#include <string>
#include <vector>
/*
#include <dirent.h>
#include <sys/types.h>
*/
#include "files.h"

void print_directory(char *path)
{
  std::string spath;
  spath = path;

  for (auto & p : std::filesystem::directory_entry(spath))
          std::cout << p << std::endl;

}
output
Code:
[Running] cd "/media/data/C-Projects/VSC/C++/mh5000/" && g++ -std=gnu++11 *.cpp
files.cpp: In function ‘void print_directory(char*)’:
files.cpp:20:24: error: ‘std::filesystem’ has not been declared
   for (auto & p : std::filesystem::directory_entry(spath))
even the example is not working if I do it that way.
http://www.cplusplus.com/forum/beginner/215121/
 
Old 10-01-2017, 10:16 AM   #4
a4z
Senior Member
 
Registered: Feb 2009
Posts: 1,417

Rep: Reputation: 608Reputation: 608Reputation: 608Reputation: 608Reputation: 608Reputation: 608
you do not need to specify the full path
#include <experimental/filesystem>
should be enough

and you need to use std::experimental, not only std, for things that you import from experimental

for (auto & p : std::experimental::filesystem::directory_entry(spath))
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Installation (Linux) RISCV GNU Toolchain error: C compiler cannot create executables, recipe for target 'configure-target-libgomp' failed riscv Linux - Newbie 2 03-23-2017 08:36 AM
GNU C compiler feroz Linux - Embedded & Single-board computer 3 06-13-2012 06:52 AM
GNU Make and GNU GCC DEBUG vs RELEASE compiler options aryan1 Programming 1 01-12-2010 12:29 PM
Help with GNU C++ Compiler please... Stiltz Linux - Software 1 03-15-2005 09:17 PM
Where to get compiler gnu c sofasurfer Linux - Games 1 01-11-2004 01:25 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 01:36 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration