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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T04:20:02+00:00 2026-05-24T04:20:02+00:00

There’s obviously something wrong with my build, but I can’t figure it out. I

  • 0

There’s obviously something wrong with my build, but I can’t figure it out. I narrowed this down to one of my projects: first build after clean fails, all following builds succeed.

I get linking errors which say that some symbols are already defined:

>------ Build started: Project: Problem, Configuration: Debug Win32 ------
> Blah blah blah...
23>     Creating library D:\SVN.DRA.WorkingCopy\Debug\Problem.lib and object D:\SVN.DRA.WorkingCopy\Debug\Problem.exp
23>ProblemDependency1.lib(PD1.obj) : error LNK2005: "public: unsigned short __thiscall PD2Class::getFoo(void)const " (?getFoo@PD2Class@@QBEGXZ) already defined in ProblemDependecy2.lib(ProblemDependency2.dll)
23>ProblemDependency1.lib(PD1.obj) : error LNK2005: "public: void __thiscall PD2Class2::`default constructor closure'(void)" (??_FPD2Class2@Image@DRA@@QAEXXZ) already defined in ProblemDependency2.lib(ProblemDependency2.dll)
23>D:\SVN.DRA.WorkingCopy\Debug\Problem.dll : fatal error LNK1169: one or more multiply defined symbols found
  • Problem is a C++/CLI project, built with the /clr switch, which references the unmanaged C++ projects ProblemDependency1, a static lib, and ProblemDependency2, a dll.
  • ProblemDependency1 references ProblemDependency2.
  • getFoo() is declared as inline and defined outside of the class declaration, in the .h
  • PD2Class2 doesn’t have an explicitly defined default constructor, but it has a constructor which has all default arguments, so you could say it includes the default constructor as a special case
  • The .h’s where these are defined have #pragma once as their first line.

Any hint on troubleshooting this? I can post more info if needed

Update: I solved the first error thanks to Anders Abel’s suggestion, but I still can’t solve the second one (the one about the default constructor)

Update: If I compile using MSBuild outside Visual Studio, it fails always, with the same error

Edit: Here’s some code. First, a bit of PD2Class2’s declaration. PD2Class2’s real name is CImage (feeling lazy to anonymize), CImage.h:

#pragma once
#pragma warning( disable: 4251 )    //TODO: Disable and solve

#include "ImageProperties.h"
#include "../CommonCppLibrary/CriticalSection.h"
#include <windows.h>
#include <stdexcept>
#include <string>

class CSharedMemory;
class EmptyImageException;
struct IShape;

struct SImageStatics {
    unsigned short low3Percentile;
    unsigned short high97Percentile;
    unsigned short medianPixelValue;
    unsigned short meanPixelValue;
    unsigned short minPixelValue;
    unsigned short maxPixelValue;
};

namespace DRA{
namespace Image{
class __declspec(dllexport) CImage {
    friend class CImageLock;

//Attributes
    int m_iPitch;
protected:
    mutable CImageProperties                    m_cProperties;
    CSharedMemory *                             m_pSharedMemmory;
    mutable DRA::CommonCpp::CCriticalSection    m_csData;
    static const float                          PIXEL_FREQUENCY_COVERAGE;
    static const float                          PIXEL_CUTOFF_PERCENTAGE;
    static const int                            MINIMUM_PIXEL_FREQUENCY;    //Pixels with a frequency lower than this are ignored
    static const int                            MINIMUM_WINDOW_WIDTH_FOR_16_BITS;

//Methods
    //Some private methods

public:

    CImage( DWORD dwWidth = 0, DWORD dwHeight = 0, ULONG uBytesPerPixel = 0,
            bool isSigned = false, EPhotometricInterpretation ePI = PI_UNKNOWN,
            UINT bitsStored = 0, float pw = -1.0f, float ph = -1.0f, BYTE * pData = NULL );
    CImage( const CImageProperties& cProperties, int iPitch = 0 );
    CImage( const CImage& rImage );
    virtual ~CImage();
    virtual CImage& operator=( const CImage& );
    bool operator==( const CImage& rImage );

//Alter State
    //More methods
//Query State
    //More methods
};
}
}

Next, the constructor’s definition, from CImage.cpp:

CImage::CImage( DWORD dwWidth, DWORD dwHeight, ULONG uBytesPerPixel, bool isSigned,
                EPhotometricInterpretation ePI, UINT bitsStored, float pw, float ph,
                BYTE * pData ) :
        m_iPitch( dwWidth * uBytesPerPixel ),
        m_cProperties( dwWidth, dwHeight, uBytesPerPixel, bitsStored, ePI, isSigned, pw, ph ),
        m_pSharedMemmory( NULL ),
        m_csData(){
    m_pSharedMemmory = new CSharedMemory( pData ? pData : new BYTE[getSize()] );
}
  • 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-24T04:20:03+00:00Added an answer on May 24, 2026 at 4:20 am

    Is getFoo() marked as __declspec(dllexport)? If it is an inline function, it is instantiated/used from wherever it is called through the included header. It shouldn’t be part of the functions that the dll exports and it should not have a dllexport directive.

    __declspec(dllexport) might be handled through a macro that is expanded to dllexport or dllimport depending on if it is the dll or code using the dll that is compiled. If there is any macro in the function declaration you might have to dig into it to find if there is an export directive.

    Update

    I think that if the header file is used both when the dll is built and when the dll is used, it is incorrect to have __declspec(dllexport) in the header file. Instead use a macro system:

    #ifdef PROBLEMDEPENDENCY2
    #define DLLEXPORT __declspec(dllexport)
    #else
    #define DLLEXPORT __declspec(dllimport)
    #endif
    
    class DLLEXPORT CImage
    {
        //...
    }
    

    Then define the PROBLEMDEPENDENCY2 preprocessor symbol when building the dll, but not when using it. The problem with hardcoding __declspec(dllexport) in the header file is that the compiler will try to export the class both from ProblemDependency2 (which is correct) and from ProblemDependency1 (which is incorrect).

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

Sidebar

Related Questions

There are nice SO question and answers about this issue, but these options didn't
There have been multiple questions regarding this topic but I have never really settled
I know there's a lot of other questions out there that deal with this
There are plenty of questions and answers to this like this question but I
There is something strange happening. Param interceptor is the one in charge to take
There's a lot of reading on self referencing problems, but I can't seem to
There is a column that exists in 2 tables. In table 1, this column
There's a Rails 3.2.3 web application which doesn't use any database. But in spite
There are two table s : one is the master and one the detail
There's a few previous questions on StackOverflow questioning how one goes about accessing local

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.