I am trying to compile my own ANTLR4 parser in C++
#include "nibble.h"
using namespace antlr4;
using namespace nibble;
int main(int argc, const char* argv[]){
const std::string file_name = argv[1];
ANTLRInputStream input(file_name);
return 0;
}
but when I compile it by typing g++ nibblec.cpp -o nibblec -I /usr/local/include/antlr4-runtime I get
/usr/bin/ld: /tmp/ccqG8KT4.o: warning: relocation against '_ZTVN6antlr416ANTLRInputStreamE' in read-only section '.text._ZN6antlr416ANTLRInputStreamD2Ev[_ZN6antlr416ANTLRInputStreamD5Ev]'
/usr/bin/ld: /tmp/ccqG8KT4.o: in function 'main':
nibblec.cpp:(.text+0x64): undefined reference to 'antlr4::ANTLRInputStream::ANTLRInputStream(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
/usr/bin/ld: /tmp/ccqG8KT4.o: in function 'antlr4::ANTLRInputStream::~ANTLRInputStream()':
nibblec.cpp:(.text._ZN6antlr416ANTLRInputStreamD2Ev[_ZN6antlr416ANTLRInputStreamD5Ev]+0xf): undefined reference to `vtable for antlr4::ANTLRInputStream'
/usr/bin/ld: nibblec.cpp:(.text._ZN6antlr416ANTLRInputStreamD2Ev[_ZN6antlr416ANTLRInputStreamD5Ev]+0x42): undefined reference to 'antlr4::CharStream::~CharStream()'
/usr/bin/ld: warning: creating DT_TEXTREL in a PIE
collect2: error: ld returned 1 exit status
What is ld? And why I get all this warnings? Am I doing something wrong with ANTLR4?
EDIT: I am using ANTLR 4.9.1
You are not linking to ANTLR. Likely you need to add -lantlr to your compile flags (although the exact spelling might be different, and you may need to specify a library directory containing ANTLR).
Related
I am trying to create executable of following code taken from here:
#include <iostream>
#include <opencv2/opencv.hpp>
#include <opencv2/imgcodecs.hpp>
using namespace cv;
using namespace std;
// Driver code
int main(int argc, char** argv)
{
// Read the image file as // imread("default.jpg");
Mat image = imread("barchart.png", IMREAD_GRAYSCALE);
// Error Handling
if (image.empty()) {
cout << "Image File Not Found" << endl;
// wait for any key press
cin.get();
return -1;
}
// Show Image inside a window with the name provided
imshow("Window Name", image);
// Wait for any keystroke
waitKey(0);
return 0;
}
It compiles all right with command g++ showimage.cpp -c -I /usr/include/opencv4 and creates an showimage.o file
However, following command to link it gives error:
g++ showimage.o -l:libopencv_imgcodecs.a
...
... (lot of output)
/usr/bin/ld: showimage.o: in function `main':
showimage.cpp:(.text+0x83): undefined reference to `cv::Mat::empty() const'
/usr/bin/ld: showimage.cpp:(.text+0x10e): undefined reference to `cv::imshow(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, cv::_InputArray const&)'
/usr/bin/ld: showimage.cpp:(.text+0x13c): undefined reference to `cv::waitKey(int)'
/usr/bin/ld: showimage.cpp:(.text+0x150): undefined reference to `cv::Mat::~Mat()'
/usr/bin/ld: showimage.cpp:(.text+0x1c2): undefined reference to `cv::Mat::~Mat()'
collect2: error: ld returned 1 exit status
I also tried following option:
g++ showimage.o -L /usr/lib/x86_64-linux-gnu
g++ showimage.o -L libopencv
g++ showimage.o -L opencv
But none is not working.
Where is the problem and how can it be solved?
I installed pcapplusplus on Ubuntu (Downloaded package from here: https://github.com/seladb/PcapPlusPlus/releases/tag/v21.11). The example that was in the archive compiles and works, everything is fine with it! But when I try to include the library in my project using CMake nothing works.
I write a line in CMakeLists.txt file:
include_directories("/usr/local/include/pcapplusplus")
After that, the header files are connected to the project. However, the project does not compile, various errors appear depending on the functions that I use. Most likely the linker does not see the files: libCommon++.a, libPacket++.a, and libPcap++.a.
I tried to connect them like this:
target_link_libraries(${PROJECT_NAME} libCommon++.a libPacket++.a libPcap++.a)
But it did not help.
Tried this:
find_package(pcapplusplus REQUIRED)
include_directories(${PCAPPLUSPLUS_INCLUDE_DIRS})
This didn't help either.
In fact, other people have already encountered such a problem, for example, netleap tom wrote about this on the StackOverflow. cmake linking against static libraries - do you have to tell cmake where to look?
However, no one there suggested a solution to him. I hope someone will tell me what to do.
udp.
Hello World from here for example:
#include <IPv4Layer.h>
#include <Packet.h>
#include <PcapFileDevice.h>
int main(int argc, char* argv[])
{
pcpp::PcapFileReaderDevice reader("1_packet.pcap");
if (!reader.open())
{
printf("Error opening the pcap file\n");
return 1;
}
pcpp::RawPacket rawPacket;
if (!reader.getNextPacket(rawPacket))
{
printf("Couldn't read the first packet in the file\n");
return 1;
}
if (parsedPacket.isPacketOfType(pcpp::IPv4))
{
pcpp::IPv4Address srcIP = parsedPacket.getLayerOfType<pcpp::IPv4Layer>()->getSrcIpAddress();
pcpp::IPv4Address destIP = parsedPacket.getLayerOfType<pcpp::IPv4Layer>()->getDstIpAddress();
printf("Source IP is '%s'; Dest IP is '%s'\n", srcIP.toString().c_str(), destIP.toString().c_str());
}
reader.close();
return 0;
}
If I add only this to CMake:
include_directories("/usr/local/include/pcapplusplus")
I have the following errors:
/usr/bin/ld: CMakeFiles/test.dir/main.cpp.o: in function `pcpp::Packet::~Packet()':
main.cpp:(.text._ZN4pcpp6PacketD2Ev[_ZN4pcpp6PacketD5Ev]+0x17): undefined reference to `pcpp::Packet::destructPacketData()'
/usr/bin/ld: CMakeFiles/test.dir/main.cpp.o: in function `pcpp::Packet::~Packet()':
main.cpp:(.text._ZN4pcpp6PacketD0Ev[_ZN4pcpp6PacketD5Ev]+0x17): undefined reference to `pcpp::Packet::destructPacketData()'
/usr/bin/ld: CMakeFiles/test.dir/main.cpp.o: in function `pcpp::IPv4Layer* pcpp::Packet::getLayerOfType<pcpp::IPv4Layer>(bool) const':
main.cpp:(.text._ZNK4pcpp6Packet14getLayerOfTypeINS_9IPv4LayerEEEPT_b[_ZNK4pcpp6Packet14getLayerOfTypeINS_9IPv4LayerEEEPT_b]+0x1b): undefined reference to `typeinfo for pcpp::IPv4Layer'
/usr/bin/ld: main.cpp:(.text._ZNK4pcpp6Packet14getLayerOfTypeINS_9IPv4LayerEEEPT_b[_ZNK4pcpp6Packet14getLayerOfTypeINS_9IPv4LayerEEEPT_b]+0x22): undefined reference to `typeinfo for pcpp::Layer'
/usr/bin/ld: main.cpp:(.text._ZNK4pcpp6Packet14getLayerOfTypeINS_9IPv4LayerEEEPT_b[_ZNK4pcpp6Packet14getLayerOfTypeINS_9IPv4LayerEEEPT_b]+0x4e): undefined reference to `typeinfo for pcpp::IPv4Layer'
/usr/bin/ld: main.cpp:(.text._ZNK4pcpp6Packet14getLayerOfTypeINS_9IPv4LayerEEEPT_b[_ZNK4pcpp6Packet14getLayerOfTypeINS_9IPv4LayerEEEPT_b]+0x55): undefined reference to `typeinfo for pcpp::Layer'
/usr/bin/ld: CMakeFiles/test.dir/main.cpp.o: in function `main.cold':
main.cpp:(.text.unlikely+0x58): undefined reference to `pcpp::Packet::destructPacketData()'
/usr/bin/ld: main.cpp:(.text.unlikely+0x63): undefined reference to `pcpp::RawPacket::~RawPacket()'
/usr/bin/ld: main.cpp:(.text.unlikely+0x8a): undefined reference to `pcpp::IFileDevice::~IFileDevice()'
More here: image.
If I add this to CMake:
target_link_libraries(${PROJECT_NAME} libCommon++.a libPacket++.a libPcap++.a)
I have the following errors (first five):
/usr/bin/ld: /usr/local/lib/libPacket++.a(EthLayer.o): in function `pcpp::EthLayer::toString[abi:cxx11]() const':
/tmp/cirrus-ci-build/PcapPlusPlus/Packet++/src/EthLayer.cpp:104: undefined reference to `pcpp::MacAddress::toString[abi:cxx11]() const'
/usr/bin/ld: /tmp/cirrus-ci-build/PcapPlusPlus/Packet++/src/EthLayer.cpp:104: undefined reference to `pcpp::MacAddress::toString[abi:cxx11]() const'
/usr/bin/ld: /usr/local/lib/libPacket++.a(EthDot3Layer.o): in function `pcpp::EthDot3Layer::toString[abi:cxx11]() const':
/tmp/cirrus-ci-build/PcapPlusPlus/Packet++/src/EthDot3Layer.cpp:36: undefined reference to `pcpp::MacAddress::toString[abi:cxx11]() const'
/usr/bin/ld: /tmp/cirrus-ci-build/PcapPlusPlus/Packet++/src/EthDot3Layer.cpp:36: undefined reference to `pcpp::MacAddress::toString[abi:cxx11]() const'
/usr/bin/ld: /usr/local/lib/libPacket++.a(DhcpLayer.o): in function `pcpp::DhcpLayer::getClientHardwareAddress() const':
/tmp/cirrus-ci-build/PcapPlusPlus/Packet++/src/DhcpLayer.cpp:83: undefined reference to `pcpp::MacAddress::Zero'
/usr/bin/ld: /usr/local/lib/libPacket++.a(PayloadLayer.o): in function `pcpp::PayloadLayer::PayloadLayer(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)':
/tmp/cirrus-ci-build/PcapPlusPlus/Packet++/src/PayloadLayer.cpp:24: undefined reference to `pcpp::hexStringToByteArray(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, unsigned char*, unsigned long)'
More here: image2
undefined reference to `pcpp::IFileReaderDevice::IFileReaderDevice(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
/usr/bin/ld: main.cpp:(.text.startup+0x63): undefined reference to `vtable for pcpp::PcapFileReaderDevice'
/usr/bin/ld: main.cpp:(.text.startup+0xb5): undefined reference to `pcpp::IFileDevice::~IFileDevice()'
/usr/bin/ld: CMakeFiles/test.dir/main.cpp.o:(.data.rel.ro._ZTIN4pcpp17IFileReaderDeviceE[_ZTIN4pcpp17IFileReaderDeviceE]+0x10): undefined reference to `typeinfo for pcpp::IFileDevice'
/usr/bin/ld: CMakeFiles/test.dir/main.cpp.o:(.data.rel.ro._ZTVN4pcpp17IFileReaderDeviceE[_ZTVN4pcpp17IFileReaderDeviceE]+0x28): undefined reference to `pcpp::IFileDevice::close()'
/usr/bin/ld: CMakeFiles/test.dir/main.cpp.o:(.data.rel.ro._ZTVN4pcpp17IFileReaderDeviceE[_ZTVN4pcpp17IFileReaderDeviceE]+0x38): undefined reference to `pcpp::IPcapDevice::setFilter(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >)'
/usr/bin/ld: CMakeFiles/test.dir/main.cpp.o:(.data.rel.ro._ZTVN4pcpp17IFileReaderDeviceE[_ZTVN4pcpp17IFileReaderDeviceE]+0x40): undefined reference to `pcpp::IPcapDevice::clearFilter()'
/usr/bin/ld: CMakeFiles/test.dir/main.cpp.o:(.data.rel.ro._ZTVN4pcpp17IFileReaderDeviceE[_ZTVN4pcpp17IFileReaderDeviceE]+0x78): undefined reference to `non-virtual thunk to pcpp::IPcapDevice::setFilter(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >)'
/usr/bin/ld: CMakeFiles/test.dir/main.cpp.o:(.data.rel.ro._ZTVN4pcpp17IFileReaderDeviceE[_ZTVN4pcpp17IFileReaderDeviceE]+0x80): undefined reference to `non-virtual thunk to pcpp::IPcapDevice::clearFilter()'
collect2: error: ld returned 1 exit status
try this
target_link_libraries(${PROJECT_NAME} Pcap++ Packet++ Common++ pcap pthread)
this is the order as listed in the pcapplusplus example mk file /usr/local/etc/PcapPlusPlus.mk
Solution: https://github.com/gleb-kun/pcappp_hw
As expected, errors occurred due to incorrect library connection using CMake.
A file FindPcapPlusPlus.cmake is required to connect. Add the following lines to the main file CMakeLists.txt:
find_package(PcapPlusPlus REQUIRED)
target_link_libraries(${PROJECT_NAME} ${PcapPlusPlus_LIBRARIES})
FindPcapPlusPlus.cmake file contents:
if (PC_PcapPlusPlus_INCLUDEDIR AND PC_PcapPlusPlus_LIBDIR)
set(PcapPlusPlus_FIND_QUIETLY TRUE)
endif ()
find_package(PkgConfig REQUIRED)
pkg_check_modules(PC_PcapPlusPlus REQUIRED PcapPlusPlus)
set(PcapPlusPlus_VERSION ${PC_PcapPlusPlus_VERSION})
mark_as_advanced(PcapPlusPlus_INCLUDE_DIR PcapPlusPlus_LIBRARY)
foreach (LIB_NAME ${PC_PcapPlusPlus_LIBRARIES})
find_library(${LIB_NAME}_PATH ${LIB_NAME} HINTS ${PC_PcapPlusPlus_LIBDIR})
if (${LIB_NAME}_PATH)
list(APPEND PcapPlusPlus_LIBS ${${LIB_NAME}_PATH})
endif ()
endforeach ()
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(PcapPlusPlus
REQUIRED_VARS PC_PcapPlusPlus_INCLUDEDIR PC_PcapPlusPlus_LIBDIR
VERSION_VAR PcapPlusPlus_VERSION
)
if (PcapPlusPlus_FOUND)
set(PcapPlusPlus_INCLUDE_DIRS ${PC_PcapPlusPlus_INCLUDEDIR})
set(PcapPlusPlus_LIBRARIES ${PcapPlusPlus_LIBS})
endif ()
if (PcapPlusPlus_FOUND AND NOT TARGET PcapPlusPlus::PcapPlusPlus)
add_library(PcapPlusPlus::PcapPlusPlus INTERFACE IMPORTED)
set_target_properties(PcapPlusPlus::PcapPlusPlus PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES "${PcapPlusPlus_INCLUDE_DIRS}"
INTERFACE_LINK_LIBRARIES "${PcapPlusPlus_LIBRARIES}"
INTERFACE_COMPILE_FLAGS "${PC_PcapPlusPlus_CFLAGS}"
)
endif ()
Here is a simple C++ program and I believe it should work. My code is reference from here.
Convert command line argument to string
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <vector>
#include <iostream>
//using namespace std;
int main(int argc, char *argv[]){
std::string boss;
//printf("PROGRAM NAME: %s\n", argv[0]);
if (argc > 1){
//printf("%s\n",&argv[1][0]);
printf("%s\n",argv[1]);
boss = argv[1];
}
}
When Compile it come out the problem:
/tmp/cctYLBpB.o: In function main':
testarg.cpp:(.text+0x1c): undefined reference tostd::basic_string, std::allocator >::basic_string()'
testarg.cpp:(.text+0x58): undefined reference to std::string::operator=(char const*)'
testarg.cpp:(.text+0x64): undefined reference tostd::basic_string, std::allocator >::~basic_string()'
testarg.cpp:(.text+0x78): undefined reference to std::basic_string<char, std::char_traits<char>, std::allocator<char> >::~basic_string()'
testarg.cpp:(.text+0x7c): undefined reference to__cxa_end_cleanup'
/tmp/cctYLBpB.o: In function __static_initialization_and_destruction_0(int, int)':
testarg.cpp:(.text+0xc0): undefined reference tostd::ios_base::Init::Init()'
testarg.cpp:(.text+0xe4): undefined reference to std::ios_base::Init::~Init()'
/tmp/cctYLBpB.o:(.ARM.extab+0x0): undefined reference to__gxx_personality_v0'
collect2: error: ld returned 1 exit status
Did you guys expert had seen any problem on it ? I have no idea ...
When you use gcc to build your program, the standard C++ libraries are not used by the linker. Use g++ instead. Add -Wall for good measure. You will get useful warning messages that will help you find problems at compile time rather than find them at run time.
g++ filename.cpp -Wall -o testc
I'm trying to test a motor control lib I've wrote with googletest but I'm not been to compile the test's codes.
The test are in a file named test.cpp such as the following:
#include <gtest/gtest.h>
#include "../motor.hpp"
TEST(constructorTest, contructorDefault)
{
}
And I've put a the tests main function in an other file named main.cpp.
#include <gtest/gtest.h>
#include "../motor.hpp"
int main(int argc, char* argv[])
{
::testing::InitGoogleTest(&argc,argv);
RUN_ALL_TESTS();
}
To compile I've excecuted the following line:
g++ main.cpp test.cpp ../motor.cpp -o test
The result I get is:
main.cpp:8:17: warning: ignoring return value of ‘int RUN_ALL_TESTS()’, declared with attribute warn_unused_result [-Wunused-result]
RUN_ALL_TESTS();
^
/tmp/ccZ5BaBH.o: In function `main':
main.cpp:(.text+0x1e): undefined reference to `testing::InitGoogleTest(int*, char**)'
/tmp/ccZ5BaBH.o: In function `RUN_ALL_TESTS()':
main.cpp:(.text._Z13RUN_ALL_TESTSv[_Z13RUN_ALL_TESTSv]+0x5): undefined reference to `testing::UnitTest::GetInstance()'
main.cpp:(.text._Z13RUN_ALL_TESTSv[_Z13RUN_ALL_TESTSv]+0xd): undefined reference to `testing::UnitTest::Run()'
/tmp/ccFuAMp3.o: In function `__static_initialization_and_destruction_0(int, int)':
test.cpp:(.text+0x5c): undefined reference to `testing::internal::GetTestTypeId()'
test.cpp:(.text+0x84): undefined reference to `testing::internal::MakeAndRegisterTestInfo(char const*, char const*, char const*, char const*, void const*, void (*)(), void (*)(), testing::internal::TestFactoryBase*)'
/tmp/ccFuAMp3.o: In function `constructorTest_contructorDefault_Test::constructorTest_contructorDefault_Test()':
test.cpp:(.text._ZN38constructorTest_contructorDefault_TestC2Ev[_ZN38constructorTest_contructorDefault_TestC5Ev]+0x14): undefined reference to `testing::Test::Test()'
/tmp/ccFuAMp3.o:(.rodata._ZTV38constructorTest_contructorDefault_Test[_ZTV38constructorTest_contructorDefault_Test]+0x20): undefined reference to `testing::Test::SetUp()'
/tmp/ccFuAMp3.o:(.rodata._ZTV38constructorTest_contructorDefault_Test[_ZTV38constructorTest_contructorDefault_Test]+0x28): undefined reference to `testing::Test::TearDown()'
/tmp/ccFuAMp3.o: In function `constructorTest_contructorDefault_Test::~constructorTest_contructorDefault_Test()':
test.cpp:(.text._ZN38constructorTest_contructorDefault_TestD2Ev[_ZN38constructorTest_contructorDefault_TestD5Ev]+0x1f): undefined reference to `testing::Test::~Test()'
/tmp/ccFuAMp3.o:(.rodata._ZTI38constructorTest_contructorDefault_Test[_ZTI38constructorTest_contructorDefault_Test]+0x10): undefined reference to `typeinfo for testing::Test'
collect2: error: ld returned 1 exit status
If I remove the test.cpp of the compiling line I get this other result:
main.cpp: In function ‘int main(int, char**)’:
main.cpp:8:17: warning: ignoring return value of ‘int RUN_ALL_TESTS()’, declared with attribute warn_unused_result [-Wunused-result]
RUN_ALL_TESTS();
^
/tmp/cc61r6NU.o: In function `main':
main.cpp:(.text+0x1e): undefined reference to `testing::InitGoogleTest(int*, char**)'
/tmp/cc61r6NU.o: In function `RUN_ALL_TESTS()':
main.cpp:(.text._Z13RUN_ALL_TESTSv[_Z13RUN_ALL_TESTSv]+0x5): undefined reference to `testing::UnitTest::GetInstance()'
main.cpp:(.text._Z13RUN_ALL_TESTSv[_Z13RUN_ALL_TESTSv]+0xd): undefined reference to `testing::UnitTest::Run()'
collect2: error: ld returned 1 exit status
What am I doing wrong?
EDIT
Look like What #RippeR says is right, but now I getting the following error:
/usr/lib/gcc/x86_64-linux-gnu/4.9/../../../../lib/libgtest.so: undefined reference to `pthread_key_create'
/usr/lib/gcc/x86_64-linux-gnu/4.9/../../../../lib/libgtest.so: undefined reference to `pthread_getspecific'
/usr/lib/gcc/x86_64-linux-gnu/4.9/../../../../lib/libgtest.so: undefined reference to `pthread_key_delete'
/usr/lib/gcc/x86_64-linux-gnu/4.9/../../../../lib/libgtest.so: undefined reference to `pthread_setspecific'
Do I have to include something else?
Solution
The problem was solve adding the -lpthread flag to compile the test.
Try:
g++ main.cpp test.cpp ../motor.cpp -o test -lgtest -lpthread
You have to link external libraries you are using. Including headers is not enough (unless library is header-only). If this solutions doesn't work, or you get error about gcc cannot find lgtest or gtest then you need to install it first (see here).
Also, note that RUN_ALL_TESTS(); returns a value, so your main() should look like:
#include <gtest/gtest.h>
#include "../motor.hpp"
int main(int argc, char* argv[])
{
::testing::InitGoogleTest(&argc,argv);
return RUN_ALL_TESTS();
}
I've updated answer (check 2nd line) to cover your next problem. This is same as before, you really should start to FIND answers to your problems instead of just asking and waiting for someone to do all the work for you.
i have the following code:
#include "Poco/Net/DatagramSocket.h"
#include "Poco/Net/SocketAddress.h"
#include "Poco/Timestamp.h"
#include "Poco/DateTimeFormatter.h"
int main(int argc, char** argv)
{
Poco::Net::SocketAddress sa("127.0.0.1", 8080);
Poco::Net::DatagramSocket dgs(sa);
std::string syslogMsg;
Poco::Timestamp now;
syslogMsg = Poco::DateTimeFormatter::format(now,
"<14>%w %f %H:%M:%S Hello, world!");
return 0;
}
and after compiling i get the following errors:
/tmp/cc38RdWw.o: In function `main':
pocoSender.cpp:(.text+0x4d): undefined reference to `Poco::Net::SocketAddress::SocketAddress(std::string const&, unsigned short)'
pocoSender.cpp:(.text+0x7d): undefined reference to `Poco::Net::DatagramSocket::DatagramSocket(Poco::Net::SocketAddress const&, bool)'
pocoSender.cpp:(.text+0x93): undefined reference to `Poco::Timestamp::Timestamp()'
pocoSender.cpp:(.text+0x11f): undefined reference to `Poco::Timestamp::~Timestamp()'
pocoSender.cpp:(.text+0x135): undefined reference to `Poco::Net::DatagramSocket::~DatagramSocket()'
pocoSender.cpp:(.text+0x140): undefined reference to `Poco::Net::SocketAddress::~SocketAddress()'
pocoSender.cpp:(.text+0x163): undefined reference to `Poco::Net::SocketAddress::~SocketAddress()'
pocoSender.cpp:(.text+0x1ac): undefined reference to `Poco::Timestamp::~Timestamp()'
pocoSender.cpp:(.text+0x1ca): undefined reference to `Poco::Net::DatagramSocket::~DatagramSocket()'
pocoSender.cpp:(.text+0x1d9): undefined reference to `Poco::Net::SocketAddress::~SocketAddress()'
/tmp/cc38RdWw.o: In function `Poco::DateTimeFormatter::format(Poco::Timestamp const&, std::string const&, int)':
pocoSender.cpp:(.text._ZN4Poco17DateTimeFormatter6formatERKNS_9TimestampERKSsi[_ZN4Poco17DateTimeFormatter6formatERKNS_9TimestampERKSsi]+0x15): undefined reference to `Poco::DateTime::DateTime(Poco::Timestamp const&)'
pocoSender.cpp:(.text._ZN4Poco17DateTimeFormatter6formatERKNS_9TimestampERKSsi[_ZN4Poco17DateTimeFormatter6formatERKNS_9TimestampERKSsi]+0x43): undefined reference to `Poco::DateTime::~DateTime()'
pocoSender.cpp:(.text._ZN4Poco17DateTimeFormatter6formatERKNS_9TimestampERKSsi[_ZN4Poco17DateTimeFormatter6formatERKNS_9TimestampERKSsi]+0x52): undefined reference to `Poco::DateTime::~DateTime()'
/tmp/cc38RdWw.o: In function `Poco::DateTimeFormatter::format(Poco::DateTime const&, std::string const&, int)':
pocoSender.cpp:(.text._ZN4Poco17DateTimeFormatter6formatERKNS_8DateTimeERKSsi[_ZN4Poco17DateTimeFormatter6formatERKNS_8DateTimeERKSsi]+0x41): undefined reference to `Poco::DateTimeFormatter::append(std::string&, Poco::DateTime const&, std::string const&, int)'
collect2: error: ld returned 1 exit status
i use the following commandline to compile:
g++ -L/usr/local/lib -lPocoUtil -lPocoFoundation -lPocoNet pocoSender.cpp -o hello
please do not mark the question as duplicate as i have included the required libraries using g++ flags, but i am still getting these errors.
It means that the compiler or linker did not find implementations of these functions. It seems that the corresponding libraries or object modules were not included in building of the project.