Author Topic: error: Text.h: No such file or directory  (Read 51447 times)

Offline prawnhead

  • Single posting newcomer
  • *
  • Posts: 5
error: Text.h: No such file or directory
« on: February 16, 2011, 10:56:47 am »
Apologies if you've seen this complaint a hundred times.
  • I've just installed Code::Blocks
  • I installed it with MingW
  • I'm using it for the first time
  • I created a console app
  • I added a new class called Text (with defaults)
  • I hit "build"
  • It threw a list of errors:
Code
||=== Test99, Debug ===|
D:\Users\prawnhead\Documents\C++\Test99\src\Text.cpp|1|error: Text.h: No such file or directory|
D:\Users\prawnhead\Documents\C++\Test99\src\Text.cpp|3|error: 'Text' has not been declared|
D:\Users\prawnhead\Documents\C++\Test99\src\Text.cpp|3|error: ISO C++ forbids declaration of 'Text' with no type|
D:\Users\prawnhead\Documents\C++\Test99\src\Text.cpp||In function 'int Text()':|
D:\Users\prawnhead\Documents\C++\Test99\src\Text.cpp|6|warning: no return statement in function returning non-void|
D:\Users\prawnhead\Documents\C++\Test99\src\Text.cpp|8|error: expected constructor, destructor, or type conversion before '::' token|
D:\Users\prawnhead\Documents\C++\Test99\src\Text.cpp|13|error: 'String' does not name a type|
||=== Build finished: 5 errors, 1 warnings ===|
Pardon my stupidity, but how does a file that Code::Blocks just created for me not exists? Thanks for any help.

Offline Jenna

  • Administrator
  • Lives here!
  • *****
  • Posts: 7255
Re: error: Text.h: No such file or directory
« Reply #1 on: February 16, 2011, 11:14:40 am »
It surely exists, but if you create the new class, you can decide where the files get created (or whether they should be in the same directory).
The class-wizard does not automatically add the folder the header is in to the include-dirs of the project, so you have to do it yourself.

Offline prawnhead

  • Single posting newcomer
  • *
  • Posts: 5
Re: error: Text.h: No such file or directory
« Reply #2 on: February 16, 2011, 11:24:34 am »
Thanks Jens. Where are the include-dirs? (And why aren't additional files added by default?) Is there a tutorial? Can't find anything for Windows. Thanks.

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: error: Text.h: No such file or directory
« Reply #3 on: February 16, 2011, 11:29:13 am »
Where are the include-dirs?
How should we know? It's your project / your directory layout. :?

(And why aren't additional files added by default?)
Because there are many cases where you don't want that.

Is there a tutorial?
Tutorial on what exactly? How you add include dirs to compiler options? Try the C:B manual here:
http://www.codeblocks.org/docs/main_codeblocks_en.html
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline prawnhead

  • Single posting newcomer
  • *
  • Posts: 5
Re: error: Text.h: No such file or directory
« Reply #4 on: February 16, 2011, 11:43:12 am »
Morten, wow. You sure know how to encourage the noobs. Bye.

Offline stahta01

  • Lives here!
  • ****
  • Posts: 7588
    • My Best Post
Re: error: Text.h: No such file or directory
« Reply #5 on: February 16, 2011, 03:03:33 pm »
Morten, wow. You sure know how to encourage the noobs. Bye.

The Newbies who fail to read and follow the rules; are Newbies we really do NOT need to have as forum posters.

Tim S.
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 64 bit.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline prawnhead

  • Single posting newcomer
  • *
  • Posts: 5
Re: error: Text.h: No such file or directory
« Reply #6 on: February 16, 2011, 08:38:18 pm »
I was a little terse last night. My apologies. I really don't see how I incurred your wrath quite as quickly as I did. As far as I understand, I followed the rules. Please give me an opportunity to explain better.

As per my initial post I downloaded and installed Code::Blocks with MingW. What MingW is I don't know. I ran the C::B app and saw the "Hello World" default code - very helpful. So I ran it. Success! I'm well on my way.

From the File menu I selected New >> Class and was met with a bewildering array of options. All I care about is my class's name, do I need a Virtual Deconstructor? I don't know. I did note that the header file was going to be created under \include and the cpp file under \src. Given that I don't know C::B at all, I accept the defaults given to me. I hit Build. It fails with the list of errors given below.

Having read in Features http://www.codeblocks.org/features that it doesn't use makefiles, I figure the Custom Build System should be taking care of building my new class (I'm wrong). So I locate the C::B forum and search. I'm looking for the phrase "No such file or directory" but the forum search gives me Match All Words and Match Any Words options. The search results are useless. So I go to Google. I search "No such file or directory" code blocks and work through the first few pages of results.

There's something about WxWidgets, some Linux stuff, plenty of new acronyms I don't know: MSVC, STL, etc. etc. So I go searching for the documentation that must exists. The web site does not have a "getting started" area, but it does link to a manual. So I dutifully download and begin reading. Are you aware the manual does not have a table of contents? Are you also aware that the first sentence is "The instructions for chapter 3 on page 53 and ?? on page ?? are official documentations of the CodeBlocks Wiki site and available in english only.". I take this to mean the manual is only a rough draft. But I plow on. After a few pages I'm reading about build targets, workspaces, dependencies and assembler files. So this isn't starting with the easy stuff; on page 5 I'm lost.

So I went back to the forum and, being a member of other forums, I have a bit of a clue what to do. I locate the appropriate section and read the stickies at the top. Yes, it's true I didn't post an "I am new, I am here" post to your Welcome Newcomers thread. I read IMPORTANT! READ THIS BEFORE ASKING FOR HELP! Again, by point 2 you've lost me. How do I know if the error I receive is generated from the compiler or the IDE? I don't know. Is my problem library or framework specific? I know it's specific to C::B 'cause so far I've used only the defaults to start a project and it's failed.

At this point I threw myself on the mercy of the forum! If I had completely the wrong end of the stick, I expected a kind person to say, "hey, you should read the Beginner's Guide, here's a link" or something. Instead Morten replied "How should we know?" That's just stunningly helpful.

I see that you Morten (Martin) are part of the C::B team. You must get a 100 posters a day asking the same inane questions over and over. And as you noted, you're legally required to read all forum posts. So I don't envy you. But if you're frustrated enough to respond unhelpfully, how about you do yourself a favour and update your documentation? Fix the manual. Put a Beginners heading on your web site and fill it with useful tutorials.

My summation of the C::B project from my meagre experience is that there's a high technical barrier to entry and one of the lead people involved trolls the forum. Marten, you should spend some time at http://arduino.cc/forum/ and see how a good forum is run.

PS. All I want to know is the answer to my reply to Jens. Where are the include directories configured in a C::B project?

Offline prawnhead

  • Single posting newcomer
  • *
  • Posts: 5
Re: error: Text.h: No such file or directory
« Reply #7 on: February 16, 2011, 09:09:10 pm »
For anyone actually needing an answer ...

When a new class is added to a Code::Blocks project a message appears:
The new class has been created.
Do you want to add it to the current project?
You answer Yes. But this does not ensure the new class is included when you build the project. The default folders that you probably used \src for .cpp files and \include for .h files are not part of the search path (where the #include directive looks for files) unless you configure it in either the project or the application settings.

To add \include and \src to the search folders list for this project only:
  • Right-click your project under Workspace in the Management pane
  • Select Build Options ...
  • Click the Search Directories tab.
  • Click Add and locate either the \include or \src folder for your project
  • When asked keep this as a relative path?, click Yes
  • Repeat for the other folder
  • Try your build again

You will likely need to alter these settings also for your Release configuration. If you want all your projects to work the same way, update Code::Block's Settings. Check these resources:

Oh yeah, and this information is not in the manual or the FAQ. The application has no on-board help. Searching the forum or Google for this does not quickly yield an answer when you don't know what you're looking for. Oh, and the the forum is patrolled.

Offline stahta01

  • Lives here!
  • ****
  • Posts: 7588
    • My Best Post
Re: error: Text.h: No such file or directory
« Reply #8 on: February 16, 2011, 09:49:02 pm »
Read http://forums.codeblocks.org/index.php/topic,14168.0.html
Read the FAQ http://wiki.codeblocks.org/index.php?title=FAQ
Learn to search the forum and wiki. http://wiki.codeblocks.org/index.php?title=Main_Page
Learn that Code::Blocks IS NOT a Compiler.
Compiler and Library related questions should not be posted on this site unless they are Code::Blocks related.
Edit:
Most of your questions were CB related; but you comment on our attitude was more a comment on your lack on a good effort to search. And, most of the folks get tired of answering the same questions over and over.
If you want, you can add the new info you posted to the CB Wiki.
Note: You need to use an uppercase letter for your user-name to edit the  Wiki Pages.
Not sure if newbies can still edit the wiki pages.

Tim S.
« Last Edit: February 17, 2011, 01:50:12 am by stahta01 »
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 64 bit.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org