I build vfptr.cpp with fsanitize=vptr to an static file.
It has errors messages about "undefined reference to __dynamic_cast".
Both g++7.4.0 and g++11.0.0 have the problem. Is it reasonable for using sanitizer=vptr?
vptr.cpp
struct A {
virtual ~A() {};
};
int main() { A a; }
compiled option
g++ vptr.C -fsanitize=vptr -static
error message:
/usr/lib/gcc/x86_64-linux-gnu/7/libubsan.a(ubsan_type_hash_itanium.o): In function `isDerivedFromAtOffset(__cxxabiv1::__class_type_info const*, __cxxabiv1::__class_type_info const*, long)':
(.text+0x52): undefined reference to `__dynamic_cast'
(.text+0x5e): undefined reference to `typeinfo for __cxxabiv1::__vmi_class_type_info'
(.text+0x6b): undefined reference to `__dynamic_cast'
/usr/lib/gcc/x86_64-linux-gnu/7/libubsan.a(ubsan_type_hash_itanium.o): In function `findBaseAtOffset(__cxxabiv1::__class_type_info const*, long)':
(.text+0x151): undefined reference to `__dynamic_cast'
(.text+0x15d): undefined reference to `typeinfo for __cxxabiv1::__vmi_class_type_info'
(.text+0x16a): undefined reference to `__dynamic_cast'
/usr/lib/gcc/x86_64-linux-gnu/7/libubsan.a(ubsan_type_hash_itanium.o): In function `__ubsan::checkDynamicType(void*, void*, unsigned long)':
(.text+0x293): undefined reference to `__dynamic_cast'
collect2: error: ld returned 1 exit status
Related
I'm trying to use SWIG so that I can call C++ code from Go.
I want to use SWIG so that it can generate me wrapper code. The C++ code in question is generated by the protobuf compiler.
I have two hello.i files hello.i and protobuf.i:
protbuf.i
#define GOOGLE_PROTOBUF_VERSION 3021008
#define GOOGLE_PROTOBUF_MIN_PROTOC_VERSION 3021000
hello.i
%module example
%include "protobuf.i"
%{
#include "hello.pb.h"
#include "hello.gen.h"
%}
#include "hello.pb.h"
#include "hello.gen.h"
namespace example {
void handle_Person(example::Person& m, unsigned char* friends);
}
I am able to compile this with the SWIG command swig -go -cgo -c++ hello.i and it generates Go and _wrap.cc file.
Then I create a shared library with the following sequence of commands:
g++ -fPIC -c hello_wrap.cxx hello.pb.cc hello.gen.cc -ldl -lprotobuf -lprotoc -L${MY_PROJECT}/protobuf -L${MY_PROJECT}/protobuf/third_party/abseil-cpp/absl -L${MY_PROJECT}/protobuf/third_party/utf8_range
g++ -shared -o libhellowrap.so hello_wrap.o hello.gen.o hello.pb.o -ldl -lprotobuf -lprotoc -L${MY_PROJECT}/protobuf -L${MY_PROJECT}/protobuf/third_party/abseil-cpp/absl -L${MY_PROJECT}/protobuf/third_party/utf8_range
Now I want to use this in Go so I create a main.go file:
package main
/*
#cgo CFLAGS: -I/my_project/example
#cgo LDFLAGS: -L/my_project/example -lhellowrap -ldl -lstdc++
#include <stdlib.h>
*/
import (
"C"
"fmt"
"my_project/example"
)
func main() {
var p example.SwigcptrExample_Person
p = example.SwigcptrExample_Person(uintptr(int32(2000)))
friends := make([]byte, 5)
example.Handle_Person(p, &friends[0])
fmt.Println("New Friends: ", friends)
}
Then I run this main.go file and the following linkage errors occur:
# command-line-arguments
/usr/local/go/pkg/tool/linux_amd64/link: running g++ failed: exit status 1
/tmp/go-link-96276495/000017.o: In function `example::Person::MergeImpl(google::protobuf::Message&, google::protobuf::Message const&)':
/usr/local/include/google/protobuf/metadata_lite.h:183: undefined reference to `void google::protobuf::internal::InternalMetadata::DoMergeFrom<google::protobuf::UnknownFieldSet>(google::protobuf::UnknownFieldSet const&)'
/tmp/go-link-96276495/000017.o: In function `example::Person::MergeImpl(google::protobuf::Message&, google::protobuf::Message const&)':
/my_project/example/hello.pb.cc:265: undefined reference to `google::protobuf::internal::LogMessage::LogMessage(google::protobuf::LogLevel, char const*, int)'
/my_project/example/hello.pb.cc:265: undefined reference to `google::protobuf::internal::LogMessage::operator<<(char const*)'
/my_project/example/hello.pb.cc:265: undefined reference to `google::protobuf::internal::LogFinisher::operator=(google::protobuf::internal::LogMessage&)'
/my_project/example/hello.pb.cc:265: undefined reference to `google::protobuf::internal::LogMessage::~LogMessage()'
/tmp/go-link-96276495/000017.o: In function `example::Person::_InternalSerialize(unsigned char*, google::protobuf::io::EpsCopyOutputStream*) const':
/usr/local/include/google/protobuf/io/coded_stream.h:674: undefined reference to `google::protobuf::io::EpsCopyOutputStream::EnsureSpaceFallback(unsigned char*)'
/tmp/go-link-96276495/000017.o: In function `example::Person::_InternalParse(char const*, google::protobuf::internal::ParseContext*)':
/usr/local/include/google/protobuf/parse_context.h:567: undefined reference to `google::protobuf::internal::VarintParseSlow32(char const*, unsigned int)'
/usr/local/include/google/protobuf/parse_context.h:228: undefined reference to `google::protobuf::internal::LogMessage::LogMessage(google::protobuf::LogLevel, char const*, int)'
/usr/local/include/google/protobuf/parse_context.h:228: undefined reference to `google::protobuf::internal::LogMessage::operator<<(char const*)'
/usr/local/include/google/protobuf/parse_context.h:228: undefined reference to `google::protobuf::internal::LogFinisher::operator=(google::protobuf::internal::LogMessage&)'
/usr/local/include/google/protobuf/parse_context.h:228: undefined reference to `google::protobuf::internal::LogMessage::~LogMessage()'
/usr/local/include/google/protobuf/parse_context.h:239: undefined reference to `google::protobuf::internal::EpsCopyInputStream::DoneFallback(int, int)'
/tmp/go-link-96276495/000017.o: In function `example::Person::_InternalParse(char const*, google::protobuf::internal::ParseContext*)':
/my_project/example/hello.pb.cc:198: undefined reference to `google::protobuf::internal::UnknownFieldParse(unsigned long, google::protobuf::UnknownFieldSet*, char const*, google::protobuf::internal::ParseContext*)'
/tmp/go-link-96276495/000017.o: In function `example::Person::_InternalParse(char const*, google::protobuf::internal::ParseContext*)':
/usr/local/include/google/protobuf/parse_context.h:658: undefined reference to `google::protobuf::internal::ReadTagFallback(char const*, unsigned int)'
/usr/local/include/google/protobuf/parse_context.h:231: undefined reference to `google::protobuf::internal::LogMessage::LogMessage(google::protobuf::LogLevel, char const*, int)'
/usr/local/include/google/protobuf/parse_context.h:231: undefined reference to `google::protobuf::internal::LogMessage::operator<<(char const*)'
/usr/local/include/google/protobuf/parse_context.h:231: undefined reference to `google::protobuf::internal::LogFinisher::operator=(google::protobuf::internal::LogMessage&)'
/usr/local/include/google/protobuf/parse_context.h:231: undefined reference to `google::protobuf::internal::LogMessage::~LogMessage()'
/tmp/go-link-96276495/000017.o: In function `example::Person::_InternalParse(char const*, google::protobuf::internal::ParseContext*)':
/usr/local/include/google/protobuf/metadata_lite.h:159: undefined reference to `google::protobuf::UnknownFieldSet* google::protobuf::internal::InternalMetadata::mutable_unknown_fields_slow<google::protobuf::UnknownFieldSet>()'
/tmp/go-link-96276495/000017.o: In function `example::Person::~Person()':
/usr/local/include/google/protobuf/message.h:245: undefined reference to `vtable for google::protobuf::Message'
/usr/local/include/google/protobuf/message.h:245: undefined reference to `google::protobuf::MessageLite::~MessageLite()'
/tmp/go-link-96276495/000017.o: In function `example::Person::~Person()':
/usr/local/include/google/protobuf/metadata_lite.h:113: undefined reference to `google::protobuf::Arena* google::protobuf::internal::InternalMetadata::DeleteOutOfLineHelper<google::protobuf::UnknownFieldSet>()'
/tmp/go-link-96276495/000017.o: In function `example::Person::~Person()':
/my_project/example/hello.pb.cc:153: undefined reference to `google::protobuf::internal::LogMessage::LogMessage(google::protobuf::LogLevel, char const*, int)'
/my_project/example/hello.pb.cc:153: undefined reference to `google::protobuf::internal::LogMessage::operator<<(char const*)'
/my_project/example/hello.pb.cc:153: undefined reference to `google::protobuf::internal::LogFinisher::operator=(google::protobuf::internal::LogMessage&)'
/my_project/example/hello.pb.cc:153: undefined reference to `google::protobuf::internal::LogMessage::~LogMessage()'
/tmp/go-link-96276495/000017.o: In function `example::Person::Person(google::protobuf::Arena*, bool)':
/usr/local/include/google/protobuf/message_lite.h:432: undefined reference to `vtable for google::protobuf::MessageLite'
/tmp/go-link-96276495/000017.o: In function `example::Person::Person(google::protobuf::Arena*, bool)':
/usr/local/include/google/protobuf/metadata_lite.h:78: undefined reference to `google::protobuf::internal::LogMessage::LogMessage(google::protobuf::LogLevel, char const*, int)'
/usr/local/include/google/protobuf/metadata_lite.h:78: undefined reference to `google::protobuf::internal::LogMessage::operator<<(char const*)'
/usr/local/include/google/protobuf/metadata_lite.h:78: undefined reference to `google::protobuf::internal::LogFinisher::operator=(google::protobuf::internal::LogMessage&)'
/usr/local/include/google/protobuf/metadata_lite.h:78: undefined reference to `google::protobuf::internal::LogMessage::~LogMessage()'
/tmp/go-link-96276495/000017.o: In function `example::Person::Person(example::Person const&)':
/usr/local/include/google/protobuf/metadata_lite.h:183: undefined reference to `void google::protobuf::internal::InternalMetadata::DoMergeFrom<google::protobuf::UnknownFieldSet>(google::protobuf::UnknownFieldSet const&)'
/tmp/go-link-96276495/000017.o: In function `example::Person* google::protobuf::Arena::CreateMaybeMessage<example::Person>(google::protobuf::Arena*)':
/usr/local/include/google/protobuf/arena.h:309: undefined reference to `google::protobuf::Arena::Allocate(unsigned long)'
/tmp/go-link-96276495/000017.o: In function `example::Person::Clear()':
/usr/local/include/google/protobuf/metadata_lite.h:190: undefined reference to `void google::protobuf::internal::InternalMetadata::DoClear<google::protobuf::UnknownFieldSet>()'
/tmp/go-link-96276495/000017.o: In function `example::Person::_InternalSerialize(unsigned char*, google::protobuf::io::EpsCopyOutputStream*) const':
/my_project/example/hello.pb.cc:228: undefined reference to `google::protobuf::internal::WireFormat::InternalSerializeUnknownFieldsToArray(google::protobuf::UnknownFieldSet const&, unsigned char*, google::protobuf::io::EpsCopyOutputStream*)'
/tmp/go-link-96276495/000017.o: In function `example::Person::ByteSizeLong() const':
/my_project/example/hello.pb.cc:250: undefined reference to `google::protobuf::Message::MaybeComputeUnknownFieldsSize(unsigned long, google::protobuf::internal::CachedSize*) const'
/tmp/go-link-96276495/000017.o: In function `example::Person::GetMetadata() const':
/my_project/example/hello.pb.cc:297: undefined reference to `google::protobuf::internal::AssignDescriptors(google::protobuf::internal::DescriptorTable const* (*)(), absl::lts_20220623::once_flag*, google::protobuf::Metadata const&)'
/tmp/go-link-96276495/000017.o: In function `example::Person::MergeImpl(google::protobuf::Message&, google::protobuf::Message const&)':
/my_project/example/hello.pb.cc:265: undefined reference to `google::protobuf::internal::LogMessage::~LogMessage()'
/tmp/go-link-96276495/000017.o: In function `example::Person::_InternalParse(char const*, google::protobuf::internal::ParseContext*) [clone .cold.25]':
/usr/local/include/google/protobuf/parse_context.h:228: undefined reference to `google::protobuf::internal::LogMessage::~LogMessage()'
/usr/local/include/google/protobuf/parse_context.h:231: undefined reference to `google::protobuf::internal::LogMessage::~LogMessage()'
/tmp/go-link-96276495/000017.o: In function `example::Person::~Person() [clone .cold.26]':
/my_project/example/hello.pb.cc:153: undefined reference to `google::protobuf::internal::LogMessage::~LogMessage()'
/tmp/go-link-96276495/000017.o: In function `example::Person::Person(google::protobuf::Arena*, bool) [clone .cold.27]':
/my_project/example/hello.pb.cc:143: undefined reference to `google::protobuf::internal::LogMessage::~LogMessage()'
/tmp/go-link-96276495/000017.o: In function `example::Person::Person(example::Person const&) [clone .cold.28]':
/usr/local/include/google/protobuf/message.h:245: undefined reference to `vtable for google::protobuf::Message'
/usr/local/include/google/protobuf/message.h:245: undefined reference to `google::protobuf::MessageLite::~MessageLite()'
/tmp/go-link-96276495/000017.o: In function `_GLOBAL__sub_I.00102_hello.pb.cc':
/my_project/example/hello.pb.cc:105: undefined reference to `google::protobuf::internal::AddDescriptorsRunner::AddDescriptorsRunner(google::protobuf::internal::DescriptorTable const*)'
/tmp/go-link-96276495/000017.o:(.data.rel.ro._ZTIN7example6PersonE[_ZTIN7example6PersonE]+0x10): undefined reference to `typeinfo for google::protobuf::Message'
/tmp/go-link-96276495/000017.o:(.data.rel.ro._ZTVN7example6PersonE[_ZTVN7example6PersonE]+0x20): undefined reference to `google::protobuf::Message::GetTypeName[abi:cxx11]() const'
/tmp/go-link-96276495/000017.o:(.data.rel.ro._ZTVN7example6PersonE[_ZTVN7example6PersonE]+0x40): undefined reference to `google::protobuf::Message::InitializationErrorString[abi:cxx11]() const'
/tmp/go-link-96276495/000017.o:(.data.rel.ro._ZTVN7example6PersonE[_ZTVN7example6PersonE]+0x48): undefined reference to `google::protobuf::Message::CheckTypeAndMergeFrom(google::protobuf::MessageLite const&)'
/tmp/go-link-96276495/000017.o:(.data.rel.ro._ZTVN7example6PersonE[_ZTVN7example6PersonE]+0x78): undefined reference to `google::protobuf::Message::MergeFrom(google::protobuf::Message const&)'
/tmp/go-link-96276495/000017.o:(.data.rel.ro._ZTVN7example6PersonE[_ZTVN7example6PersonE]+0x80): undefined reference to `google::protobuf::Message::SpaceUsedLong() const'
/tmp/go-link-96276495/000017.o:(.data.rel.ro+0x0): undefined reference to `google::protobuf::Message::CopyWithSourceCheck(google::protobuf::Message&, google::protobuf::Message const&)'
/tmp/go-link-96276495/000018.o: In function `example::handle_Person(example::Person&, unsigned char*)':
/my_project/example/hello.gen.cc:14: undefined reference to `dlopen'
/my_project/example/hello.gen.cc:25: undefined reference to `dlsym'
/my_project/example/hello.gen.cc:26: undefined reference to `dlerror'
/my_project/example/hello.gen.cc:29: undefined reference to `dlclose'
/my_project/example/hello.gen.cc:16: undefined reference to `dlerror'
collect2: error: ld returned 1 exit status
I have various things when trying to solve this problem but it feels like I'm missing a crucial step.
I downloaded some example protobuff codes and sfml-networking but i cant compile the files and i dont what's wrong i definitly installed "libprotobuf-dev" and "protobuf-compiler" and also the code seem to run ok on other Pcs but when i use command make in terminal i get this error
this is the repository i cloned the example from :
https://github.com/An-Alone-Cow/schat
please help me i tried every thing
i also reinstalled all protobuff things several times and even installed manually from github repository provided by google
this is the error massege i get
g++ main.o messages.pb.o -L/usr/SFML-2.5.1/lib/ -lprotobuf -lsfml-network -lsfml-system -o run
main.o: In function `google::protobuf::internal::GetEmptyStringAlreadyInited[abi:cxx11]()':
main.cpp:(.text._ZN6google8protobuf8internal27GetEmptyStringAlreadyInitedB5cxx11Ev[_ZN6google8protobuf8internal27GetEmptyStringAlreadyInitedB5cxx11Ev]+0x7): undefined reference to `google::protobuf::internal::fixed_address_empty_string[abi:cxx11]'
messages.pb.o: In function `Message* google::protobuf::Arena::CreateMaybeMessage<Message>(google::protobuf::Arena*)':
messages.pb.cc:(.text+0x177a): undefined reference to `google::protobuf::internal::ArenaImpl::AllocateAligned(unsigned long)'
messages.pb.cc:(.text+0x1799): undefined reference to `google::protobuf::internal::ArenaImpl::AllocateAlignedAndAddCleanup(unsigned long, void (*)(void*))'
messages.pb.o: In function `__static_initialization_and_destruction_0(int, int)':
messages.pb.cc:(.text+0x1855): undefined reference to `google::protobuf::internal::AddDescriptors(google::protobuf::internal::DescriptorTable const*)'
messages.pb.o: In function `google::protobuf::Arena::AllocHook(std::type_info const*, unsigned long) const':
messages.pb.cc:(.text._ZNK6google8protobuf5Arena9AllocHookEPKSt9type_infom[_ZNK6google8protobuf5Arena9AllocHookEPKSt9type_infom]+0x3d): undefined reference to `google::protobuf::Arena::OnArenaAllocation(std::type_info const*, unsigned long) const'
messages.pb.o: In function `google::protobuf::internal::ArenaStringPtr::CreateInstance(google::protobuf::Arena*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const*)':
messages.pb.cc:(.text._ZN6google8protobuf8internal14ArenaStringPtr14CreateInstanceEPNS0_5ArenaEPKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE[_ZN6google8protobuf8internal14ArenaStringPtr14CreateInstanceEPNS0_5ArenaEPKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE]+0x22f): undefined reference to `google::protobuf::internal::ArenaImpl::AllocateAligned(unsigned long)'
messages.pb.cc:(.text._ZN6google8protobuf8internal14ArenaStringPtr14CreateInstanceEPNS0_5ArenaEPKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE[_ZN6google8protobuf8internal14ArenaStringPtr14CreateInstanceEPNS0_5ArenaEPKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE]+0x24e): undefined reference to `google::protobuf::internal::ArenaImpl::AllocateAlignedAndAddCleanup(unsigned long, void (*)(void*))'
messages.pb.o: In function `google::protobuf::internal::InitSCC(google::protobuf::internal::SCCInfoBase*)':
messages.pb.cc:(.text._ZN6google8protobuf8internal7InitSCCEPNS1_11SCCInfoBaseE[_ZN6google8protobuf8internal7InitSCCEPNS1_11SCCInfoBaseE]+0x4d): undefined reference to `google::protobuf::internal::InitSCCImpl(google::protobuf::internal::SCCInfoBase*)'
messages.pb.o: In function `google::protobuf::internal::OnShutdownDestroyMessage(void const*)':
messages.pb.cc:(.text._ZN6google8protobuf8internal24OnShutdownDestroyMessageEPKv[_ZN6google8protobuf8internal24OnShutdownDestroyMessageEPKv]+0x16): undefined reference to `google::protobuf::internal::DestroyMessage(void const*)'
messages.pb.cc:(.text._ZN6google8protobuf8internal24OnShutdownDestroyMessageEPKv[_ZN6google8protobuf8internal24OnShutdownDestroyMessageEPKv]+0x1e): undefined reference to `google::protobuf::internal::OnShutdownRun(void (*)(void const*), void const*)'
messages.pb.o: In function `Message::GetMetadataStatic()':
messages.pb.cc:(.text._ZN7Message17GetMetadataStaticEv[_ZN7Message17GetMetadataStaticEv]+0xc): undefined reference to `google::protobuf::internal::AssignDescriptors(google::protobuf::internal::DescriptorTable const*)'
messages.pb.o: In function `google::protobuf::internal::InternalMetadataWithArenaBase<google::protobuf::UnknownFieldSet, google::protobuf::internal::InternalMetadataWithArena>::mutable_unknown_fields_slow()':
messages.pb.cc:(.text._ZN6google8protobuf8internal29InternalMetadataWithArenaBaseINS0_15UnknownFieldSetENS1_25InternalMetadataWithArenaEE27mutable_unknown_fields_slowEv[_ZN6google8protobuf8internal29InternalMetadataWithArenaBaseINS0_15UnknownFieldSetENS1_25InternalMetadataWithArenaEE27mutable_unknown_fields_slowEv]+0x15e): undefined reference to `google::protobuf::internal::ArenaImpl::AllocateAligned(unsigned long)'
messages.pb.cc:(.text._ZN6google8protobuf8internal29InternalMetadataWithArenaBaseINS0_15UnknownFieldSetENS1_25InternalMetadataWithArenaEE27mutable_unknown_fields_slowEv[_ZN6google8protobuf8internal29InternalMetadataWithArenaBaseINS0_15UnknownFieldSetENS1_25InternalMetadataWithArenaEE27mutable_unknown_fields_slowEv]+0x17a): undefined reference to `google::protobuf::internal::ArenaImpl::AllocateAlignedAndAddCleanup(unsigned long, void (*)(void*))'
messages.pb.o:(.data.rel.ro._ZTV7Message[_ZTV7Message]+0xb8): undefined reference to `google::protobuf::Message::SpaceUsedLong() const'
collect2: error: ld returned 1 exit status
Makefile:2: recipe for target 'run' failed
make: *** [run] Error 1
[1]: https://github.com/An-Alone-Cow/schat
I'm trying to utilize Crypto++'s Simon and Speck implementations for a research project, but I currently cannot compile and link the example code provided on its wiki page.
Following the instructions from the Crypto++ wiki, I was able to build the library and run all of their test suites to completion. I have also been able to run example AES code from the same wiki. The compilation errors only come when I try to invoke Simon or Speck.
To compile and link the file I am using g++ speck_test.cpp -lcryptopp.
Here is the program provided on the Crypto++ Speck wiki. I added include statements and scope resolutions where I believed necessary.
#include <iostream>
#include <iomanip>
#include "cryptopp/modes.h"
#include "cryptopp/speck.h"
#include "cryptopp/filters.h"
int main(int argc, char* argv[]) {
CryptoPP::SPECK128::Encryption speck;
std::cout << "StaticAlgorithmName: " << speck.StaticAlgorithmName() << std::endl;
std::cout << "AlgorithmName (unkeyed): " << speck.AlgorithmName() << std::endl;
CryptoPP::byte key[CryptoPP::SPECK128::DEFAULT_KEYLENGTH] = {};
speck.SetKey(key, sizeof(key));
std::cout << "AlgorithmName (keyed): " << speck.AlgorithmName() << std::endl;
return 0;
}
Expected output of this program according to the wiki is
StaticAlgorithmName: SPECK-128
AlgorithmName (unkeyed): SPECK-128
AlgorithmName (keyed): SPECK-128(128)
however, I am receiving the following error from the compiler:
/tmp/ccD02cM7.o: In function `CryptoPP::SPECK128::Base::Base()':
speck_test.cpp:(.text._ZN8CryptoPP8SPECK1284BaseC2Ev[_ZN8CryptoPP8SPECK1284BaseC5Ev]+0x2c): undefined reference to `vtable for CryptoPP::SPECK128::Base'
speck_test.cpp:(.text._ZN8CryptoPP8SPECK1284BaseC2Ev[_ZN8CryptoPP8SPECK1284BaseC5Ev]+0x3a): undefined reference to `vtable for CryptoPP::SPECK128::Base'
speck_test.cpp:(.text._ZN8CryptoPP8SPECK1284BaseC2Ev[_ZN8CryptoPP8SPECK1284BaseC5Ev]+0x49): undefined reference to `vtable for CryptoPP::SPECK128::Base'
/tmp/ccD02cM7.o: In function `CryptoPP::SPECK128::Base::~Base()':
speck_test.cpp:(.text._ZN8CryptoPP8SPECK1284BaseD2Ev[_ZN8CryptoPP8SPECK1284BaseD5Ev]+0xf): undefined reference to `vtable for CryptoPP::SPECK128::Base'
speck_test.cpp:(.text._ZN8CryptoPP8SPECK1284BaseD2Ev[_ZN8CryptoPP8SPECK1284BaseD5Ev]+0x1d): undefined reference to `vtable for CryptoPP::SPECK128::Base'
/tmp/ccD02cM7.o:speck_test.cpp:(.text._ZN8CryptoPP8SPECK1284BaseD2Ev[_ZN8CryptoPP8SPECK1284BaseD5Ev]+0x2c): more undefined references to `vtable for CryptoPP::SPECK128::Base' follow
/tmp/ccD02cM7.o: In function `CryptoPP::SPECK128::Enc::Enc()':
speck_test.cpp:(.text._ZN8CryptoPP8SPECK1283EncC2Ev[_ZN8CryptoPP8SPECK1283EncC5Ev]+0x1b): undefined reference to `vtable for CryptoPP::SPECK128::Enc'
speck_test.cpp:(.text._ZN8CryptoPP8SPECK1283EncC2Ev[_ZN8CryptoPP8SPECK1283EncC5Ev]+0x29): undefined reference to `vtable for CryptoPP::SPECK128::Enc'
speck_test.cpp:(.text._ZN8CryptoPP8SPECK1283EncC2Ev[_ZN8CryptoPP8SPECK1283EncC5Ev]+0x38): undefined reference to `vtable for CryptoPP::SPECK128::Enc'
/tmp/ccD02cM7.o: In function `CryptoPP::SPECK128::Enc::~Enc()':
speck_test.cpp:(.text._ZN8CryptoPP8SPECK1283EncD2Ev[_ZN8CryptoPP8SPECK1283EncD5Ev]+0xf): undefined reference to `vtable for CryptoPP::SPECK128::Enc'
speck_test.cpp:(.text._ZN8CryptoPP8SPECK1283EncD2Ev[_ZN8CryptoPP8SPECK1283EncD5Ev]+0x1d): undefined reference to `vtable for CryptoPP::SPECK128::Enc'
/tmp/ccD02cM7.o:speck_test.cpp:(.text._ZN8CryptoPP8SPECK1283EncD2Ev[_ZN8CryptoPP8SPECK1283EncD5Ev]+0x2c): more undefined references to `vtable for CryptoPP::SPECK128::Enc' follow
/tmp/ccD02cM7.o:(.data.rel.ro._ZTVN8CryptoPP16BlockCipherFinalILNS_9CipherDirE0ENS_8SPECK1283EncEEE[_ZTVN8CryptoPP16BlockCipherFinalILNS_9CipherDirE0ENS_8SPECK1283EncEEE]+0x28): undefined reference to `CryptoPP::SPECK128::Base::AlgorithmProvider[abi:cxx11]() const'
/tmp/ccD02cM7.o:(.data.rel.ro._ZTVN8CryptoPP16BlockCipherFinalILNS_9CipherDirE0ENS_8SPECK1283EncEEE[_ZTVN8CryptoPP16BlockCipherFinalILNS_9CipherDirE0ENS_8SPECK1283EncEEE]+0x30): undefined reference to `CryptoPP::SPECK128::Base::UncheckedSetKey(unsigned char const*, unsigned int, CryptoPP::NameValuePairs const&)'
/tmp/ccD02cM7.o:(.data.rel.ro._ZTVN8CryptoPP16BlockCipherFinalILNS_9CipherDirE0ENS_8SPECK1283EncEEE[_ZTVN8CryptoPP16BlockCipherFinalILNS_9CipherDirE0ENS_8SPECK1283EncEEE]+0x38): undefined reference to `CryptoPP::SPECK128::Enc::ProcessAndXorBlock(unsigned char const*, unsigned char const*, unsigned char*) const'
/tmp/ccD02cM7.o:(.data.rel.ro._ZTVN8CryptoPP16BlockCipherFinalILNS_9CipherDirE0ENS_8SPECK1283EncEEE[_ZTVN8CryptoPP16BlockCipherFinalILNS_9CipherDirE0ENS_8SPECK1283EncEEE]+0x40): undefined reference to `CryptoPP::SPECK128::Enc::AdvancedProcessBlocks(unsigned char const*, unsigned char const*, unsigned char*, unsigned long, unsigned int) const'
/tmp/ccD02cM7.o:(.data.rel.ro._ZTVN8CryptoPP16BlockCipherFinalILNS_9CipherDirE0ENS_8SPECK1283EncEEE[_ZTVN8CryptoPP16BlockCipherFinalILNS_9CipherDirE0ENS_8SPECK1283EncEEE]+0xe0): undefined reference to `non-virtual thunk to CryptoPP::SPECK128::Base::UncheckedSetKey(unsigned char const*, unsigned int, CryptoPP::NameValuePairs const&)'
/tmp/ccD02cM7.o:(.data.rel.ro._ZTVN8CryptoPP16BlockCipherFinalILNS_9CipherDirE0ENS_8SPECK1283EncEEE[_ZTVN8CryptoPP16BlockCipherFinalILNS_9CipherDirE0ENS_8SPECK1283EncEEE]+0x128): undefined reference to `non-virtual thunk to CryptoPP::SPECK128::Base::AlgorithmProvider[abi:cxx11]() const'
/tmp/ccD02cM7.o:(.data.rel.ro._ZTVN8CryptoPP16BlockCipherFinalILNS_9CipherDirE0ENS_8SPECK1283EncEEE[_ZTVN8CryptoPP16BlockCipherFinalILNS_9CipherDirE0ENS_8SPECK1283EncEEE]+0x130): undefined reference to `non-virtual thunk to CryptoPP::SPECK128::Enc::ProcessAndXorBlock(unsigned char const*, unsigned char const*, unsigned char*) const'
/tmp/ccD02cM7.o:(.data.rel.ro._ZTVN8CryptoPP16BlockCipherFinalILNS_9CipherDirE0ENS_8SPECK1283EncEEE[_ZTVN8CryptoPP16BlockCipherFinalILNS_9CipherDirE0ENS_8SPECK1283EncEEE]+0x160): undefined reference to `non-virtual thunk to CryptoPP::SPECK128::Enc::AdvancedProcessBlocks(unsigned char const*, unsigned char const*, unsigned char*, unsigned long, unsigned int) const'
/tmp/ccD02cM7.o:(.data.rel.ro._ZTVN8CryptoPP12ClonableImplINS_16BlockCipherFinalILNS_9CipherDirE0ENS_8SPECK1283EncEEES4_EE[_ZTVN8CryptoPP12ClonableImplINS_16BlockCipherFinalILNS_9CipherDirE0ENS_8SPECK1283EncEEES4_EE]+0x28): undefined reference to `CryptoPP::SPECK128::Base::AlgorithmProvider[abi:cxx11]() const'
/tmp/ccD02cM7.o:(.data.rel.ro._ZTVN8CryptoPP12ClonableImplINS_16BlockCipherFinalILNS_9CipherDirE0ENS_8SPECK1283EncEEES4_EE[_ZTVN8CryptoPP12ClonableImplINS_16BlockCipherFinalILNS_9CipherDirE0ENS_8SPECK1283EncEEES4_EE]+0x30): undefined reference to `CryptoPP::SPECK128::Base::UncheckedSetKey(unsigned char const*, unsigned int, CryptoPP::NameValuePairs const&)'
/tmp/ccD02cM7.o:(.data.rel.ro._ZTVN8CryptoPP12ClonableImplINS_16BlockCipherFinalILNS_9CipherDirE0ENS_8SPECK1283EncEEES4_EE[_ZTVN8CryptoPP12ClonableImplINS_16BlockCipherFinalILNS_9CipherDirE0ENS_8SPECK1283EncEEES4_EE]+0x38): undefined reference to `CryptoPP::SPECK128::Enc::ProcessAndXorBlock(unsigned char const*, unsigned char const*, unsigned char*) const'
/tmp/ccD02cM7.o:(.data.rel.ro._ZTVN8CryptoPP12ClonableImplINS_16BlockCipherFinalILNS_9CipherDirE0ENS_8SPECK1283EncEEES4_EE[_ZTVN8CryptoPP12ClonableImplINS_16BlockCipherFinalILNS_9CipherDirE0ENS_8SPECK1283EncEEES4_EE]+0x40): undefined reference to `CryptoPP::SPECK128::Enc::AdvancedProcessBlocks(unsigned char const*, unsigned char const*, unsigned char*, unsigned long, unsigned int) const'
/tmp/ccD02cM7.o:(.data.rel.ro._ZTVN8CryptoPP12ClonableImplINS_16BlockCipherFinalILNS_9CipherDirE0ENS_8SPECK1283EncEEES4_EE[_ZTVN8CryptoPP12ClonableImplINS_16BlockCipherFinalILNS_9CipherDirE0ENS_8SPECK1283EncEEES4_EE]+0xd8): undefined reference to `non-virtual thunk to CryptoPP::SPECK128::Base::UncheckedSetKey(unsigned char const*, unsigned int, CryptoPP::NameValuePairs const&)'
/tmp/ccD02cM7.o:(.data.rel.ro._ZTVN8CryptoPP12ClonableImplINS_16BlockCipherFinalILNS_9CipherDirE0ENS_8SPECK1283EncEEES4_EE[_ZTVN8CryptoPP12ClonableImplINS_16BlockCipherFinalILNS_9CipherDirE0ENS_8SPECK1283EncEEES4_EE]+0x120): undefined reference to `non-virtual thunk to CryptoPP::SPECK128::Base::AlgorithmProvider[abi:cxx11]() const'
/tmp/ccD02cM7.o:(.data.rel.ro._ZTVN8CryptoPP12ClonableImplINS_16BlockCipherFinalILNS_9CipherDirE0ENS_8SPECK1283EncEEES4_EE[_ZTVN8CryptoPP12ClonableImplINS_16BlockCipherFinalILNS_9CipherDirE0ENS_8SPECK1283EncEEES4_EE]+0x128): undefined reference to `non-virtual thunk to CryptoPP::SPECK128::Enc::ProcessAndXorBlock(unsigned char const*, unsigned char const*, unsigned char*) const'
/tmp/ccD02cM7.o:(.data.rel.ro._ZTVN8CryptoPP12ClonableImplINS_16BlockCipherFinalILNS_9CipherDirE0ENS_8SPECK1283EncEEES4_EE[_ZTVN8CryptoPP12ClonableImplINS_16BlockCipherFinalILNS_9CipherDirE0ENS_8SPECK1283EncEEES4_EE]+0x158): undefined reference to `non-virtual thunk to CryptoPP::SPECK128::Enc::AdvancedProcessBlocks(unsigned char const*, unsigned char const*, unsigned char*, unsigned long, unsigned int) const'
/tmp/ccD02cM7.o:(.data.rel.ro._ZTIN8CryptoPP12ClonableImplINS_16BlockCipherFinalILNS_9CipherDirE0ENS_8SPECK1283EncEEES4_EE[_ZTIN8CryptoPP12ClonableImplINS_16BlockCipherFinalILNS_9CipherDirE0ENS_8SPECK1283EncEEES4_EE]+0x10): undefined reference to `typeinfo for CryptoPP::SPECK128::Enc'
/tmp/ccD02cM7.o: In function `CryptoPP::SPECK128::Base::Base(CryptoPP::SPECK128::Base const&)':
speck_test.cpp:(.text._ZN8CryptoPP8SPECK1284BaseC2ERKS1_[_ZN8CryptoPP8SPECK1284BaseC5ERKS1_]+0x41): undefined reference to `vtable for CryptoPP::SPECK128::Base'
speck_test.cpp:(.text._ZN8CryptoPP8SPECK1284BaseC2ERKS1_[_ZN8CryptoPP8SPECK1284BaseC5ERKS1_]+0x4f): undefined reference to `vtable for CryptoPP::SPECK128::Base'
speck_test.cpp:(.text._ZN8CryptoPP8SPECK1284BaseC2ERKS1_[_ZN8CryptoPP8SPECK1284BaseC5ERKS1_]+0x5e): undefined reference to `vtable for CryptoPP::SPECK128::Base'
/tmp/ccD02cM7.o: In function `CryptoPP::SPECK128::Enc::Enc(CryptoPP::SPECK128::Enc const&)':
speck_test.cpp:(.text._ZN8CryptoPP8SPECK1283EncC2ERKS1_[_ZN8CryptoPP8SPECK1283EncC5ERKS1_]+0x26): undefined reference to `vtable for CryptoPP::SPECK128::Enc'
speck_test.cpp:(.text._ZN8CryptoPP8SPECK1283EncC2ERKS1_[_ZN8CryptoPP8SPECK1283EncC5ERKS1_]+0x34): undefined reference to `vtable for CryptoPP::SPECK128::Enc'
speck_test.cpp:(.text._ZN8CryptoPP8SPECK1283EncC2ERKS1_[_ZN8CryptoPP8SPECK1283EncC5ERKS1_]+0x43): undefined reference to `vtable for CryptoPP::SPECK128::Enc'
collect2: error: ld returned 1 exit status
Any help would be very appreciated!
As dave pointed out, the error was arose from the compiler being unable to find CryptoPP.
To fix this, I had to set the LD_LIBRARY_PATH environment variable on Ubuntu to include the path to the library. Then, I had to alter my compiler command to compile my file first, then link the library second, i.e.
g++ -o test.exe speck_test.cpp -L<path-to-cryptopp> -lcryptopp
rather than
g++ -L<path-to-cryptopp> -lcryptopp -o test.exe speck_test.cpp, which was failing.
I am trying to do some tests with TBB at HPCG benchmark. However I didn't compiled the program successfully so far. I am getting errors like these:
src/ComputeSPMV_ref.o: In function `tbb::interface6::internal::start_for<tbb::blocked_range<int>, tbb::internal::parallel_for_body<ComputeSPMV_ref(SparseMatrix_STRUCT const&, Vector_STRUCT&, Vector_STRUCT&)::{lambda(int)#1}, int>, tbb::auto_partitioner const>::~start_for()':
ComputeSPMV_ref.cpp:(.text+0x3): undefined reference to `vtable for tbb::task'
src/ComputeSPMV_ref.o: In function `tbb::interface6::internal::start_for<tbb::blocked_range<int>, tbb::internal::parallel_for_body<ComputeSPMV_ref(SparseMatrix_STRUCT const&, Vector_STRUCT&, Vector_STRUCT&)::{lambda(int)#1}, int>, tbb::auto_partitioner const>::~start_for()':
ComputeSPMV_ref.cpp:(.text+0x23): undefined reference to `vtable for tbb::task'
src/ComputeSPMV_ref.o: In function `tbb::interface6::internal::start_for<tbb::blocked_range<int>, tbb::internal::parallel_for_body<ComputeSPMV_ref(SparseMatrix_STRUCT const&, Vector_STRUCT&, Vector_STRUCT&)::{lambda(int)#1}, int>, tbb::auto_partitioner const>::execute()':
ComputeSPMV_ref.cpp:(.text+0x182): undefined reference to `tbb::internal::allocate_continuation_proxy::allocate(unsigned long) const'
ComputeSPMV_ref.cpp:(.text+0x1ad): undefined reference to `tbb::internal::allocate_child_proxy::allocate(unsigned long) const'
ComputeSPMV_ref.cpp:(.text+0x26b): undefined reference to `tbb::internal::allocate_continuation_proxy::allocate(unsigned long) const'
ComputeSPMV_ref.cpp:(.text+0x296): undefined reference to `tbb::internal::allocate_child_proxy::allocate(unsigned long) const'
ComputeSPMV_ref.cpp:(.text+0x43b): undefined reference to `tbb::internal::allocate_continuation_proxy::allocate(unsigned long) const'
ComputeSPMV_ref.cpp:(.text+0x470): undefined reference to `tbb::internal::allocate_child_proxy::allocate(unsigned long) const'
ComputeSPMV_ref.cpp:(.text+0x52c): undefined reference to `tbb::task_group_context::is_group_execution_cancelled() const'
src/ComputeSPMV_ref.o: In function `ComputeSPMV_ref(SparseMatrix_STRUCT const&, Vector_STRUCT&, Vector_STRUCT&)':
ComputeSPMV_ref.cpp:(.text+0x9d0): undefined reference to `tbb::task_group_context::init()'
ComputeSPMV_ref.cpp:(.text+0x9e9): undefined reference to `tbb::internal::allocate_root_with_context_proxy::allocate(unsigned long) const'
ComputeSPMV_ref.cpp:(.text+0xa29): undefined reference to `tbb::internal::get_initial_auto_partitioner_divisor()'
ComputeSPMV_ref.cpp:(.text+0xa52): undefined reference to `tbb::task_group_context::~task_group_context()'
ComputeSPMV_ref.cpp:(.text+0xad4): undefined reference to `tbb::task_group_context::~task_group_context()'
ComputeSPMV_ref.cpp:(.text+0xae0): undefined reference to `vtable for tbb::task'
ComputeSPMV_ref.cpp:(.text+0xaee): undefined reference to `tbb::internal::allocate_root_with_context_proxy::free(tbb::task&) const'
src/ComputeSPMV_ref.o: In function `tbb::interface6::internal::flag_task::~flag_task()':
ComputeSPMV_ref.cpp:(.text._ZN3tbb10interface68internal9flag_taskD2Ev[_ZN3tbb10interface68internal9flag_taskD5Ev]+0x3): undefined reference to `vtable for tbb::task'
src/ComputeSPMV_ref.o: In function `tbb::interface6::internal::signal_task::~signal_task()':
ComputeSPMV_ref.cpp:(.text._ZN3tbb10interface68internal11signal_taskD2Ev[_ZN3tbb10interface68internal11signal_taskD5Ev]+0x3): undefined reference to `vtable for tbb::task'
src/ComputeSPMV_ref.o: In function `tbb::interface6::internal::flag_task::~flag_task()':
ComputeSPMV_ref.cpp:(.text._ZN3tbb10interface68internal9flag_taskD0Ev[_ZN3tbb10interface68internal9flag_taskD0Ev]+0x3): undefined reference to `vtable for tbb::task'
src/ComputeSPMV_ref.o: In function `tbb::interface6::internal::signal_task::~signal_task()':
ComputeSPMV_ref.cpp:(.text._ZN3tbb10interface68internal11signal_taskD0Ev[_ZN3tbb10interface68internal11signal_taskD0Ev]+0x3): undefined reference to `vtable for tbb::task'
src/ComputeSPMV_ref.o:(.rodata+0x110): undefined reference to `typeinfo for tbb::task'
src/ComputeSPMV_ref.o:(.rodata._ZTIN3tbb10interface68internal11signal_taskE[_ZTIN3tbb10interface68internal11signal_taskE]+0x10): undefined reference to `typeinfo for tbb::task'
src/ComputeSPMV_ref.o:(.rodata._ZTIN3tbb10interface68internal9flag_taskE[_ZTIN3tbb10interface68internal9flag_taskE]+0x10): undefined reference to `typeinfo for tbb::task'
src/ComputeSPMV_ref.o:(.rodata._ZTVN3tbb10interface68internal9flag_taskE[_ZTVN3tbb10interface68internal9flag_taskE]+0x28): undefined reference to `tbb::task::note_affinity(unsigned short)'
src/ComputeSPMV_ref.o:(.rodata._ZTVN3tbb10interface68internal11signal_taskE[_ZTVN3tbb10interface68internal11signal_taskE]+0x28): undefined reference to `tbb::task::note_affinity(unsigned short)'
collect2: error: ld returned 1 exit status
make: *** [bin/xhpcg] Error 1
Compile instruction look like this:
make
/usr/bin/g++ -DHPCG_NOMPI -DHPCG_NOOPENMP -I./src -I./src/GCC_TBB -O3 -ltbb -std=c++11 -ffast-math -ftree-vectorize -ftree-vectorizer-verbose=0 -fopenmp testing/main.o src/CG.o src/CG_ref.o ....
I downloaded and install latest source code from Intel.Also I already use -ltbb and -std=c++11 at compile time and I include tbb files inside my code. I can't figure out the problem so far. Does anyone face anything like this before with Intel TBB? I am assuming that is something with the linking of library but I can't figure it out
Try to insert "-ltbb -std=c++11" just before -o and it should work!
Patroklos Patroklou's answer didn't help, so I put -ltbb at the end of my command and it worked.
Ubuntu 20.04
g++-9, libstdc++-9-dev
I'm trying to compile the message pack (http://msgpack.org/) example code and keep getting these errors which I can't get to the bottom of:
g++ -o"MsgPack2" ./src/MsgPack2.o -lmsgpack -lmsgpackc
./src/MsgPack2.o: In function `main':
/mnt/eoh/workspace/MsgPack2/Debug/../src/MsgPack2.cpp:38:
undefined reference to msgpack::rpc::server::listen(std::basic_string<char,
std::char_traits<char>, std::allocator<char> > const&, unsigned
short)'
./src/MsgPack2.o: In functionloop':
/usr/local/include/msgpack/rpc/loop.h:30: undefined reference to
mp::wavy::loop::loop()'
./src/MsgPack2.o: In functionbase':
/usr/local/include/msgpack/rpc/server.h:59: undefined reference to
msgpack::rpc::server::server(msgpack::rpc::loop)'
/usr/local/include/msgpack/rpc/server.h:59: undefined reference to
msgpack::rpc::server::serve(msgpack::rpc::dispatcher*)'
/usr/local/include/msgpack/rpc/server.h:59: undefined reference to
msgpack::rpc::server::~server()'
./src/MsgPack2.o: In function~base':
/usr/local/include/msgpack/rpc/server.h:64: undefined reference to
msgpack::rpc::server::~server()'
./src/MsgPack2.o: In function
myserver::dispatch(msgpack::rpc::request)':
/mnt/eoh/workspace/MsgPack2/Debug/../src/MsgPack2.cpp:14:
undefined reference to msgpack::rpc::request::method()'
/mnt/eoh/workspace/MsgPack2/Debug/../src/MsgPack2.cpp:18:
undefined reference tomsgpack::rpc::request::params()'
./src/MsgPack2.o: In function
msgpack::rpc::loop_util<msgpack::rpc::session_pool>::run(unsigned
long)':
/usr/local/include/msgpack/rpc/loop_util.h:34: undefined reference
tomsgpack::rpc::session_pool::get_loop()'
/usr/local/include/msgpack/rpc/loop_util.h:34: undefined reference
to mp::wavy::loop::run(unsigned long)'
./src/MsgPack2.o: In functionvoid
msgpack::rpc::request::call(int&,
msgpack::type::nil&)':
/usr/local/include/msgpack/rpc/request.h:119: undefined reference
to msgpack::rpc::request::is_sent() const'
/usr/local/include/msgpack/rpc/request.h:122: undefined reference
tomsgpack::rpc::request::get_msgid() const'
/usr/local/include/msgpack/rpc/request.h:125: undefined reference
to msgpack::rpc::request::send_data(msgpack::sbuffer*)'
./src/MsgPack2.o: In functionvoid
msgpack::rpc::request::call(msgpack::type::nil&, unsigned char&)':
/usr/local/include/msgpack/rpc/request.h:119: undefined reference
to msgpack::rpc::request::is_sent() const'
/usr/local/include/msgpack/rpc/request.h:122: undefined reference
tomsgpack::rpc::request::get_msgid() const'
/usr/local/include/msgpack/rpc/request.h:125: undefined reference
to msgpack::rpc::request::send_data(msgpack::sbuffer*)'
./src/MsgPack2.o: In functionvoid
msgpack::rpc::request::call, std::allocator >
(msgpack::type::nil&, std::basic_string,
std::allocator >&)':
/usr/local/include/msgpack/rpc/request.h:119: undefined reference
to msgpack::rpc::request::is_sent() const'
/usr/local/include/msgpack/rpc/request.h:122: undefined reference
tomsgpack::rpc::request::get_msgid() const'
/usr/local/include/msgpack/rpc/request.h:125: undefined reference
to msgpack::rpc::request::send_data(msgpack::sbuffer*)'
./src/MsgPack2.o: In function__shared_count':
/usr/include/c++/4.5/tr1/shared_ptr.h:121: undefined reference to
mp::wavy::loop::~loop()'
./src/MsgPack2.o: In function
std::tr1::_Sp_deleter::operator()(mp::wavy::loop*)
const':
/usr/include/c++/4.5/tr1/shared_ptr.h:99: undefined reference to
`mp::wavy::loop::~loop()'
collect2: ld returned 1 exit status
make: * [MsgPack2] Error 1
And here is the code:
#include <msgpack/rpc/server.h>
class myserver : public msgpack::rpc::server::base {
public:
void add(msgpack::rpc::request req, int a1, int a2)
{
req.result(a1 + a2);
}
public:
void dispatch(msgpack::rpc::request req)
try {
std::string method;
req.method().convert(&method);
if(method == "add") {
msgpack::type::tuple<int, int> params;
req.params().convert(¶ms);
add(req, params.get<0>(), params.get<1>());
} else {
req.error(msgpack::rpc::NO_METHOD_ERROR);
}
} catch (msgpack::type_error& e) {
req.error(msgpack::rpc::ARGUMENT_ERROR);
return;
} catch (std::exception& e) {
req.error(std::string(e.what()));
return;
}
};
int main(void)
{
myserver svr;
svr.instance.listen("127.0.0.1", 80800);
svr.instance.run(4); // run 4 threads
return 0;
}
If anyone has any ideas, it would be greatly appreciated.
Many thanks in advance,
You need -lmsgpack-rpc.
[Side note: 80800 is not a valid port.]