Compile Errors != Linker Errors, BTW why do I get Linker errors?

Daniel Duffy

C++ author, trainer
Thank you APalley @APalley, I made a silly mistake to forget to write destructor lol..
After adding destructor, I still got one link error:

1>Shape.obj : error LNK2005: "public: class YC::CAD::Shape & __thiscall YC::CAD::Shape::operator=(class YC::CAD::Shape const &)" (??4Shape@CAD@YC@@QAEAAV012@ABV012@@Z) already defined in Point.obj
1>C:\Users\Danielle\Documents\Visual Studio 2010\Projects\Level 5\3.4-Exercise2\Debug\3.4-Exercise2.exe : fatal error LNK1169: one or more multiply defined symbols found
Below is my code for operator = in shape and point:

Code:
Shape& Shape::operator=(const Shape& source)
{//Assignment operator.
    cout<<"Shape assignment operator is called."<<endl;
    if (this == &source)
        return *this;
    this->m_id = source.m_id; 
    return *this;
}
Code:
Point& Point::operator = (const Point& source)         
{//Print out text in assignment operator.
 
    cout<<"Point assignment operator called."<<endl;
    if (this==&source) 
        return *this;
    Shape::operator=(source); 
    this->m_x = source.m_x;
    this->m_y = source.m_y;
    return *this;
}
Thanks!
one or more multiply defined symbols found
 

Danielle Chen

Member
C++ Student
Thank you very much Daniel!
I found the problem finally, it was a very silly mistake as well...:(
 

Daniel Duffy

C++ author, trainer
Code:
#include <iostream>

// Daniel J. Duffy

struct IntComparator
{
    bool operator()(const double& a, const double& b) const
    {
        return a < b;
    }
};

// C++11 VS2013 Community version free downloadable

int main()
{
    double a = 20.00; double b = 20.0001;

    IntComparator ic;
    std::cout << ic(a, b) << std::endl;

    // Lambda function
    auto Compare = [](const double& a, const double& b) -> bool { return a < b; };
    auto CompareII = [](const double& a, const double& b) -> bool { return a > std::exp(b); };

    std::cout << Compare(a, b) << std::endl;
    std::cout << CompareII(a, b) << std::endl;

    return 0;

}
 

Daniel Duffy

C++ author, trainer
QUIOTE-->

I also had the same problem and then I realised that I should have changed my "ExcelImports.cpp" to adapt it to MS 2013.

I rewrote my ExcelImports.cpp file in the following way:
// Office 2013 (Office v15)
#import "C:\Program Files\Microsoft Office 15\root\vfs\ProgramFilesCommonX86\Microsoft Shared\OFFICE15\MSO.DLL" rename("DocumentProperties", "DocumentPropertiesXL") rename("RGB", "RGBXL")
#import "C:\Program Files\Microsoft Office 15\root\vfs\ProgramFilesCommonX86\Microsoft Shared\VBA\VBA6\VBE6EXT.OLB"
#import "C:\Program Files (x86)\Microsoft Office\Office15\EXCEL.EXE" rename("DialogBox", "DialogBoxXL") rename("RGB", "RGBXL") rename("DocumentProperties", "DocumentPropertiesXL") rename("ReplaceText", "ReplaceTextXL") rename("CopyFile", "CopyFileXL") no_dual_interfaces

I am using Window 7 Ultimate (64 bit operating system).
 

Daniel Duffy

C++ author, trainer
The 13 Golden Rules of Debugging
1. Understand the requirements
2. Make it fail
3. Simplify the test case
4. Read the right error message
5. Check the plug
6. Separate facts from interpretation
7. Divide and conquer
8. Match the tool to the bug
9. One change at a time
10. Keep an audit trail
11. Get a fresh view
12. If you didn’t fix it, it ain’t fixed
13. Cover your bugfix with a regression test
14.Sometimes a good rule is: remove/comment out stuff until the code starts working; then uncomment slowly, slowly.
 

ExSan

Active Member
Directory setting Boost 1.59 for VS2015 Community
I can not reproduce image 2/2

LINKER/ADDITIONAL LIBRARY DIRECTORIES

I can only set to this:
C:\BOOST\boost_1_59_0;%AdditionalLibraryDirectories)

but not to lib-32- msvc
should I include this manually ?

.........
I can compile the directive
#include <boost/format.hpp>

when I try this directive
//#include <boost/chrono.hpp>
or
//#include <boost/chrono/chrono.hpp>

I get error compilation... something is not working? what am I missing ?
thanks in advance DD ! ;)
 

Daniel Duffy

C++ author, trainer
See the directory structure

The install has to be done properly

but not to lib-32- msvc should I include this manually ?
You need this directory as part of the automagic install. If not, try again until you get it right.

14.0 !!!!!!!!!!!!!!
 

Attachments

ExSan

Active Member
See the directory structure

The install has to be done properly

but not to lib-32- msvc should I include this manually ?
You need this directory as part of the automagic install. If not, try again until you get it right.

14.0 !!!!!!!!!!!!!!
it seems to work now. thanks !!!
 

Daniel Duffy

C++ author, trainer
See the directory structure

The install has to be done properly

but not to lib-32- msvc should I include this manually ?
You need this directory as part of the automagic install. If not, try again until you get it right.

14.0 !!!!!!!!!!!!!!
bump
 

ExSan

Active Member
QUIOTE-->

I also had the same problem and then I realised that I should have changed my "ExcelImports.cpp" to adapt it to MS 2013.

I rewrote my ExcelImports.cpp file in the following way:
// Office 2013 (Office v15)
#import "C:\Program Files\Microsoft Office 15\root\vfs\ProgramFilesCommonX86\Microsoft Shared\OFFICE15\MSO.DLL" rename("DocumentProperties", "DocumentPropertiesXL") rename("RGB", "RGBXL")
#import "C:\Program Files\Microsoft Office 15\root\vfs\ProgramFilesCommonX86\Microsoft Shared\VBA\VBA6\VBE6EXT.OLB"
#import "C:\Program Files (x86)\Microsoft Office\Office15\EXCEL.EXE" rename("DialogBox", "DialogBoxXL") rename("RGB", "RGBXL") rename("DocumentProperties", "DocumentPropertiesXL") rename("ReplaceText", "ReplaceTextXL") rename("CopyFile", "CopyFileXL") no_dual_interfaces

I am using Window 7 Ultimate (64 bit operating system).
Dear DD,
I am having difficulties to compile and execute your program ExcelHelloWorld, could you please update the import directives

This is my environment
Windows10 + MS Visual Studio Community 2015
 
Last edited:

Daniel Duffy

C++ author, trainer
Dear DD,
I am having difficulties to compile and execute your program ExcelHelloWorld, could you please update the import directives

This is my environment
Windows10 + MS Visual Studio Community 2015
Which version of Excel are you using? Where are these files on your system?
 
Last edited:

ExSan

Active Member
C:\Program Files (x86)\Common Files\Microsoft Shared\OFFICE14\MSO.DLL

C:\Program Files (x86)\Common Files\Microsoft\VBE6EXT.OLB Shared\VBA\VBA6\VBE6EXT.OLB

C:\Program Files\Microsoft Office\Office14\EXCEL.exe

Microsoft® Office/Excel 2010 (Version 14 - 64 bits)

THANKS IN ADVANCE ;)
R
 

Daniel Duffy

C++ author, trainer
C:\Program Files (x86)\Common Files\Microsoft Shared\OFFICE14\MSO.DLL

C:\Program Files (x86)\Common Files\Microsoft\VBE6EXT.OLB Shared\VBA\VBA6\VBE6EXT.OLB

C:\Program Files\Microsoft Office\Office14\EXCEL.exe

Microsoft® Office/Excel 2010 (Version 14 - 64 bits)

Are these similar to the issues you are having with VS2015 and Boost ... 32 v 64?

THANKS IN ADVANCE ;)
R
I think you are mixing 32/64! (?)
Programs Files vs Program files (x86)

In the initial stages I advise sticking to 32 bit libs and projects etc. to avoid getting bogged down in OS issues.

@APalley
 
Last edited:
Top