0

I don't know what I am doing wrong!

I have defined the header files: Project->Build Options->Search directories->Compiler->Added the path that my header file is located in...

I am using codeblocks.

I don't know what is wrong!

#include <iostream>
#include "Sales_item.h"

using namespace std;

int main()
{
    Sales_item book; // Reads ISBN, number of copies sold and sales price
    cin >> book; // Write ISBN, number of copies sold, total revenue, and avg. price
    cout << book << endl;
    return 0;
}
bytecode77
  • 14,163
  • 30
  • 110
  • 141
Seeist
  • 21
  • 1
  • 5
  • 3
    Copy in your question full invocation of the compiler from the tab «Build output». It is something like `g++ main.cpp …`, *(below you will also see build errors)*. – Hi-Angel Jun 20 '15 at 21:02

3 Answers3

0

A simple visit to the Code::Blocks wiki would have solved your problem.

The process:

- Right click on the project then select Build options - Select the directories tab - Add the required paths for compiler and linker. - Add your specific libraries in the linker tab. - Pay attention to project settings and target settings.

Dimitris Sfounis
  • 2,400
  • 4
  • 31
  • 46
  • Not sure what I'm doing wrong. I've followed the steps and it is still giving me that error. Am I placing the file in the right folder? I am sure I am because I have the header in the folder. – Seeist Jun 20 '15 at 21:14
  • Thanks, this is solved. I use CodeLite now instead of CodeBlocks. – Seeist Jul 01 '15 at 04:10
0

Try < Sales_item.h> instead "Sales_item.h". Not sure about CodeBlocks, but using "" usually means that the path is located in the same directory while <> means that path is described in the project settings.

  • Not quite right, and the "" syntax should fallback on the <> syntaxe on failure. See http://stackoverflow.com/a/77092/1614219 – dureuill Jun 22 '15 at 10:37
  • I meant usual general situation - not sure how CodeBlocks rework it – Tezkatlipoka Jun 23 '15 at 16:52
  • This is defined in the C++ standard so codeblocks should not interfere. See the answer I linked. – dureuill Jun 23 '15 at 17:18
  • LOL. I was not going to teach anybody - I've proposed the possible way to resolve the problem. – Tezkatlipoka Jun 25 '15 at 07:09
  • Which is wrong, since the "" syntax fallbacks on the <> syntax on failure, as my link demonstrates. There is zero chance of a header being found by manually replacing "" with <>. Actually your compiler may find *less* headers with the <> syntax than with the "" syntax. I just wanted to point it out. – dureuill Jun 25 '15 at 07:31
0

If your issue is because of <iostream>, Goto Settings -> Compiler... -> Global compiler settings -> Linker settings then add path of directory folder into folder

If your issue is because of "Sales_item.h", ensure that Sales_item.h was placed in the same directory with this (main.cpp I guess)

DMaster
  • 603
  • 1
  • 10
  • 23