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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T23:31:41+00:00 2026-06-09T23:31:41+00:00

I have the 5 files as from the examples here – Dec.h, Dec.cpp, decInterface.h,

  • 0

I have the 5 files as from the examples here – Dec.h, Dec.cpp, decInterface.h, decInterface.cpp and temp.c

How to use c++ objects in c?
and
Developing C wrapper API for Object-Oriented C++ code
with the main in a file called temp.c which calls the cpp code implemented in Dec.cpp with help of interface files.

they all reside in one project in vs2008, I have set the compile as option to default instead of compile as c or compile as c++

I get the following link errors

    1>Compiling...
    1>decInterface.cpp
    1>Generating Code...
    1>Compiling...
    1>temp.c
    1>Generating Code...
    1>Compiling manifest to resources...
    1>Microsoft (R) Windows (R) Resource Compiler Version 6.0.5724.0
    1>Copyright (C) Microsoft Corporation.  All rights reserved.
    1>Linking...

        1>decInterface.obj : error LNK2005: "public: __thiscall Node::Node(class std::vector<float,class std::allocator<float> >)" (??0Node@@QAE@V?$vector@MV?$allocator@M@std@@@std@@@Z) already defined in Dec.obj
        1>decInterface.obj : error LNK2005: "public: __thiscall Node::Node(float,float)" (??0Node@@QAE@MM@Z) already defined in Dec.obj
        1>decInterface.obj : error LNK2005: "public: __thiscall Node::Node(class std::vector<float,class std::allocator<float> >,class std::vector<bool,class std::allocator<bool> >)" (??0Node@@QAE@V?$vector@MV?$allocator@M@std@@@std@@V?$vector@_NV?$allocator@_N@std@@@2@@Z) already defined in Dec.obj
        1>decInterface.obj : error LNK2005: "public: __thiscall reprVectorsTree::reprVectorsTree(class std::vector<class Node *,class std::allocator<class Node *> >,int)" (??0reprVectorsTree@@QAE@V?$vector@PAVNode@@V?$allocator@PAVNode@@@std@@@std@@H@Z) already defined in Dec.obj
        1>decInterface.obj : error LNK2005: "public: __thiscall reprVectorsT

ree::reprVectorsTree(float * *,int,int)" (??0reprVectorsTree@@QAE@PAPAMHH@Z) already defined in Dec.obj
    1>decInterface.obj : error LNK2005: "private: class std::vector<bool,class std::allocator<bool> > __thiscall reprVectorsTree::binaryForm(int,int)" (?binaryForm@reprVectorsTree@@AAE?AV?$vector@_NV?$allocator@_N@std@@@std@@HH@Z) already defined in Dec.obj
    1>decInterface.obj : error LNK2005: "public: class std::vector<float,class std::allocator<float> > __thiscall reprVectorsTree::decode(class std::vector<bool,class std::allocator<bool> >)" (?decode@reprVectorsTree@@QAE?AV?$vector@MV?$allocator@M@std@@@std@@V?$vector@_NV?$allocator@_N@std@@@3@@Z) already defined in Dec.obj
    1>decInterface.obj : error LNK2005: "public: float * __thiscall reprVectorsTree::decode(int *,int)" (?decode@reprVe

ctorsTree@@QAEPAMPAHH@Z) already defined in Dec.obj

What kind of visual studio project settings should I use? I feel the problem is here?
Which files to link? how to link? or the default project settings should work?

  • 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-06-09T23:31:42+00:00Added an answer on June 9, 2026 at 11:31 pm

    The error messages are telling you that several functions are defined in both Dec.cpp and decInterface.cpp, or in a header included by both source files. Usually, you are only allowed a single definition of a function in a program; this is (one aspect of) the One Definition Rule.

    If the definitions are in both source files, then remove them from one of them.

    If they are in a header, then you have a choice. You could move the definitions into one (and only one) source file, leaving just the declarations in the header:

    // header
    class Node {
    public:
        Node(std::vector<float>); // declaration
    };
    
    // source
    Node::Node(std::vector<float>) {
        // definition
    }
    

    Or you could define them inline in the header. This relaxes the rule to allow multiple identical definitions:

    // header
    class Node {
    public:
        Node(std::vector<float>); // declaration
    };
    
    inline Node::Node(std::vector<float>) {
        // inline definition
    }
    

    Or you could define them inside the class definition; this also makes them inline:

    // header
    class Node {
    public:
        Node(std::vector<float>) {
            // inline definition
        }
    };
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I currently have a csv file that I'm parsing with an example from here:
We have got an extjs 3.1.1 form with file upload field ( http://www.extjs.com/deploy/dev/examples/form/file-upload.html from
At some point I must have moved files from one location to another using
I have copied some files from project A to project B, both of which
I have downloaded some files from the internet related to a particular topic. Now
I have checked out files from my svn repository to a local project folder.
I have several PHP files include()ing other files from several other directories. In one
I have a directory OUTPUT where I have the output files from a Map
I have a problem such that i have zip files uploaded from forms and
Two questions here. I have a set of files which are usually UTF-8 with

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.