Question:
G++ (gcc GNU compiler forc++) in-line options error?
2010-10-25 11:47:40 UTC
i'm trying to compile a .cpp file using g++ (on mac command line) and it tells me it cannot file the files which i have included using

# include notation.

How can i add them in the command line so that it compiles?

thanks.

it tells me : cannot include file.h: no such file or directory.


I tried to use the I- command, but no luck. I think it only works for "file.h", but not for .

ANy more ideas?
Three answers:
Ilie
2010-10-25 21:18:10 UTC
Hi,



Apple's port of GCC is sort of funky and you're not the only one I've heard having problems with it. If you don't fix it, I suggest building GCC from source. Don't worry, it's an easy process.



First of all, make sure that file.h is there and that both spellings are correct! You've probably done that already but I mentioned that anyway. Many times, people just make silly mistakes. It happens to everyone.



You were pretty vague about #include "file.h" - does it work or do you just think it works? Have you tried it? Unfortunately, the use of #include "file.h" is usually discouraged because different compilers vendors implement it in different manners; it's not standardized.



Try using the -include file.h argument and see where that leads you. Also, try shoving file.h in the same directories as all your other standard header files.



IMPORTANT NOTE: The previous answer is wrong in that inverted commas are not supposed to work differently on non-standard include files, as per the ISO C++ standard.



Cheers,

Bogdan
2016-11-06 15:08:48 UTC
definite, Gcc does have conio. Gcc does variety in some respects in incorporate headers from older texts on C++ programming and is principally what you would be able to desire to look out for counting on implication. That being mentioned mutually as conio is present, you would be able to could desire to examine if the functionality you calling has been deminished in want for yet another functionality.
Chris C
2010-10-25 21:09:18 UTC
It's probably not "file.h", but perhaps "stdio.h".

And usually the # is immediately before "include", like tihs:

#include



Now, if the file isn't a standard C/C++ file, use double quotes.

#include "file.h"


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...