Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7309077
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T23:39:55+00:00 2026-05-28T23:39:55+00:00

I ‘ve been struggling for more than 3 hours but cannot find a solution.

  • 0

I ‘ve been struggling for more than 3 hours but cannot find a solution.
A simple helloworld program is running nicely and I can get the output,

 #include<iostream>
    #include<string>

    using namespace std;
    int main(){
       string s;
       cout<<"hello world";
    }

But for the My Sudoku Project I have the following user defined header
files, SudokuSolver.h, Matrix.h, Cell.h, Pos.h, Error.h, Exception.h and
their corresponding .cpp files.

And ExampleProgram.cpp uses these header files, to solve a Sudoku.

(All the .h and .cpp files are in a same folder.)

I have included using namespace std; and I included the string as #include <string>.
in each header file, wherever I used string.h. But even though I am getting the fatal error: string: No such file or directory compilation terminated. when I run as

g++ ExampleProgram.cpp SudokuSolver.h Cell.h Error.h Pos.h Matrix.h

When I compile the ExampleProgram.cpp as

 g++ -c ExampleProgram.cpp SudokuSolver.h
 Cell.h Error.h Pos.h Matrix.h       

I am getting no error.

When I run the ExampleProgram.cpp using ./a.out I am not getting the output for my sudoku solver. Rather I am getting the output of my previously runned helloworld program. It shows my ExampleProgram.cpp has not successfully compiled. But as previously said

g++ -c ExampleProgram.cpp  SudokuSolver.h 
    Cell.h Error.h Pos.h Matrix.h       

doesn’t give any error.

This is my output:

[fosslab@fosslab SudokuSolver]$ g++ -c Error.h
[fosslab@fosslab SudokuSolver]$ g++ -c Exception.h
[fosslab@fosslab SudokuSolver]$ g++ -c Matrix.h
[fosslab@fosslab SudokuSolver]$ g++ -c Cell.h
[fosslab@fosslab SudokuSolver]$ g++ -c Pos.h
[fosslab@fosslab SudokuSolver]$ g++ -c SudokuSolver.h
[fosslab@fosslab SudokuSolver]$ g++ -c ExampleProgram.cpp SudokuSolver.h Excepti
on.h Cell.h Error.h Pos.h Matrix.h                                             
[fosslab@fosslab SudokuSolver]$ ./a.out
hello world[fosslab@fosslab SudokuSolver]$ 
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T23:39:56+00:00Added an answer on May 28, 2026 at 11:39 pm

    First of all, header files a meant to be included in the source files. Do not add them to the command line for the compiler.

    Secondly, the command line argument “-c” to g++ tells g++ to not link and make an executable file, but only make an object file.

    You should either do:

    $ g++ -c ExampleProgram.cpp
    $ g++ ExampleProgram.o
    

    or

    $ g++ ExampleProgram.cpp
    

    In both the above cases you will get a new “a.out” executable program.

    If you have several source files, then compile them and not the header files:

    $ g++ -c Error.cpp
    $ g++ -c Exception.cpp
    $ # etc...
    $ g++ -c ExampleProgram.cpp
    $ g++ Error.o Exception.o ... ExampleProgram.o
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have just tried to save a simple *.rtf file with some websites and
I am currently running into a problem where an element is coming back from
I need to clean up various Word 'smart' characters in user input, including but
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I would like to count the length of a string with PHP. The string
I've got a string that has curly quotes in it. I'd like to replace
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I am trying to create a RegEx expression that will successfully parse the following
I'm creating a web service to transfer json to an iPhone app. I'm using
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.