PDA

View Full Version : error string: no such file or directory...




NSDuo
Nov 26, 2008, 11:37 PM
I'm trying to make a simple obj loader to practice with 3D, and I thought I'd use std::string to handle text. However when I tell the compiler to #include <string> it gives me "error string: no such file or directory", weird as it only does it for this one specific project. The first place I looked was Google, and I got one result relevent to my situation and it didn't give a solution to my problem. Here is my code:

#include "global.h"
#include <string> <------------------ the line giving me trouble, wherever I put it in the project


typedef struct vertex
{
float x, y, z;
} vert;

typedef struct face
{
vert points[4];
} face;

typedef struct object
{
int noOfVerts;
int noOfFaces;
face *faces;
} obj;

obj *edlObj(std::string file); <----- this line gives me "syntax error before :"
void render(obj object);



gnasher729
Nov 27, 2008, 04:29 AM
I'm trying to make a simple obj loader to practice with 3D, and I thought I'd use std::string to handle text. However when I tell the compiler to #include <string> it gives me "error string: no such file or directory", weird as it only does it for this one specific project. The first place I looked was Google, and I got one result relevent to my situation and it didn't give a solution to my problem. Here is my code:

#include "global.h"
#include <string> <------------------ the line giving me trouble, wherever I put it in the project


What is the file name of your program?

NSDuo
Nov 27, 2008, 11:19 AM
What is the file name of your program?

I don't exactly understand what you mean by the filename of my program. Do you mean:

my actual program? wormhole demo.app, wormhole demo.xcodeproj
the program its happening in? xcode
the file the error occurs in? edldata.h

if I'm wrong please tell me

ChrisA
Nov 27, 2008, 12:28 PM
This is in C? Then string.h

NSDuo
Nov 27, 2008, 12:45 PM
This is in C? Then string.h

No, std::string is a C++ class and part of the standard code library. I tried including <vector> and <list> and xcode says they are missing too.

gnasher729
Nov 27, 2008, 02:52 PM
I don't exactly understand what you mean by the filename of my program. Do you mean:

my actual program? wormhole demo.app, wormhole demo.xcodeproj
the program its happening in? xcode
the file the error occurs in? edldata.h

if I'm wrong please tell me

If the source file is called main.c, then XCode invokes the C compiler. And the C compiler won't find <string>, and it won't like the C++ syntax. If the source file is called main.cpp, the XCode invokes the C++ compiler which shouldn't give an error. If the source file is called main.m, then XCode invokes the Objective-C compiler; again, that won't like <string>.

Just a hint: You are starting to learn programming, and you are running into a problem. It is very, very unlikely that the problem is with XCode. It is much more likely that something that you are doing is not what you think you are doing. Like your insistence that this is a C++ program: You think it is C++. But what does the compiler think?

Add these lines:

#ifdef __cplusplus
#error Compiling C++
#else
#error Not compiling C++
#endif

and check what error you get.

ctaylo21
Feb 11, 2009, 08:59 AM
I had the same problem, and after I read the earlier comment I checked and sure enough i was using #include <string> in my main.c file. Oops. Switch to main.cpp and it works fine.