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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T18:58:18+00:00 2026-05-29T18:58:18+00:00

I am using dev c++. also i am getting assistant from a library, developed

  • 0

I am using dev c++. also i am getting assistant from a library, developed by somebody else for my own c++ projects. i have added two new classes called TriangleList and TriangleLists to the library as i wanted new class types for the project. once, i added the hpp and cpp files to the library, i got the massage like creating ../lib/libExtraction.a .
however, when i called back the functions, that i written in the new classes, from my own project, i got the error massages like

`[Linker error] undefined reference to `TriangleLists::Erase()`

(the above one for the Erase function)
then, when i removed the .cpp file and wrote everything in .hpp it works.

But, i would like to maintain two files for the hpp and cpp further. so, please tell me how to solve this link error problem as i want to learn this. thank you in advance.

  • 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-29T18:58:25+00:00Added an answer on May 29, 2026 at 6:58 pm

    First thing you need to check is if you’re exporting the class:

    class __declspec(dllexport) TriangleLists
    {
    //members
    };
    

    When you include the header in a different project however, you need to specify that the class is imported, so:

    class __declspec(dllimport) TriangleLists
    {
    };
    

    This is usually achieved with preprocessor directives:

    #ifdef BUILDING_FIRST_PROJECT
    #define DLLIMPEXP _declspec(dllexport)
    #else
    #define DLLIMPEXP _declspec(dllimport)
    #endif
    
    //TriangleLists.h
    class DLLIMPEXP TriangleLists
    {
    }
    

    and only define BUILDING_FIRST_PROJECT in your first project. That way, when building the first project, you’ll be exporting the class, and when you include the header in another project, you’re importing it.

    Second thing is that the other project must link to the .lib file generated by the first project.

    The reason it works when you move the implementation to the header is that the method becomes inline, so there’s no lookup for it in the lib files, as it’s definition is already known.

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

Sidebar

Related Questions

I code C++ using MS Dev Studio and I work from home two days
So i have this local SVN repo that i am using for my dev
Have been getting pretty bald over this situation! I am using MS VS 2010
Have followed every step correctly from this link http://msdn.microsoft.com/en-us/library/ms746621.aspx When trying to localize the
I created a program using dev-cpp and wxwidgets which solves a puzzle. The user
I'm using Dev C++ to write a simple C program and I need to
I wrote a program in C++/OpenGL (using Dev-C++ compiler) for my calculus 2 class.
I'm trying to rebuild someone's old C++ project using Dev-C++ (version 4.9.9.2) and the
I am currently using whoosh to dev a website, and I'll need to choose
Why didn't languages such as C end up being using for web dev? Surely

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.