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 6589909
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T17:14:02+00:00 2026-05-25T17:14:02+00:00

There was a week I’m learning and reading how to use my own static

  • 0

There was a week I’m learning and reading how to use my own static library in C++ and it’s driving me crazy. I’m using Ubuntu and I have a class in /home/myFiles/lib I want to build my library:

//MyClass.h
//---------------------------------------------
#ifndef MYCLASS_H_
#define MYCLASS_H_

class MyClass {
public:
    int a;

    MyClass();
    virtual ~MyClass();
};

#endif

And

//MyClass.cpp
//------------------------------------------
#include "MyClass.h"

MyClass::MyClass() {
    a = 3;
}

MyClass::~MyClass() {
}
//------------------------------------------

And a test file in /home/myFiles/main where I want to use the library:

// test.cpp
//-------------------------------------------------
#include <iostream>
using namespace std;

#include "MyClass.h"

int main() {
    MyClass c = MyClass;

    cout << "Hello World!!!" << c.a << endl;
    return 0;
}
//----------------------------------------------

Using Ubuntu console I type:

In lib folder: g++ -c MyClass.cpp
ar rsc libTesting.a MyClass.o

In test folder: g++ -c test.cpp -lTesting -L/home/myFiles/lib

Then It returns: test.cpp: error: MyClass.h: No such file or directory

If I write:
g++ -o test.cpp -lTesting -L/home/myFiles/lib

It deletes my file test.cpp

I know there is a lot of information about this but I don’t understand why it don’t recognize the #include "MyClass.h" and how can I use this using only the library without include the path with -I/home/myFiles/lib.

Thank you.

  • 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-25T17:14:03+00:00Added an answer on May 25, 2026 at 5:14 pm

    you havn’t indicate the include path, so gnu report the error.

    try to add -I for your include path, or copy the .h file to your source directory.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been searching since a week for that is there any library like
I just started using SVN as of last week (TortoiseSVN), is there any SVN
Lat week I downloaded the Glazed List library into eclipse. I have been looking
I have discovered Scintilla/Notepad++ API this week end. As there is a nice Template
Is there any way to show only week day with Date as: MON 03-JUL
week DKK id=radio2 value=75 /> I have bunch of these div entry generated by
There are a few ways to get class-like behavior in javascript, the most common
There are numerous Agile software development methods. Which ones have you used in practice
There are several types of objects in a system, and each has it's own
A friend and I had an argument last week. He stated there were no

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.