This question already has answers here:
C++17: Defining static constexpr member functons in .cpp file
(1 answer)
Is it possible to declare constexpr class in a header and define it in a separate .cpp file?
(2 answers)
Undefined symbols for constexpr function
(3 answers)
Closed 5 months ago.
Function is declared in hpp file like this:
class StringProcessor
{
static constexpr const char* string_process(const char* initial_string, std::size_t string_length, const char* key, std::size_t key_length);
};
And defined in cpp like this:
constexpr const char* StringProcessor:: string_process(const char* initial_string, std::size_t string_length, const char* key, std::size_t key_length)
{
...
}
How do I call it, because following line throws Undefined symbols for architecture x86_64: "StringProcessor::string_process(char const*, unsigned long, char const*, unsigned long)", referenced from: _main in main.cpp.o error:
std::cout << StringProcessor::string_process("Test", 4, "Test", 4) << std::endl;
constexpr functions are implicitly inline and therefore need to be defined in every translation unit where they are used. That usually means that the definition should go into a header shared between the translation units using the function.
Also, in order for constexpr to be of any use, the function needs to be defined before its potential use in a constant expression. Therefore it usually only really makes sense to define it directly on the first declaration, i.e. here in the class definition in the header.
I have not mine C++ project, which I can successfully compile using this line:
g++ -o minit minit.c MinitGlobal.h Item.c ItemsetQueue.c Transaction.c Error.h Dataset.c SubDataset.c RankItems.c MinitAlgo.c but if I add optimization level like below (same for -O3):
[ec2-user#ip-10-209-16-177 minit++]$ g++ -o -O0 minit minit.c MinitGlobal.h Item.c ItemsetQueue.c Transaction.c Error.h Dataset.c SubDataset.c RankItems.c MinitAlgo.c
minit: In function `_start':
(.text+0x2a8): multiple definition of `_start'
/usr/lib/gcc/x86_64-amazon-linux/4.6.3/../../../../lib64/crt1.o:(.text+0x0): first defined here
minit: In function `_fini':
(.fini+0x0): multiple definition of `_fini'
/usr/lib/gcc/x86_64-amazon-linux/4.6.3/../../../../lib64/crti.o:(.fini+0x0): first defined here
minit:(.rodata+0x0): multiple definition of `_IO_stdin_used'
/usr/lib/gcc/x86_64-amazon-linux/4.6.3/../../../../lib64/crt1.o:(.rodata.cst4+0x0): first defined here
minit: In function `__data_start':
(.data+0x0): multiple definition of `__data_start'
/usr/lib/gcc/x86_64-amazon-linux/4.6.3/../../../../lib64/crt1.o:(.data+0x0): first defined here
minit:(.rodata+0x8): multiple definition of `__dso_handle'
/usr/lib/gcc/x86_64-amazon-linux/4.6.3/crtbegin.o:(.rodata+0x0): first defined here
minit: In function `_init':
(.init+0x0): multiple definition of `_init'
/usr/lib/gcc/x86_64-amazon-linux/4.6.3/../../../../lib64/crti.o:(.init+0x0): first defined here
/tmp/cc0cvoT6.o: In function `main':
minit.c:(.text+0x4d2): multiple definition of `main'
minit:(.text+0x0): first defined here
/tmp/ccRfRvQv.o:(.bss+0x0): multiple definition of `minit::Itemset::count'
minit:(.bss+0x638): first defined here
/tmp/ccQhesuV.o: In function `minit::ItemsetQueue::ItemsetQueue()':
ItemsetQueue.c:(.text+0x0): multiple definition of `minit::ItemsetQueue::ItemsetQueue()'
minit:(.text+0x390): first defined here
/tmp/ccQhesuV.o: In function `minit::ItemsetQueue::enqueue(unsigned int const&, unsigned int)':
ItemsetQueue.c:(.text+0x7e): multiple definition of `minit::ItemsetQueue::enqueue(unsigned int const&, unsigned int)'
minit:(.text+0x430): first defined here
/tmp/ccQhesuV.o: In function `minit::ItemsetQueue::enqueue(minit::Itemset const&, unsigned int const&, unsigned int)':
ItemsetQueue.c:(.text+0xfe): multiple definition of `minit::ItemsetQueue::enqueue(minit::Itemset const&, unsigned int const&, unsigned int)'
minit:(.text+0x520): first defined here
/tmp/ccQhesuV.o: In function `minit::ItemsetQueue::dequeue()':
ItemsetQueue.c:(.text+0x186): multiple definition of `minit::ItemsetQueue::dequeue()'
minit:(.text+0x3b0): first defined here
/tmp/ccQhesuV.o: In function `minit::ItemsetQueue::print(std::basic_ostream<char, std::char_traits<char> >&) const':
ItemsetQueue.c:(.text+0x1f2): multiple definition of `minit::ItemsetQueue::print(std::basic_ostream<char, std::char_traits<char> >&) const'
minit:(.text+0x6d0): first defined here
/tmp/ccQhesuV.o: In function `minit::ItemsetQueue::printItemsets(std::basic_ostream<char, std::char_traits<char> >&) const':
ItemsetQueue.c:(.text+0x306): multiple definition of `minit::ItemsetQueue::printItemsets(std::basic_ostream<char, std::char_traits<char> >&) const'
minit:(.text+0xa60): first defined here
/tmp/ccQhesuV.o: In function `minit::ItemsetQueue::ItemsetQueue()':
ItemsetQueue.c:(.text+0x0): multiple definition of `minit::ItemsetQueue::ItemsetQueue()'
minit:(.text+0x390): first defined here
/tmp/cc6ZqTIl.o: In function `minit::Transaction::readTransaction(std::basic_istream<char, std::char_traits<char> >&)':
Transaction.c:(.text+0x0): multiple definition of `minit::Transaction::readTransaction(std::basic_istream<char, std::char_traits<char> >&)'
minit:(.text+0x16b0): first defined here
/tmp/cc6ZqTIl.o: In function `minit::Transaction::readValue(std::basic_istream<char, std::char_traits<char> >&)':
Transaction.c:(.text+0x14a): multiple definition of `minit::Transaction::readValue(std::basic_istream<char, std::char_traits<char> >&)'
minit:(.text+0x15b0): first defined here
/tmp/ccZandoO.o: In function `minit::Dataset::Dataset(std::basic_string<char, std::char_traits<char>, std::allocator<char> >)':
Dataset.c:(.text+0x0): multiple definition of `minit::Dataset::Dataset(std::basic_string<char, std::char_traits<char>, std::allocator<char> >)'
minit:(.text+0x29b0): first defined here
/tmp/ccZandoO.o: In function `minit::Dataset::readDataset(std::basic_istream<char, std::char_traits<char> >&)':
Dataset.c:(.text+0x644): multiple definition of `minit::Dataset::readDataset(std::basic_istream<char, std::char_traits<char> >&)'
minit:(.text+0x2350): first defined here
/tmp/ccZandoO.o: In function `minit::Dataset::~Dataset()':
Dataset.c:(.text+0x512): multiple definition of `minit::Dataset::~Dataset()'
minit:(.text+0x1af0): first defined here
/tmp/ccZandoO.o: In function `minit::Dataset::toString() const':
Dataset.c:(.text+0x7f0): multiple definition of `minit::Dataset::toString() const'
minit:(.text+0x1c00): first defined here
/tmp/ccZandoO.o: In function `minit::Dataset::printColumnInfo()':
Dataset.c:(.text+0x9d6): multiple definition of `minit::Dataset::printColumnInfo()'
minit:(.text+0x2200): first defined here
/tmp/ccZandoO.o: In function `minit::Dataset::Dataset(std::basic_string<char, std::char_traits<char>, std::allocator<char> >)':
Dataset.c:(.text+0x0): multiple definition of `minit::Dataset::Dataset(std::basic_string<char, std::char_traits<char>, std::allocator<char> >)'
minit:(.text+0x29b0): first defined here
/tmp/ccZandoO.o: In function `minit::Dataset::~Dataset()':
Dataset.c:(.text+0x512): multiple definition of `minit::Dataset::~Dataset()'
minit:(.text+0x1af0): first defined here
/tmp/cc3PBOXh.o: In function `minit::SubDataset::SubDataset(minit::Dataset const&)':
SubDataset.c:(.text+0x0): multiple definition of `minit::SubDataset::SubDataset(minit::Dataset const&)'
minit:(.text+0x3c20): first defined here
/tmp/cc3PBOXh.o:(.bss+0x0): multiple definition of `minit::SubDataset::count'
minit:(.bss+0x670): first defined here
/tmp/cc3PBOXh.o:(.bss+0x10): multiple definition of `minit::SubDataset::preComputeCallsPerMaxc'
minit:(.bss+0x650): first defined here
/tmp/cc3PBOXh.o: In function `minit::SubDataset::SubDataset(minit::SubDataset const&)':
SubDataset.c:(.text+0x11a): multiple definition of `minit::SubDataset::SubDataset(minit::SubDataset const&)'
minit:(.text+0x3360): first defined here
/tmp/cc3PBOXh.o: In function `minit::SubDataset::~SubDataset()':
SubDataset.c:(.text+0x1b8): multiple definition of `minit::SubDataset::~SubDataset()'
minit:(.text+0x33f0): first defined here
/tmp/cc3PBOXh.o: In function `minit::SubDataset::~SubDataset()':
SubDataset.c:(.text+0x1b8): multiple definition of `minit::SubDataset::~SubDataset()'
minit:(.text+0x33f0): first defined here
/tmp/cc3PBOXh.o: In function `minit::SubDataset::supportSet(unsigned int) const':
SubDataset.c:(.text+0x242): multiple definition of `minit::SubDataset::supportSet(unsigned int) const'
minit:(.text+0x33a0): first defined here
/tmp/cc3PBOXh.o: In function `minit::SubDataset::preComputeSupportSets(minit::RankItems const&, int, int, int)':
SubDataset.c:(.text+0x2ac): multiple definition of `minit::SubDataset::preComputeSupportSets(minit::RankItems const&, int, int, int)'
minit:(.text+0x40d0): first defined here
/tmp/cc3PBOXh.o: In function `minit::SubDataset::preComputeSupportSetsLeafNode(minit::RankItems const&, unsigned int, unsigned int)':
SubDataset.c:(.text+0x514): multiple definition of `minit::SubDataset::preComputeSupportSetsLeafNode(minit::RankItems const&, unsigned int, unsigned int)'
minit:(.text+0x3f30): first defined here
/tmp/cc3PBOXh.o: In function `minit::SubDataset::SubDataset(minit::SubDataset const&)':
SubDataset.c:(.text+0x11a): multiple definition of `minit::SubDataset::SubDataset(minit::SubDataset const&)'
minit:(.text+0x3360): first defined here
/tmp/cc3PBOXh.o: In function `minit::SubDataset::doneWithAnchorItem(unsigned int const&)':
SubDataset.c:(.text+0x6a0): multiple definition of `minit::SubDataset::doneWithAnchorItem(unsigned int const&)'
minit:(.text+0x37e0): first defined here
/tmp/cc3PBOXh.o: In function `minit::SubDataset::SubDataset(minit::Dataset const&)':
SubDataset.c:(.text+0x0): multiple definition of `minit::SubDataset::SubDataset(minit::Dataset const&)'
minit:(.text+0x3c20): first defined here
/tmp/ccWMQMqM.o: In function `minit::RankItems::RankItems(minit::Dataset const&)':
RankItems.c:(.text+0x0): multiple definition of `minit::RankItems::RankItems(minit::Dataset const&)'
minit:(.text+0x56c0): first defined here
/tmp/ccWMQMqM.o:(.bss+0x0): multiple definition of `minit::RankItems::count'
minit:(.bss+0x680): first defined here
/tmp/ccWMQMqM.o: In function `minit::RankItems::RankItems(minit::SubDataset&, int, minit::RankItems const&, int, unsigned int)':
RankItems.c:(.text+0x1fa): multiple definition of `minit::RankItems::RankItems(minit::SubDataset&, int, minit::RankItems const&, int, unsigned int)'
minit:(.text+0x5990): first defined here
/tmp/ccWMQMqM.o: In function `minit::RankItems::toString() const':
RankItems.c:(.text+0x4e0): multiple definition of `minit::RankItems::toString() const'
minit:(.text+0x5130): first defined here
/tmp/ccWMQMqM.o: In function `minit::RankItems::RankItems(minit::Dataset const&)':
RankItems.c:(.text+0x0): multiple definition of `minit::RankItems::RankItems(minit::Dataset const&)'
minit:(.text+0x56c0): first defined here
/tmp/ccWMQMqM.o: In function `minit::RankItems::RankItems(minit::SubDataset&, int, minit::RankItems const&, int, unsigned int)':
RankItems.c:(.text+0x1fa): multiple definition of `minit::RankItems::RankItems(minit::SubDataset&, int, minit::RankItems const&, int, unsigned int)'
minit:(.text+0x5990): first defined here
/tmp/ccDeL01h.o: In function `minit::MinitAlgo::MinitAlgo(std::basic_string<char, std::char_traits<char>, std::allocator<char> >)':
MinitAlgo.c:(.text+0x0): multiple definition of `minit::MinitAlgo::MinitAlgo(std::basic_string<char, std::char_traits<char>, std::allocator<char> >)'
minit:(.text+0x6eb0): first defined here
/tmp/ccDeL01h.o: In function `minit::MinitAlgo::~MinitAlgo()':
MinitAlgo.c:(.text+0x128): multiple definition of `minit::MinitAlgo::~MinitAlgo()'
minit:(.text+0x6dc0): first defined here
/tmp/ccDeL01h.o: In function `minit::MinitAlgo::search(int, int, bool)':
MinitAlgo.c:(.text+0x1ee): multiple definition of `minit::MinitAlgo::search(int, int, bool)'
minit:(.text+0x93f0): first defined here
/tmp/ccDeL01h.o: In function `minit::MinitAlgo::minitRecursive(minit::SubDataset&, minit::RankItems const&, int, int)':
MinitAlgo.c:(.text+0x6fc): multiple definition of `minit::MinitAlgo::minitRecursive(minit::SubDataset&, minit::RankItems const&, int, int)'
minit:(.text+0x9860): first defined here
/tmp/ccDeL01h.o: In function `minit::MinitAlgo::processMinII(int, unsigned int, unsigned int)':
MinitAlgo.c:(.text+0x678): multiple definition of `minit::MinitAlgo::processMinII(int, unsigned int, unsigned int)'
minit:(.text+0x6d70): first defined here
/tmp/ccDeL01h.o: In function `minit::MinitAlgo::requiredSupportTransactionsExist(unsigned int const&, minit::Itemset const&, unsigned int const&, minit::SubDataset const&, int)':
MinitAlgo.c:(.text+0x10f0): multiple definition of `minit::MinitAlgo::requiredSupportTransactionsExist(unsigned int const&, minit::Itemset const&, unsigned int const&, minit::SubDataset const&, int)'
minit:(.text+0x6fe0): first defined here
/tmp/ccDeL01h.o: In function `minit::MinitAlgo::MinitAlgo(std::basic_string<char, std::char_traits<char>, std::allocator<char> >)':
MinitAlgo.c:(.text+0x0): multiple definition of `minit::MinitAlgo::MinitAlgo(std::basic_string<char, std::char_traits<char>, std::allocator<char> >)'
minit:(.text+0x6eb0): first defined here
/tmp/ccDeL01h.o: In function `minit::MinitAlgo::~MinitAlgo()':
MinitAlgo.c:(.text+0x128): multiple definition of `minit::MinitAlgo::~MinitAlgo()'
minit:(.text+0x6dc0): first defined here
/usr/lib/gcc/x86_64-amazon-linux/4.6.3/crtend.o:(.dtors+0x0): multiple definition of `__DTOR_END__'
minit:(.dtors+0x8): first defined here
/usr/bin/ld: error in minit(.eh_frame); no .eh_frame_hdr table will be created.
collect2: ld returned 1 exit status
[ec2-user#ip-10-209-16-177 minit++]$
[ec2-user#ip-10-209-16-177 minit++]$ g++ -o -O0 minit minit.c MinitGlobal.h Item.c ItemsetQueue.c Transaction.c Error.h Dataset.c SubDataset.c RankItems.c MinitAlgo.c
minit: In function `_start':
(.text+0x2a8): multiple definition of `_start'
/usr/lib/gcc/x86_64-amazon-linux/4.6.3/../../../../lib64/crt1.o:(.text+0x0): first defined here
minit: In function `_fini':
(.fini+0x0): multiple definition of `_fini'
/usr/lib/gcc/x86_64-amazon-linux/4.6.3/../../../../lib64/crti.o:(.fini+0x0): first defined here
minit:(.rodata+0x0): multiple definition of `_IO_stdin_used'
/usr/lib/gcc/x86_64-amazon-linux/4.6.3/../../../../lib64/crt1.o:(.rodata.cst4+0x0): first defined here
minit: In function `__data_start':
(.data+0x0): multiple definition of `__data_start'
/usr/lib/gcc/x86_64-amazon-linux/4.6.3/../../../../lib64/crt1.o:(.data+0x0): first defined here
minit:(.rodata+0x8): multiple definition of `__dso_handle'
/usr/lib/gcc/x86_64-amazon-linux/4.6.3/crtbegin.o:(.rodata+0x0): first defined here
minit: In function `_init':
(.init+0x0): multiple definition of `_init'
/usr/lib/gcc/x86_64-amazon-linux/4.6.3/../../../../lib64/crti.o:(.init+0x0): first defined here
/tmp/cc0cvoT6.o: In function `main':
minit.c:(.text+0x4d2): multiple definition of `main'
minit:(.text+0x0): first defined here
/tmp/ccRfRvQv.o:(.bss+0x0): multiple definition of `minit::Itemset::count'
minit:(.bss+0x638): first defined here
/tmp/ccQhesuV.o: In function `minit::ItemsetQueue::ItemsetQueue()':
ItemsetQueue.c:(.text+0x0): multiple definition of `minit::ItemsetQueue::ItemsetQueue()'
minit:(.text+0x390): first defined here
/tmp/ccQhesuV.o: In function `minit::ItemsetQueue::enqueue(unsigned int const&, unsigned int)':
ItemsetQueue.c:(.text+0x7e): multiple definition of `minit::ItemsetQueue::enqueue(unsigned int const&, unsigned int)'
minit:(.text+0x430): first defined here
/tmp/ccQhesuV.o: In function `minit::ItemsetQueue::enqueue(minit::Itemset const&, unsigned int const&, unsigned int)':
ItemsetQueue.c:(.text+0xfe): multiple definition of `minit::ItemsetQueue::enqueue(minit::Itemset const&, unsigned int const&, unsigned int)'
minit:(.text+0x520): first defined here
/tmp/ccQhesuV.o: In function `minit::ItemsetQueue::dequeue()':
ItemsetQueue.c:(.text+0x186): multiple definition of `minit::ItemsetQueue::dequeue()'
minit:(.text+0x3b0): first defined here
/tmp/ccQhesuV.o: In function `minit::ItemsetQueue::print(std::basic_ostream<char, std::char_traits<char> >&) const':
ItemsetQueue.c:(.text+0x1f2): multiple definition of `minit::ItemsetQueue::print(std::basic_ostream<char, std::char_traits<char> >&) const'
minit:(.text+0x6d0): first defined here
/tmp/ccQhesuV.o: In function `minit::ItemsetQueue::printItemsets(std::basic_ostream<char, std::char_traits<char> >&) const':
ItemsetQueue.c:(.text+0x306): multiple definition of `minit::ItemsetQueue::printItemsets(std::basic_ostream<char, std::char_traits<char> >&) const'
minit:(.text+0xa60): first defined here
/tmp/ccQhesuV.o: In function `minit::ItemsetQueue::ItemsetQueue()':
ItemsetQueue.c:(.text+0x0): multiple definition of `minit::ItemsetQueue::ItemsetQueue()'
minit:(.text+0x390): first defined here
/tmp/cc6ZqTIl.o: In function `minit::Transaction::readTransaction(std::basic_istream<char, std::char_traits<char> >&)':
Transaction.c:(.text+0x0): multiple definition of `minit::Transaction::readTransaction(std::basic_istream<char, std::char_traits<char> >&)'
minit:(.text+0x16b0): first defined here
/tmp/cc6ZqTIl.o: In function `minit::Transaction::readValue(std::basic_istream<char, std::char_traits<char> >&)':
Transaction.c:(.text+0x14a): multiple definition of `minit::Transaction::readValue(std::basic_istream<char, std::char_traits<char> >&)'
minit:(.text+0x15b0): first defined here
/tmp/ccZandoO.o: In function `minit::Dataset::Dataset(std::basic_string<char, std::char_traits<char>, std::allocator<char> >)':
Dataset.c:(.text+0x0): multiple definition of `minit::Dataset::Dataset(std::basic_string<char, std::char_traits<char>, std::allocator<char> >)'
minit:(.text+0x29b0): first defined here
/tmp/ccZandoO.o: In function `minit::Dataset::readDataset(std::basic_istream<char, std::char_traits<char> >&)':
Dataset.c:(.text+0x644): multiple definition of `minit::Dataset::readDataset(std::basic_istream<char, std::char_traits<char> >&)'
minit:(.text+0x2350): first defined here
/tmp/ccZandoO.o: In function `minit::Dataset::~Dataset()':
Dataset.c:(.text+0x512): multiple definition of `minit::Dataset::~Dataset()'
minit:(.text+0x1af0): first defined here
/tmp/ccZandoO.o: In function `minit::Dataset::toString() const':
Dataset.c:(.text+0x7f0): multiple definition of `minit::Dataset::toString() const'
minit:(.text+0x1c00): first defined here
/tmp/ccZandoO.o: In function `minit::Dataset::printColumnInfo()':
Dataset.c:(.text+0x9d6): multiple definition of `minit::Dataset::printColumnInfo()'
minit:(.text+0x2200): first defined here
/tmp/ccZandoO.o: In function `minit::Dataset::Dataset(std::basic_string<char, std::char_traits<char>, std::allocator<char> >)':
Dataset.c:(.text+0x0): multiple definition of `minit::Dataset::Dataset(std::basic_string<char, std::char_traits<char>, std::allocator<char> >)'
minit:(.text+0x29b0): first defined here
/tmp/ccZandoO.o: In function `minit::Dataset::~Dataset()':
Dataset.c:(.text+0x512): multiple definition of `minit::Dataset::~Dataset()'
minit:(.text+0x1af0): first defined here
/tmp/cc3PBOXh.o: In function `minit::SubDataset::SubDataset(minit::Dataset const&)':
SubDataset.c:(.text+0x0): multiple definition of `minit::SubDataset::SubDataset(minit::Dataset const&)'
minit:(.text+0x3c20): first defined here
/tmp/cc3PBOXh.o:(.bss+0x0): multiple definition of `minit::SubDataset::count'
minit:(.bss+0x670): first defined here
/tmp/cc3PBOXh.o:(.bss+0x10): multiple definition of `minit::SubDataset::preComputeCallsPerMaxc'
minit:(.bss+0x650): first defined here
/tmp/cc3PBOXh.o: In function `minit::SubDataset::SubDataset(minit::SubDataset const&)':
SubDataset.c:(.text+0x11a): multiple definition of `minit::SubDataset::SubDataset(minit::SubDataset const&)'
minit:(.text+0x3360): first defined here
/tmp/cc3PBOXh.o: In function `minit::SubDataset::~SubDataset()':
SubDataset.c:(.text+0x1b8): multiple definition of `minit::SubDataset::~SubDataset()'
minit:(.text+0x33f0): first defined here
/tmp/cc3PBOXh.o: In function `minit::SubDataset::~SubDataset()':
SubDataset.c:(.text+0x1b8): multiple definition of `minit::SubDataset::~SubDataset()'
minit:(.text+0x33f0): first defined here
/tmp/cc3PBOXh.o: In function `minit::SubDataset::supportSet(unsigned int) const':
SubDataset.c:(.text+0x242): multiple definition of `minit::SubDataset::supportSet(unsigned int) const'
minit:(.text+0x33a0): first defined here
/tmp/cc3PBOXh.o: In function `minit::SubDataset::preComputeSupportSets(minit::RankItems const&, int, int, int)':
SubDataset.c:(.text+0x2ac): multiple definition of `minit::SubDataset::preComputeSupportSets(minit::RankItems const&, int, int, int)'
minit:(.text+0x40d0): first defined here
/tmp/cc3PBOXh.o: In function `minit::SubDataset::preComputeSupportSetsLeafNode(minit::RankItems const&, unsigned int, unsigned int)':
SubDataset.c:(.text+0x514): multiple definition of `minit::SubDataset::preComputeSupportSetsLeafNode(minit::RankItems const&, unsigned int, unsigned int)'
minit:(.text+0x3f30): first defined here
/tmp/cc3PBOXh.o: In function `minit::SubDataset::SubDataset(minit::SubDataset const&)':
SubDataset.c:(.text+0x11a): multiple definition of `minit::SubDataset::SubDataset(minit::SubDataset const&)'
minit:(.text+0x3360): first defined here
/tmp/cc3PBOXh.o: In function `minit::SubDataset::doneWithAnchorItem(unsigned int const&)':
SubDataset.c:(.text+0x6a0): multiple definition of `minit::SubDataset::doneWithAnchorItem(unsigned int const&)'
minit:(.text+0x37e0): first defined here
/tmp/cc3PBOXh.o: In function `minit::SubDataset::SubDataset(minit::Dataset const&)':
SubDataset.c:(.text+0x0): multiple definition of `minit::SubDataset::SubDataset(minit::Dataset const&)'
minit:(.text+0x3c20): first defined here
/tmp/ccWMQMqM.o: In function `minit::RankItems::RankItems(minit::Dataset const&)':
RankItems.c:(.text+0x0): multiple definition of `minit::RankItems::RankItems(minit::Dataset const&)'
minit:(.text+0x56c0): first defined here
/tmp/ccWMQMqM.o:(.bss+0x0): multiple definition of `minit::RankItems::count'
minit:(.bss+0x680): first defined here
/tmp/ccWMQMqM.o: In function `minit::RankItems::RankItems(minit::SubDataset&, int, minit::RankItems const&, int, unsigned int)':
RankItems.c:(.text+0x1fa): multiple definition of `minit::RankItems::RankItems(minit::SubDataset&, int, minit::RankItems const&, int, unsigned int)'
minit:(.text+0x5990): first defined here
/tmp/ccWMQMqM.o: In function `minit::RankItems::toString() const':
RankItems.c:(.text+0x4e0): multiple definition of `minit::RankItems::toString() const'
minit:(.text+0x5130): first defined here
/tmp/ccWMQMqM.o: In function `minit::RankItems::RankItems(minit::Dataset const&)':
RankItems.c:(.text+0x0): multiple definition of `minit::RankItems::RankItems(minit::Dataset const&)'
minit:(.text+0x56c0): first defined here
/tmp/ccWMQMqM.o: In function `minit::RankItems::RankItems(minit::SubDataset&, int, minit::RankItems const&, int, unsigned int)':
RankItems.c:(.text+0x1fa): multiple definition of `minit::RankItems::RankItems(minit::SubDataset&, int, minit::RankItems const&, int, unsigned int)'
minit:(.text+0x5990): first defined here
/tmp/ccDeL01h.o: In function `minit::MinitAlgo::MinitAlgo(std::basic_string<char, std::char_traits<char>, std::allocator<char> >)':
MinitAlgo.c:(.text+0x0): multiple definition of `minit::MinitAlgo::MinitAlgo(std::basic_string<char, std::char_traits<char>, std::allocator<char> >)'
minit:(.text+0x6eb0): first defined here
/tmp/ccDeL01h.o: In function `minit::MinitAlgo::~MinitAlgo()':
MinitAlgo.c:(.text+0x128): multiple definition of `minit::MinitAlgo::~MinitAlgo()'
minit:(.text+0x6dc0): first defined here
/tmp/ccDeL01h.o: In function `minit::MinitAlgo::search(int, int, bool)':
MinitAlgo.c:(.text+0x1ee): multiple definition of `minit::MinitAlgo::search(int, int, bool)'
minit:(.text+0x93f0): first defined here
/tmp/ccDeL01h.o: In function `minit::MinitAlgo::minitRecursive(minit::SubDataset&, minit::RankItems const&, int, int)':
MinitAlgo.c:(.text+0x6fc): multiple definition of `minit::MinitAlgo::minitRecursive(minit::SubDataset&, minit::RankItems const&, int, int)'
minit:(.text+0x9860): first defined here
/tmp/ccDeL01h.o: In function `minit::MinitAlgo::processMinII(int, unsigned int, unsigned int)':
MinitAlgo.c:(.text+0x678): multiple definition of `minit::MinitAlgo::processMinII(int, unsigned int, unsigned int)'
minit:(.text+0x6d70): first defined here
/tmp/ccDeL01h.o: In function `minit::MinitAlgo::requiredSupportTransactionsExist(unsigned int const&, minit::Itemset const&, unsigned int const&, minit::SubDataset const&, int)':
MinitAlgo.c:(.text+0x10f0): multiple definition of `minit::MinitAlgo::requiredSupportTransactionsExist(unsigned int const&, minit::Itemset const&, unsigned int const&, minit::SubDataset const&, int)'
minit:(.text+0x6fe0): first defined here
/tmp/ccDeL01h.o: In function `minit::MinitAlgo::MinitAlgo(std::basic_string<char, std::char_traits<char>, std::allocator<char> >)':
MinitAlgo.c:(.text+0x0): multiple definition of `minit::MinitAlgo::MinitAlgo(std::basic_string<char, std::char_traits<char>, std::allocator<char> >)'
minit:(.text+0x6eb0): first defined here
/tmp/ccDeL01h.o: In function `minit::MinitAlgo::~MinitAlgo()':
MinitAlgo.c:(.text+0x128): multiple definition of `minit::MinitAlgo::~MinitAlgo()'
minit:(.text+0x6dc0): first defined here
/usr/lib/gcc/x86_64-amazon-linux/4.6.3/crtend.o:(.dtors+0x0): multiple definition of `__DTOR_END__'
minit:(.dtors+0x8): first defined here
/usr/bin/ld: error in minit(.eh_frame); no .eh_frame_hdr table will be created.
collect2: ld returned 1 exit status
[ec2-user#ip-10-209-16-177 minit++]$
It crashes. All the errors are of "multiple definition" nature, could you please suggest how to fix that?
gcc/g++ expect the name of the output file directly after -o. You mixed up the argument order:
Instead of g++ -o -O0 minit ... try g++ -O0 -o minit ....
g++ tried to link the executable minit and the objects files together into one assembly, that's why you get these errors.
I tried several times, it's probably fairly easy to solve but I can't see the solution.
I tried to compile SAXPrint example from xerces site ( the link to four *.cpp and *.hpp files is here [sorry for using skydrive, my FTP died]) using g++ in linux (got xerces-dev package) and windows (MinGW with libraries) and I couldn't succeed Is there any chance you could lend me a hand? I tried command:
g++ SAXPrint.hpp SAXPrint.cpp SAXPrintHandlers.hpp SAXPrintHandlers.cpp -o output
and it gave me:
C:\Users\Mati\AppData\Local\Temp\cctzntQK.o:SAXPrintHandlers.cpp:(.text+0x0): multiple definition of `SAXPrintHandlers::SAXPrint
Handlers(char const*, xercesc_3_1::XMLFormatter::UnRepFlags)'
C:\Users\Mati\AppData\Local\Temp\ccF7gVrk.o:SAXPrintHandlers.cpp:(.text+0x0): first defined here
C:\Users\Mati\AppData\Local\Temp\cctzntQK.o:SAXPrintHandlers.cpp:(.text+0x0): multiple definition of `SAXPrintHandlers::SAXPrint
Handlers(char const*, xercesc_3_1::XMLFormatter::UnRepFlags)'
C:\Users\Mati\AppData\Local\Temp\ccF7gVrk.o:SAXPrintHandlers.cpp:(.text+0x0): first defined here
C:\Users\Mati\AppData\Local\Temp\cctzntQK.o:SAXPrintHandlers.cpp:(.text+0x11e): multiple definition of `SAXPrintHandlers::~SAXPr
intHandlers()'
C:\Users\Mati\AppData\Local\Temp\ccF7gVrk.o:SAXPrintHandlers.cpp:(.text+0x11e): first defined here
C:\Users\Mati\AppData\Local\Temp\cctzntQK.o:SAXPrintHandlers.cpp:(.text+0x11e): multiple definition of `SAXPrintHandlers::~SAXPr
intHandlers()'
C:\Users\Mati\AppData\Local\Temp\ccF7gVrk.o:SAXPrintHandlers.cpp:(.text+0x11e): first defined here
C:\Users\Mati\AppData\Local\Temp\cctzntQK.o:SAXPrintHandlers.cpp:(.text+0x1c9): multiple definition of `non-virtual thunk to SAX
PrintHandlers::~SAXPrintHandlers()'
C:\Users\Mati\AppData\Local\Temp\ccF7gVrk.o:SAXPrintHandlers.cpp:(.text+0x1c9): first defined here
C:\Users\Mati\AppData\Local\Temp\cctzntQK.o:SAXPrintHandlers.cpp:(.text+0x1d3): multiple definition of `non-virtual thunk to SAX
PrintHandlers::~SAXPrintHandlers()'
C:\Users\Mati\AppData\Local\Temp\ccF7gVrk.o:SAXPrintHandlers.cpp:(.text+0x1d3): first defined here
C:\Users\Mati\AppData\Local\Temp\cctzntQK.o:SAXPrintHandlers.cpp:(.text+0x1dd): multiple definition of `non-virtual thunk to SAX
PrintHandlers::~SAXPrintHandlers()'
C:\Users\Mati\AppData\Local\Temp\ccF7gVrk.o:SAXPrintHandlers.cpp:(.text+0x1dd): first defined here
C:\Users\Mati\AppData\Local\Temp\cctzntQK.o:SAXPrintHandlers.cpp:(.text+0x1e7): multiple definition of `non-virtual thunk to SAX
PrintHandlers::~SAXPrintHandlers()'
C:\Users\Mati\AppData\Local\Temp\ccF7gVrk.o:SAXPrintHandlers.cpp:(.text+0x1e7): first defined here
C:\Users\Mati\AppData\Local\Temp\cctzntQK.o:SAXPrintHandlers.cpp:(.text+0x1f2): multiple definition of `SAXPrintHandlers::~SAXPr
intHandlers()'
C:\Users\Mati\AppData\Local\Temp\ccF7gVrk.o:SAXPrintHandlers.cpp:(.text+0x1f2): first defined here
C:\Users\Mati\AppData\Local\Temp\cctzntQK.o:SAXPrintHandlers.cpp:(.text+0x212): multiple definition of `non-virtual thunk to SAX
PrintHandlers::~SAXPrintHandlers()'
C:\Users\Mati\AppData\Local\Temp\ccF7gVrk.o:SAXPrintHandlers.cpp:(.text+0x212): first defined here
C:\Users\Mati\AppData\Local\Temp\cctzntQK.o:SAXPrintHandlers.cpp:(.text+0x219): multiple definition of `non-virtual thunk to SAX
PrintHandlers::~SAXPrintHandlers()'
C:\Users\Mati\AppData\Local\Temp\ccF7gVrk.o:SAXPrintHandlers.cpp:(.text+0x219): first defined here
C:\Users\Mati\AppData\Local\Temp\cctzntQK.o:SAXPrintHandlers.cpp:(.text+0x220): multiple definition of `non-virtual thunk to SAX
PrintHandlers::~SAXPrintHandlers()'
C:\Users\Mati\AppData\Local\Temp\ccF7gVrk.o:SAXPrintHandlers.cpp:(.text+0x220): first defined here
C:\Users\Mati\AppData\Local\Temp\cctzntQK.o:SAXPrintHandlers.cpp:(.text+0x227): multiple definition of `non-virtual thunk to SAX
PrintHandlers::~SAXPrintHandlers()'
C:\Users\Mati\AppData\Local\Temp\ccF7gVrk.o:SAXPrintHandlers.cpp:(.text+0x227): first defined here
C:\Users\Mati\AppData\Local\Temp\cctzntQK.o:SAXPrintHandlers.cpp:(.text+0x22e): multiple definition of `SAXPrintHandlers::writeC
hars(unsigned char const*)'
C:\Users\Mati\AppData\Local\Temp\ccF7gVrk.o:SAXPrintHandlers.cpp:(.text+0x22e): first defined here
C:\Users\Mati\AppData\Local\Temp\cctzntQK.o:SAXPrintHandlers.cpp:(.text+0x234): multiple definition of `SAXPrintHandlers::writeC
hars(unsigned char const*, unsigned long, xercesc_3_1::XMLFormatter*)'
C:\Users\Mati\AppData\Local\Temp\ccF7gVrk.o:SAXPrintHandlers.cpp:(.text+0x234): first defined here
C:\Users\Mati\AppData\Local\Temp\cctzntQK.o:SAXPrintHandlers.cpp:(.text+0x262): multiple definition of `non-virtual thunk to SAX
PrintHandlers::writeChars(unsigned char const*, unsigned long, xercesc_3_1::XMLFormatter*)'
C:\Users\Mati\AppData\Local\Temp\ccF7gVrk.o:SAXPrintHandlers.cpp:(.text+0x262): first defined here
C:\Users\Mati\AppData\Local\Temp\cctzntQK.o:SAXPrintHandlers.cpp:(.text+0x26a): multiple definition of `SAXPrintHandlers::error(
xercesc_3_1::SAXParseException const&)'
C:\Users\Mati\AppData\Local\Temp\ccF7gVrk.o:SAXPrintHandlers.cpp:(.text+0x26a): first defined here
C:\Users\Mati\AppData\Local\Temp\cctzntQK.o:SAXPrintHandlers.cpp:(.text+0x39a): multiple definition of `non-virtual thunk to SAX
PrintHandlers::error(xercesc_3_1::SAXParseException const&)'
C:\Users\Mati\AppData\Local\Temp\ccF7gVrk.o:SAXPrintHandlers.cpp:(.text+0x39a): first defined here
C:\Users\Mati\AppData\Local\Temp\cctzntQK.o:SAXPrintHandlers.cpp:(.text+0x3a4): multiple definition of `SAXPrintHandlers::fatalE
rror(xercesc_3_1::SAXParseException const&)'
C:\Users\Mati\AppData\Local\Temp\ccF7gVrk.o:SAXPrintHandlers.cpp:(.text+0x3a4): first defined here
C:\Users\Mati\AppData\Local\Temp\cctzntQK.o:SAXPrintHandlers.cpp:(.text+0x4d4): multiple definition of `non-virtual thunk to SAX
PrintHandlers::fatalError(xercesc_3_1::SAXParseException const&)'
C:\Users\Mati\AppData\Local\Temp\ccF7gVrk.o:SAXPrintHandlers.cpp:(.text+0x4d4): first defined here
C:\Users\Mati\AppData\Local\Temp\cctzntQK.o:SAXPrintHandlers.cpp:(.text+0x4de): multiple definition of `SAXPrintHandlers::warnin
g(xercesc_3_1::SAXParseException const&)'
C:\Users\Mati\AppData\Local\Temp\ccF7gVrk.o:SAXPrintHandlers.cpp:(.text+0x4de): first defined here
C:\Users\Mati\AppData\Local\Temp\cctzntQK.o:SAXPrintHandlers.cpp:(.text+0x60e): multiple definition of `non-virtual thunk to SAX
PrintHandlers::warning(xercesc_3_1::SAXParseException const&)'
C:\Users\Mati\AppData\Local\Temp\ccF7gVrk.o:SAXPrintHandlers.cpp:(.text+0x60e): first defined here
C:\Users\Mati\AppData\Local\Temp\cctzntQK.o:SAXPrintHandlers.cpp:(.text+0x618): multiple definition of `SAXPrintHandlers::unpars
edEntityDecl(unsigned short const*, unsigned short const*, unsigned short const*, unsigned short const*)'
C:\Users\Mati\AppData\Local\Temp\ccF7gVrk.o:SAXPrintHandlers.cpp:(.text+0x618): first defined here
C:\Users\Mati\AppData\Local\Temp\cctzntQK.o:SAXPrintHandlers.cpp:(.text+0x61d): multiple definition of `non-virtual thunk to SAX
PrintHandlers::unparsedEntityDecl(unsigned short const*, unsigned short const*, unsigned short const*, unsigned short const*)'
C:\Users\Mati\AppData\Local\Temp\ccF7gVrk.o:SAXPrintHandlers.cpp:(.text+0x61d): first defined here
C:\Users\Mati\AppData\Local\Temp\cctzntQK.o:SAXPrintHandlers.cpp:(.text+0x624): multiple definition of `SAXPrintHandlers::notati
onDecl(unsigned short const*, unsigned short const*, unsigned short const*)'
C:\Users\Mati\AppData\Local\Temp\ccF7gVrk.o:SAXPrintHandlers.cpp:(.text+0x624): first defined here
C:\Users\Mati\AppData\Local\Temp\cctzntQK.o:SAXPrintHandlers.cpp:(.text+0x629): multiple definition of `non-virtual thunk to SAX
PrintHandlers::notationDecl(unsigned short const*, unsigned short const*, unsigned short const*)'
C:\Users\Mati\AppData\Local\Temp\ccF7gVrk.o:SAXPrintHandlers.cpp:(.text+0x629): first defined here
C:\Users\Mati\AppData\Local\Temp\cctzntQK.o:SAXPrintHandlers.cpp:(.text+0x630): multiple definition of `SAXPrintHandlers::charac
ters(unsigned short const*, unsigned long)'
C:\Users\Mati\AppData\Local\Temp\ccF7gVrk.o:SAXPrintHandlers.cpp:(.text+0x630): first defined here
C:\Users\Mati\AppData\Local\Temp\cctzntQK.o:SAXPrintHandlers.cpp:(.text+0x666): multiple definition of `non-virtual thunk to SAX
PrintHandlers::characters(unsigned short const*, unsigned long)'
C:\Users\Mati\AppData\Local\Temp\ccF7gVrk.o:SAXPrintHandlers.cpp:(.text+0x666): first defined here
C:\Users\Mati\AppData\Local\Temp\cctzntQK.o:SAXPrintHandlers.cpp:(.text+0x66e): multiple definition of `SAXPrintHandlers::endDoc
ument()'
C:\Users\Mati\AppData\Local\Temp\ccF7gVrk.o:SAXPrintHandlers.cpp:(.text+0x66e): first defined here
C:\Users\Mati\AppData\Local\Temp\cctzntQK.o:SAXPrintHandlers.cpp:(.text+0x673): multiple definition of `non-virtual thunk to SAX
PrintHandlers::endDocument()'
C:\Users\Mati\AppData\Local\Temp\ccF7gVrk.o:SAXPrintHandlers.cpp:(.text+0x673): first defined here
C:\Users\Mati\AppData\Local\Temp\cctzntQK.o:SAXPrintHandlers.cpp:(.text+0x67a): multiple definition of `SAXPrintHandlers::endEle
ment(unsigned short const*)'
C:\Users\Mati\AppData\Local\Temp\ccF7gVrk.o:SAXPrintHandlers.cpp:(.text+0x67a): first defined here
C:\Users\Mati\AppData\Local\Temp\cctzntQK.o:SAXPrintHandlers.cpp:(.text+0x6cd): multiple definition of `non-virtual thunk to SAX
PrintHandlers::endElement(unsigned short const*)'
C:\Users\Mati\AppData\Local\Temp\ccF7gVrk.o:SAXPrintHandlers.cpp:(.text+0x6cd): first defined here
C:\Users\Mati\AppData\Local\Temp\cctzntQK.o:SAXPrintHandlers.cpp:(.text+0x6d4): multiple definition of `SAXPrintHandlers::ignora
bleWhitespace(unsigned short const*, unsigned long)'
C:\Users\Mati\AppData\Local\Temp\ccF7gVrk.o:SAXPrintHandlers.cpp:(.text+0x6d4): first defined here
C:\Users\Mati\AppData\Local\Temp\cctzntQK.o:SAXPrintHandlers.cpp:(.text+0x70a): multiple definition of `non-virtual thunk to SAX
PrintHandlers::ignorableWhitespace(unsigned short const*, unsigned long)'
C:\Users\Mati\AppData\Local\Temp\ccF7gVrk.o:SAXPrintHandlers.cpp:(.text+0x70a): first defined here
C:\Users\Mati\AppData\Local\Temp\cctzntQK.o:SAXPrintHandlers.cpp:(.text+0x712): multiple definition of `SAXPrintHandlers::proces
singInstruction(unsigned short const*, unsigned short const*)'
C:\Users\Mati\AppData\Local\Temp\ccF7gVrk.o:SAXPrintHandlers.cpp:(.text+0x712): first defined here
C:\Users\Mati\AppData\Local\Temp\cctzntQK.o:SAXPrintHandlers.cpp:(.text+0x7aa): multiple definition of `non-virtual thunk to SAX
PrintHandlers::processingInstruction(unsigned short const*, unsigned short const*)'
C:\Users\Mati\AppData\Local\Temp\ccF7gVrk.o:SAXPrintHandlers.cpp:(.text+0x7aa): first defined here
C:\Users\Mati\AppData\Local\Temp\cctzntQK.o:SAXPrintHandlers.cpp:(.text+0x7b4): multiple definition of `SAXPrintHandlers::startD
ocument()'
C:\Users\Mati\AppData\Local\Temp\ccF7gVrk.o:SAXPrintHandlers.cpp:(.text+0x7b4): first defined here
C:\Users\Mati\AppData\Local\Temp\cctzntQK.o:SAXPrintHandlers.cpp:(.text+0x7b9): multiple definition of `non-virtual thunk to SAX
PrintHandlers::startDocument()'
C:\Users\Mati\AppData\Local\Temp\ccF7gVrk.o:SAXPrintHandlers.cpp:(.text+0x7b9): first defined here
C:\Users\Mati\AppData\Local\Temp\cctzntQK.o:SAXPrintHandlers.cpp:(.text+0x7c0): multiple definition of `SAXPrintHandlers::startE
lement(unsigned short const*, xercesc_3_1::AttributeList&)'
C:\Users\Mati\AppData\Local\Temp\ccF7gVrk.o:SAXPrintHandlers.cpp:(.text+0x7c0): first defined here
C:\Users\Mati\AppData\Local\Temp\cctzntQK.o:SAXPrintHandlers.cpp:(.text+0x925): multiple definition of `non-virtual thunk to SAX
PrintHandlers::startElement(unsigned short const*, xercesc_3_1::AttributeList&)'
C:\Users\Mati\AppData\Local\Temp\ccF7gVrk.o:SAXPrintHandlers.cpp:(.text+0x925): first defined here
C:\Users\Mati\AppData\Local\Temp\ccJzlNBi.o:SAXPrint.cpp:(.text+0x44): undefined reference to `_imp___ZN11xercesc_3_16XMLUni22fg
XercescDefaultLocaleE'
C:\Users\Mati\AppData\Local\Temp\ccJzlNBi.o:SAXPrint.cpp:(.text+0x64): undefined reference to `_imp___ZN11xercesc_3_116XMLPlatfo
rmUtils10InitializeEPKcS2_PNS_12PanicHandlerEPNS_13MemoryManagerE'
C:\Users\Mati\AppData\Local\Temp\ccJzlNBi.o:SAXPrint.cpp:(.text+0x76): undefined reference to `_imp___ZN11xercesc_3_116XMLPlatfo
rmUtils9TerminateEv'
C:\Users\Mati\AppData\Local\Temp\ccJzlNBi.o:SAXPrint.cpp:(.text+0xd8): undefined reference to `_imp___ZN11xercesc_3_116XMLPlatfo
rmUtils9TerminateEv'
C:\Users\Mati\AppData\Local\Temp\ccJzlNBi.o:SAXPrint.cpp:(.text+0x211): undefined reference to `_imp___ZN11xercesc_3_116XMLPlatf
ormUtils9TerminateEv'
C:\Users\Mati\AppData\Local\Temp\ccJzlNBi.o:SAXPrint.cpp:(.text+0x4b2): undefined reference to `_imp___ZN11xercesc_3_116XMLPlatf
ormUtils9TerminateEv'
C:\Users\Mati\AppData\Local\Temp\ccJzlNBi.o:SAXPrint.cpp:(.text+0x543): undefined reference to `_imp___ZN11xercesc_3_116XMLPlatf
ormUtils9TerminateEv'
C:\Users\Mati\AppData\Local\Temp\ccJzlNBi.o:SAXPrint.cpp:(.text+0x57a): undefined reference to `_imp___ZN11xercesc_3_17XMemorynw
Ej'
C:\Users\Mati\AppData\Local\Temp\ccJzlNBi.o:SAXPrint.cpp:(.text+0x583): undefined reference to `_imp___ZN11xercesc_3_116XMLPlatf
ormUtils15fgMemoryManagerE'
C:\Users\Mati\AppData\Local\Temp\ccJzlNBi.o:SAXPrint.cpp:(.text+0x5a3): undefined reference to `_imp___ZN11xercesc_3_19SAXParser
C1EPNS_12XMLValidatorEPNS_13MemoryManagerEPNS_14XMLGrammarPoolE'
C:\Users\Mati\AppData\Local\Temp\ccJzlNBi.o:SAXPrint.cpp:(.text+0x5c4): undefined reference to `_imp___ZN11xercesc_3_19SAXParser
19setValidationSchemeENS0_10ValSchemesE'
C:\Users\Mati\AppData\Local\Temp\ccJzlNBi.o:SAXPrint.cpp:(.text+0x5e1): undefined reference to `_imp___ZN11xercesc_3_19SAXParser
15setDoNamespacesEb'
C:\Users\Mati\AppData\Local\Temp\ccJzlNBi.o:SAXPrint.cpp:(.text+0x5fe): undefined reference to `_imp___ZN11xercesc_3_19SAXParser
11setDoSchemaEb'
C:\Users\Mati\AppData\Local\Temp\ccJzlNBi.o:SAXPrint.cpp:(.text+0x617): undefined reference to `_imp___ZN11xercesc_3_19SAXParser
24setHandleMultipleImportsEb'
C:\Users\Mati\AppData\Local\Temp\ccJzlNBi.o:SAXPrint.cpp:(.text+0x634): undefined reference to `_imp___ZN11xercesc_3_19SAXParser
31setValidationSchemaFullCheckingEb'
C:\Users\Mati\AppData\Local\Temp\ccJzlNBi.o:SAXPrint.cpp:(.text+0x6dc): undefined reference to `_imp___ZNK11xercesc_3_19SAXParse
r13getErrorCountEv'
C:\Users\Mati\AppData\Local\Temp\ccJzlNBi.o:SAXPrint.cpp:(.text+0x700): undefined reference to `_imp___ZN11xercesc_3_116XMLPlatf
ormUtils9TerminateEv'
C:\Users\Mati\AppData\Local\Temp\ccJzlNBi.o:SAXPrint.cpp:(.text+0x734): undefined reference to `_imp___ZN11xercesc_3_116XMLPlatf
ormUtils9TerminateEv'
C:\Users\Mati\AppData\Local\Temp\ccJzlNBi.o:SAXPrint.cpp:(.text+0x819): undefined reference to `_imp___ZN11xercesc_3_17XMemorydl
EPv'
C:\Users\Mati\AppData\Local\Temp\ccJzlNBi.o:SAXPrint.cpp:(.text$_ZN4StrXC1EPKt[StrX::StrX(unsigned short const*)]+0x7): undefine
d reference to `_imp___ZN11xercesc_3_116XMLPlatformUtils15fgMemoryManagerE'
C:\Users\Mati\AppData\Local\Temp\ccJzlNBi.o:SAXPrint.cpp:(.text$_ZN4StrXC1EPKt[StrX::StrX(unsigned short const*)]+0x18): undefin
ed reference to `_imp___ZN11xercesc_3_19XMLString9transcodeEPKtPNS_13MemoryManagerE'
C:\Users\Mati\AppData\Local\Temp\ccJzlNBi.o:SAXPrint.cpp:(.text$_ZN4StrXD1Ev[StrX::~StrX()]+0x7): undefined reference to `_imp__
_ZN11xercesc_3_116XMLPlatformUtils15fgMemoryManagerE'
C:\Users\Mati\AppData\Local\Temp\ccJzlNBi.o:SAXPrint.cpp:(.text$_ZN4StrXD1Ev[StrX::~StrX()]+0x18): undefined reference to `_imp_
__ZN11xercesc_3_19XMLString7releaseEPPcPNS_13MemoryManagerE'
C:\Users\Mati\AppData\Local\Temp\ccF7gVrk.o:SAXPrintHandlers.cpp:(.text+0x52): undefined reference to `_imp___ZN11xercesc_3_116X
MLPlatformUtils15fgMemoryManagerE'
C:\Users\Mati\AppData\Local\Temp\ccF7gVrk.o:SAXPrintHandlers.cpp:(.text+0x8e): undefined reference to `_imp___ZN11xercesc_3_112X
MLFormatterC1EPKcS2_PNS_15XMLFormatTargetENS0_11EscapeFlagsENS0_10UnRepFlagsEPNS_13MemoryManagerE'
C:\Users\Mati\AppData\Local\Temp\ccF7gVrk.o:SAXPrintHandlers.cpp:(.text+0xb6): undefined reference to `_imp___ZN11xercesc_3_112X
MLFormatterlsEPKt'
C:\Users\Mati\AppData\Local\Temp\ccF7gVrk.o:SAXPrintHandlers.cpp:(.text+0xc4): undefined reference to `_imp___ZN11xercesc_3_112X
MLFormatterlsEPKt'
C:\Users\Mati\AppData\Local\Temp\ccF7gVrk.o:SAXPrintHandlers.cpp:(.text+0xd6): undefined reference to `_imp___ZN11xercesc_3_112X
MLFormatterlsEPKt'
C:\Users\Mati\AppData\Local\Temp\ccF7gVrk.o:SAXPrintHandlers.cpp:(.text+0xea): undefined reference to `_imp___ZN11xercesc_3_112X
MLFormatterD1Ev'
C:\Users\Mati\AppData\Local\Temp\ccF7gVrk.o:SAXPrintHandlers.cpp:(.text+0x160): undefined reference to `_imp___ZN11xercesc_3_112
XMLFormatterD1Ev'
C:\Users\Mati\AppData\Local\Temp\ccF7gVrk.o:SAXPrintHandlers.cpp:(.text+0x192): undefined reference to `_imp___ZN11xercesc_3_17X
MemorydlEPv'
C:\Users\Mati\AppData\Local\Temp\ccF7gVrk.o:SAXPrintHandlers.cpp:(.text+0x20a): undefined reference to `_imp___ZN11xercesc_3_17X
MemorydlEPv'
C:\Users\Mati\AppData\Local\Temp\ccF7gVrk.o:SAXPrintHandlers.cpp:(.text+0x29a): undefined reference to `_imp___ZNK11xercesc_3_11
7SAXParseException15getColumnNumberEv'
C:\Users\Mati\AppData\Local\Temp\ccF7gVrk.o:SAXPrintHandlers.cpp:(.text+0x2a9): undefined reference to `_imp___ZNK11xercesc_3_11
7SAXParseException13getLineNumberEv'
C:\Users\Mati\AppData\Local\Temp\ccF7gVrk.o:SAXPrintHandlers.cpp:(.text+0x2b8): undefined reference to `_imp___ZNK11xercesc_3_11
7SAXParseException11getSystemIdEv'
C:\Users\Mati\AppData\Local\Temp\ccF7gVrk.o:SAXPrintHandlers.cpp:(.text+0x3d4): undefined reference to `_imp___ZNK11xercesc_3_11
7SAXParseException15getColumnNumberEv'
C:\Users\Mati\AppData\Local\Temp\ccF7gVrk.o:SAXPrintHandlers.cpp:(.text+0x3e3): undefined reference to `_imp___ZNK11xercesc_3_11
7SAXParseException13getLineNumberEv'
C:\Users\Mati\AppData\Local\Temp\ccF7gVrk.o:SAXPrintHandlers.cpp:(.text+0x3f2): undefined reference to `_imp___ZNK11xercesc_3_11
7SAXParseException11getSystemIdEv'
C:\Users\Mati\AppData\Local\Temp\ccF7gVrk.o:SAXPrintHandlers.cpp:(.text+0x50e): undefined reference to `_imp___ZNK11xercesc_3_11
7SAXParseException15getColumnNumberEv'
C:\Users\Mati\AppData\Local\Temp\ccF7gVrk.o:SAXPrintHandlers.cpp:(.text+0x51d): undefined reference to `_imp___ZNK11xercesc_3_11
7SAXParseException13getLineNumberEv'
C:\Users\Mati\AppData\Local\Temp\ccF7gVrk.o:SAXPrintHandlers.cpp:(.text+0x52c): undefined reference to `_imp___ZNK11xercesc_3_11
7SAXParseException11getSystemIdEv'
C:\Users\Mati\AppData\Local\Temp\ccF7gVrk.o:SAXPrintHandlers.cpp:(.text+0x65e): undefined reference to `_imp___ZN11xercesc_3_112
XMLFormatter9formatBufEPKtmNS0_11EscapeFlagsENS0_10UnRepFlagsE'
C:\Users\Mati\AppData\Local\Temp\ccF7gVrk.o:SAXPrintHandlers.cpp:(.text+0x6a2): undefined reference to `_imp___ZN11xercesc_3_112
XMLFormatterlsEPKt'
C:\Users\Mati\AppData\Local\Temp\ccF7gVrk.o:SAXPrintHandlers.cpp:(.text+0x6b3): undefined reference to `_imp___ZN11xercesc_3_112
XMLFormatterlsEPKt'
C:\Users\Mati\AppData\Local\Temp\ccF7gVrk.o:SAXPrintHandlers.cpp:(.text+0x6c5): undefined reference to `_imp___ZN11xercesc_3_112
XMLFormatterlsEt'
C:\Users\Mati\AppData\Local\Temp\ccF7gVrk.o:SAXPrintHandlers.cpp:(.text+0x702): undefined reference to `_imp___ZN11xercesc_3_112
XMLFormatter9formatBufEPKtmNS0_11EscapeFlagsENS0_10UnRepFlagsE'
C:\Users\Mati\AppData\Local\Temp\ccF7gVrk.o:SAXPrintHandlers.cpp:(.text+0x73a): undefined reference to `_imp___ZN11xercesc_3_112
XMLFormatterlsEPKt'
C:\Users\Mati\AppData\Local\Temp\ccF7gVrk.o:SAXPrintHandlers.cpp:(.text+0x74b): undefined reference to `_imp___ZN11xercesc_3_112
XMLFormatterlsEPKt'
C:\Users\Mati\AppData\Local\Temp\ccF7gVrk.o:SAXPrintHandlers.cpp:(.text+0x769): undefined reference to `_imp___ZN11xercesc_3_112
XMLFormatterlsEt'
C:\Users\Mati\AppData\Local\Temp\ccF7gVrk.o:SAXPrintHandlers.cpp:(.text+0x77a): undefined reference to `_imp___ZN11xercesc_3_112
XMLFormatterlsEPKt'
C:\Users\Mati\AppData\Local\Temp\ccF7gVrk.o:SAXPrintHandlers.cpp:(.text+0x7a2): undefined reference to `_imp___ZN11xercesc_3_112
XMLFormatterlsEPKt'
C:\Users\Mati\AppData\Local\Temp\ccF7gVrk.o:SAXPrintHandlers.cpp:(.text+0x7ea): undefined reference to `_imp___ZN11xercesc_3_112
XMLFormatterlsEt'
C:\Users\Mati\AppData\Local\Temp\ccF7gVrk.o:SAXPrintHandlers.cpp:(.text+0x7fb): undefined reference to `_imp___ZN11xercesc_3_112
XMLFormatterlsEPKt'
C:\Users\Mati\AppData\Local\Temp\ccF7gVrk.o:SAXPrintHandlers.cpp:(.text+0x87a): undefined reference to `_imp___ZN11xercesc_3_112
XMLFormatterlsEt'
C:\Users\Mati\AppData\Local\Temp\ccF7gVrk.o:SAXPrintHandlers.cpp:(.text+0x888): undefined reference to `_imp___ZN11xercesc_3_112
XMLFormatterlsEPKt'
C:\Users\Mati\AppData\Local\Temp\ccF7gVrk.o:SAXPrintHandlers.cpp:(.text+0x89a): undefined reference to `_imp___ZN11xercesc_3_112
XMLFormatterlsEt'
C:\Users\Mati\AppData\Local\Temp\ccF7gVrk.o:SAXPrintHandlers.cpp:(.text+0x8ac): undefined reference to `_imp___ZN11xercesc_3_112
XMLFormatterlsEt'
C:\Users\Mati\AppData\Local\Temp\ccF7gVrk.o:SAXPrintHandlers.cpp:(.text+0x8ca): undefined reference to `_imp___ZN11xercesc_3_112
XMLFormatterlsEPKt'
C:\Users\Mati\AppData\Local\Temp\ccF7gVrk.o:SAXPrintHandlers.cpp:(.text+0x8ec): undefined reference to `_imp___ZN11xercesc_3_112
XMLFormatterlsEt'
C:\Users\Mati\AppData\Local\Temp\ccF7gVrk.o:SAXPrintHandlers.cpp:(.text+0x918): undefined reference to `_imp___ZN11xercesc_3_112
XMLFormatterlsEt'
C:\Users\Mati\AppData\Local\Temp\ccF7gVrk.o:SAXPrintHandlers.cpp:(.text$_ZN11xercesc_3_115DocumentHandlerC2Ev[xercesc_3_1::Docum
entHandler::DocumentHandler()]+0x4): undefined reference to `_imp___ZTVN11xercesc_3_115DocumentHandlerE'
C:\Users\Mati\AppData\Local\Temp\ccF7gVrk.o:SAXPrintHandlers.cpp:(.text$_ZN11xercesc_3_115DocumentHandlerD2Ev[xercesc_3_1::Docum
entHandler::~DocumentHandler()]+0x7): undefined reference to `_imp___ZTVN11xercesc_3_115DocumentHandlerE'
C:\Users\Mati\AppData\Local\Temp\ccF7gVrk.o:SAXPrintHandlers.cpp:(.text$_ZN11xercesc_3_115DocumentHandlerD1Ev[xercesc_3_1::Docum
entHandler::~DocumentHandler()]+0x7): undefined reference to `_imp___ZTVN11xercesc_3_115DocumentHandlerE'
etc.
Is there any chance to solve it quick? Thanks anyway!
don't put the .hpp files in the compiler command line. they are included automatically by the .cpp files.
g++ SAXPrint.cpp SAXPrintHandlers.cpp -o output
I solved my problem, it was simplier than I had imagined. All you need to do is use flag:
-lxerces-c
It worked out great, but thanks for trying, guys! I appreciate it :)
I'm new to C++ and I have a problem with classes.
I got this prototype
class MMA7455 : public Accel
{
public:
MMA7455(uint8_t);
uint8_t accel_get_data(acceleration_t*);
private:
uint8_t accel_data_ready(void);
};
and I want to create an instance of it
MMA7455 accel = MMA7455(0x21);
but the following message appears
In function `global constructors keyed to accel':
sensors.cpp:(.text+0x8): undefined reference to `MMA7455::MMA7455(unsigned char)'
Why it's looking for 'unsigned char' argument? Same message even if I try to implicitly cast the type of constant
MMA7455 accel = MMA7455((uint8_t)0x21);
You probably didn't link your .cpp file containing the constructor definition. "uint8_t" is a typedef for 'unsigned char".
You need to define MMA7455::MMA7455(uint8_t) somewhere in your program, i.e. add a {}-body after the definition in the prototype (or perhaps you just forgot to compile and link the cpp-file containing the definitions for MMA7455.
It looks for unsigned char because uint8_t happens to be a typedef for unsigned char on your system.
uint8_t is a typedef for unsigned char on your platform. The error is a linker error since you haven't provided an implementation for your constructor and is unrelated to the argument being an unsigned char or not.
My code had an error about not defining the operator<. I corrected the operator< problem in my code by overloading it. When I compile it, there was no error there but it has lots of errors about multidefinition. My code is:
int Vector3D::operator < (const Vector 3D &vector) const
{
if(x<vector.x)
return 1;
else
return 0;
}
Here are some of the lines:
debug/src/common/propagation-delay-model_1.o: In function `empty':
/usr/include/c++/4.1.2/limits:1044: multiple definition of `ns3::Vector3D::operator<(ns3::Vector3D const&) const'
debug/src/core/vector_1.o:/home/bahar/Desktop/ns/ns-allinone-3.9/ns-allinone-3.9/ns-3.9/build/../src/core/vector.h:118: first defined here
debug/src/common/propagation-loss-model_1.o: In function `empty':
/usr/include/c++/4.1.2/new:94: multiple definition of `ns3::Vector3D::operator<(ns3::Vector3D const&) const'
debug/src/core/vector_1.o:/home/bahar/Desktop/ns/ns-allinone-3.9/ns-allinone-3.9/ns-3.9/build/../src/core/vector.h:118: first defined here
debug/src/common/jakes-propagation-loss-model_1.o: In function `empty':
/usr/include/c++/4.1.2/new:94: multiple definition of `ns3::Vector3D::operator<(ns3::Vector3D const&) const'
debug/src/core/vector_1.o:/home/bahar/Desktop/ns/ns-allinone-3.9/ns-allinone-3.9/ns-3.9/build/../src/core/vector.h:118: first defined here
debug/src/common/cost231-propagation-loss-model_1.o: In function `empty':
/usr/include/c++/4.1.2/limits:1044: multiple definition of `ns3::Vector3D::operator<(ns3::Vector3D const&) const'
debug/src/core/vector_1.o:/home/bahar/Desktop/ns/ns-allinone-3.9/ns-allinone-3.9/ns-3.9/build/../src/core/vector.h:118: first defined here
debug/src/common/spectrum-propagation-loss-model_1.o: In function `~BandInfo':
/home/bahar/Desktop/ns/ns-allinone-3.9/ns-allinone-3.9/ns-3.9/build/debug/ns3/type-id.h:392: multiple definition of `ns3::Vector3D::operator<(ns3::Vector3D const&) const'
debug/src/core/vector_1.o:/home/bahar/Desktop/ns/ns-allinone-3.9/ns-allinone-3.9/ns-3.9/build/../src/core/vector.h:118: first defined here
debug/src/common/friis-spectrum-propagation-loss_1.o: In function `~BandInfo':
/home/bahar/Desktop/ns/ns-allinone-3.9/ns-allinone-3.9/ns-3.9/build/debug/ns3/vector.h:118: multiple definition of `ns3::Vector3D::operator<(ns3::Vector3D const&) const'
debug/src/core/vector_1.o:/home/bahar/Desktop/ns/ns-allinone-3.9/ns-allinone-3.9/ns-3.9/build/../src/core/vector.h:118: first defined here
debug/src/node/spectrum-phy_1.o: In function `~TypeId':
/home/bahar/Desktop/ns/ns-allinone-3.9/ns-allinone-3.9/ns-3.9/build/debug/ns3/type-id.h:392: multiple definition of `ns3::Vector3D::operator<(ns3::Vector3D const&) const'
debug/src/core/vector_1.o:/home/bahar/Desktop/ns/ns-allinone-3.9/ns-allinone-3.9/ns-3.9/build/../src/core/vector.h:118: first defined here
debug/src/internet-stack/ipv6-l3-protocol_1.o: In function `new_allocator':
/usr/include/c++/4.1.2/new:94: multiple definition of `ns3::Vector3D::operator<(ns3::Vector3D const&) const'
debug/src/core/vector_1.o:/home/bahar/Desktop/ns/ns-allinone-3.9/ns-allinone-3.9/ns-3.9/build/../src/core/vector.h:118: first defined here
debug/src/routing/olsr/olsr-routing-protocol_1.o: In function `~Association':
/usr/include/c++/4.1.2/new:94: multiple definition of `ns3::Vector3D::operator<(ns3::Vector3D const&) const'
debug/src/core/vector_1.o:/home/bahar/Desktop/ns/ns-allinone-3.9/ns-allinone-3.9/ns-3.9/build/../src/core/vector.h:118: first defined here
debug/src/routing/olsr/test/bug780-test_1.o: In function `new_allocator':
/usr/include/c++/4.1.2/new:94: multiple definition of `ns3::Vector3D::operator<(ns3::Vector3D const&) const'
It looks like you are defining a function in a header file, so it gets defined in every source file that includes it. Either declare it inline (which allows multiple definitions), or move the implementation into a source file (so it's only defined once). EDIT: Or move the definition inside the class definition, which also makes it inline. (Thanks David.)