Undefined refrence with wxWidgets in Code::Blocks - codeblocks

I have downloaded the pre-built binaries of wxWidgets 3.1.2 and placed it in my minGW folder. In Code::Blocks I run the wizard for creating the wxWidgets application just to check whether the wxWidgets is working. I started building the project and showed me some series of errors I rectified it.
But I couldn't get these errors:
||=== Build: Debug in x (compiler: GNU GCC Compiler) ===|
c:\mingw\bin\..\lib\gcc\x86_64-w64-mingw32\8.2.0\..\..\..\..\x86_64-w64-mingw32\bin\ld.exe: obj\Debug\xApp.o||in function `WinMain':|
C:\Users\Aadhish\Documents\Projects\x\xApp.cpp|17|undefined reference to `__imp__Z7wxEntryP11HINSTANCE__S0_Pci'|
c:\mingw\bin\..\lib\gcc\x86_64-w64-mingw32\8.2.0\..\..\..\..\x86_64-w64-mingw32\bin\ld.exe: obj\Debug\xApp.o||in function `xApp::OnInit()':|
C:\Users\Aadhish\Documents\Projects\x\xApp.cpp|23|undefined reference to `__imp__Z22wxInitAllImageHandlersv'|
c:\mingw\bin\..\lib\gcc\x86_64-w64-mingw32\8.2.0\..\..\..\..\x86_64-w64-mingw32\bin\ld.exe: obj\Debug\xApp.o||in function `xApp::xApp()':|
C:\Users\Aadhish\Documents\Projects\x\xApp.h|15|undefined reference to `__imp__ZN5wxAppC2Ev'|
c:\mingw\bin\..\lib\gcc\x86_64-w64-mingw32\8.2.0\..\..\..\..\x86_64-w64-mingw32\bin\ld.exe: obj\Debug\xApp.o:xApp.cpp:(.rdata$_ZTV4xApp[_ZTV4xApp]+0x10)||undefined reference to `wxApp::GetClassInfo() const'|
c:\mingw\bin\..\lib\gcc\x86_64-w64-mingw32\8.2.0\..\..\..\..\x86_64-w64-mingw32\bin\ld.exe: obj\Debug\xApp.o:xApp.cpp:(.rdata$_ZTV4xApp[_ZTV4xApp]+0x80)||undefined reference to `wxApp::GetEventTable() const'|
c:\mingw\bin\..\lib\gcc\x86_64-w64-mingw32\8.2.0\..\..\..\..\x86_64-w64-mingw32\bin\ld.exe: obj\Debug\xApp.o:xApp.cpp:(.rdata$_ZTV4xApp[_ZTV4xApp]+0x88)||undefined reference to `wxApp::GetEventHashTable() const'|
c:\mingw\bin\..\lib\gcc\x86_64-w64-mingw32\8.2.0\..\..\..\..\x86_64-w64-mingw32\bin\ld.exe: obj\Debug\xApp.o:xApp.cpp:(.rdata$_ZTV4xApp[_ZTV4xApp]+0xb0)||undefined reference to `wxApp::Initialize(int&, wchar_t**)'|
c:\mingw\bin\..\lib\gcc\x86_64-w64-mingw32\8.2.0\..\..\..\..\x86_64-w64-mingw32\bin\ld.exe: obj\Debug\xApp.o:xApp.cpp:(.rdata$_ZTV4xApp[_ZTV4xApp]+0xc8)||undefined reference to `wxAppBase::OnRun()'|
c:\mingw\bin\..\lib\gcc\x86_64-w64-mingw32\8.2.0\..\..\..\..\x86_64-w64-mingw32\bin\ld.exe: obj\Debug\xApp.o:xApp.cpp:(.rdata$_ZTV4xApp[_ZTV4xApp]+0xe0)||undefined reference to `wxAppBase::OnExit()'|
c:\mingw\bin\..\lib\gcc\x86_64-w64-mingw32\8.2.0\..\..\..\..\x86_64-w64-mingw32\bin\ld.exe: obj\Debug\xApp.o:xApp.cpp:(.rdata$_ZTV4xApp[_ZTV4xApp]+0xf0)||undefined reference to `wxApp::CleanUp()'|
c:\mingw\bin\..\lib\gcc\x86_64-w64-mingw32\8.2.0\..\..\..\..\x86_64-w64-mingw32\bin\ld.exe: obj\Debug\xApp.o:xApp.cpp:(.rdata$_ZTV4xApp[_ZTV4xApp]+0x108)||undefined reference to `wxAppBase::OnInitCmdLine(wxCmdLineParser&)'|
c:\mingw\bin\..\lib\gcc\x86_64-w64-mingw32\8.2.0\..\..\..\..\x86_64-w64-mingw32\bin\ld.exe: obj\Debug\xApp.o:xApp.cpp:(.rdata$_ZTV4xApp[_ZTV4xApp]+0x110)||undefined reference to `wxAppBase::OnCmdLineParsed(wxCmdLineParser&)'|
c:\mingw\bin\..\lib\gcc\x86_64-w64-mingw32\8.2.0\..\..\..\..\x86_64-w64-mingw32\bin\ld.exe: obj\Debug\xApp.o:xApp.cpp:(.rdata$_ZTV4xApp[_ZTV4xApp]+0x150)||undefined reference to `wxApp::OnExceptionInMainLoop()'|
c:\mingw\bin\..\lib\gcc\x86_64-w64-mingw32\8.2.0\..\..\..\..\x86_64-w64-mingw32\bin\ld.exe: obj\Debug\xApp.o:xApp.cpp:(.rdata$_ZTV4xApp[_ZTV4xApp]+0x190)||undefined reference to `wxApp::WakeUpIdle()'|
c:\mingw\bin\..\lib\gcc\x86_64-w64-mingw32\8.2.0\..\..\..\..\x86_64-w64-mingw32\bin\ld.exe: obj\Debug\xApp.o:xApp.cpp:(.rdata$_ZTV4xApp[_ZTV4xApp]+0x198)||undefined reference to `wxAppBase::ProcessIdle()'|
c:\mingw\bin\..\lib\gcc\x86_64-w64-mingw32\8.2.0\..\..\..\..\x86_64-w64-mingw32\bin\ld.exe: obj\Debug\xApp.o:xApp.cpp:(.rdata$_ZTV4xApp[_ZTV4xApp]+0x1b8)||undefined reference to `wxAppBase::CreateTraits()'|
c:\mingw\bin\..\lib\gcc\x86_64-w64-mingw32\8.2.0\..\..\..\..\x86_64-w64-mingw32\bin\ld.exe: obj\Debug\xApp.o:xApp.cpp:(.rdata$_ZTV4xApp[_ZTV4xApp]+0x1c0)||undefined reference to `wxAppBase::OnInitGui()'|
c:\mingw\bin\..\lib\gcc\x86_64-w64-mingw32\8.2.0\..\..\..\..\x86_64-w64-mingw32\bin\ld.exe: obj\Debug\xApp.o:xApp.cpp:(.rdata$_ZTV4xApp[_ZTV4xApp]+0x1c8)||undefined reference to `wxAppBase::SafeYield(wxWindow*, bool)'|
c:\mingw\bin\..\lib\gcc\x86_64-w64-mingw32\8.2.0\..\..\..\..\x86_64-w64-mingw32\bin\ld.exe: obj\Debug\xApp.o:xApp.cpp:(.rdata$_ZTV4xApp[_ZTV4xApp]+0x1d0)||undefined reference to `wxAppBase::SafeYieldFor(wxWindow*, long)'|
c:\mingw\bin\..\lib\gcc\x86_64-w64-mingw32\8.2.0\..\..\..\..\x86_64-w64-mingw32\bin\ld.exe: obj\Debug\xApp.o:xApp.cpp:(.rdata$_ZTV4xApp[_ZTV4xApp]+0x1e0)||undefined reference to `wxAppBase::GetTopWindow() const'|
c:\mingw\bin\..\lib\gcc\x86_64-w64-mingw32\8.2.0\..\..\..\..\x86_64-w64-mingw32\bin\ld.exe: obj\Debug\xApp.o:xApp.cpp:(.rdata$_ZTV4xApp[_ZTV4xApp]+0x1e8)||undefined reference to `wxAppBase::GetDisplayMode() const'|
c:\mingw\bin\..\lib\gcc\x86_64-w64-mingw32\8.2.0\..\..\..\..\x86_64-w64-mingw32\bin\ld.exe: obj\Debug\xApp.o:xApp.cpp:(.rdata$_ZTV4xApp[_ZTV4xApp]+0x200)||undefined reference to `wxAppBase::GetLayoutDirection() const'|
c:\mingw\bin\..\lib\gcc\x86_64-w64-mingw32\8.2.0\..\..\..\..\x86_64-w64-mingw32\bin\ld.exe: obj\Debug\xApp.o:xApp.cpp:(.rdata$_ZTV4xApp[_ZTV4xApp]+0x210)||undefined reference to `wxAppBase::SetActive(bool, wxWindow*)'|
c:\mingw\bin\..\lib\gcc\x86_64-w64-mingw32\8.2.0\..\..\..\..\x86_64-w64-mingw32\bin\ld.exe: obj\Debug\xApp.o||in function `xApp::~xApp()':|
C:\Users\Aadhish\Documents\Projects\x\xApp.h|15|undefined reference to `__imp__ZN5wxAppD2Ev'|
c:\mingw\bin\..\lib\gcc\x86_64-w64-mingw32\8.2.0\..\..\..\..\x86_64-w64-mingw32\bin\ld.exe: obj\Debug\xMain.o||in function `xFrame::xFrame(wxWindow*, int)':|
C:\Users\Aadhish\Documents\Projects\x\xMain.cpp|64|undefined reference to `__imp_wxDefaultSize'|
c:\mingw\bin\..\lib\gcc\x86_64-w64-mingw32\8.2.0\..\..\..\..\x86_64-w64-mingw32\bin\ld.exe: C:\Users\Aadhish\Documents\Projects\x\xMain.cpp|64|undefined reference to `__imp_wxDefaultPosition'|
c:\mingw\bin\..\lib\gcc\x86_64-w64-mingw32\8.2.0\..\..\..\..\x86_64-w64-mingw32\bin\ld.exe: C:\Users\Aadhish\Documents\Projects\x\xMain.cpp|64|undefined reference to `__imp__ZN7wxFrame6CreateEP8wxWindowiRK8wxStringRK7wxPointRK6wxSizelS4_'|
c:\mingw\bin\..\lib\gcc\x86_64-w64-mingw32\8.2.0\..\..\..\..\x86_64-w64-mingw32\bin\ld.exe: C:\Users\Aadhish\Documents\Projects\x\xMain.cpp|65|undefined reference to `__imp__ZN9wxMenuBarC1Ev'|
c:\mingw\bin\..\lib\gcc\x86_64-w64-mingw32\8.2.0\..\..\..\..\x86_64-w64-mingw32\bin\ld.exe: C:\Users\Aadhish\Documents\Projects\x\xMain.cpp|67|undefined reference to `__imp__ZN10wxMenuItemC1EP6wxMenuiRK8wxStringS4_10wxItemKindS1_'|
c:\mingw\bin\..\lib\gcc\x86_64-w64-mingw32\8.2.0\..\..\..\..\x86_64-w64-mingw32\bin\ld.exe: C:\Users\Aadhish\Documents\Projects\x\xMain.cpp|71|undefined reference to `__imp__ZN10wxMenuItemC1EP6wxMenuiRK8wxStringS4_10wxItemKindS1_'|
c:\mingw\bin\..\lib\gcc\x86_64-w64-mingw32\8.2.0\..\..\..\..\x86_64-w64-mingw32\bin\ld.exe: C:\Users\Aadhish\Documents\Projects\x\xMain.cpp|74|undefined reference to `__imp__ZN11wxFrameBase10SetMenuBarEP9wxMenuBar'|
c:\mingw\bin\..\lib\gcc\x86_64-w64-mingw32\8.2.0\..\..\..\..\x86_64-w64-mingw32\bin\ld.exe: C:\Users\Aadhish\Documents\Projects\x\xMain.cpp|80|undefined reference to `__imp__ZN11wxFrameBase12SetStatusBarEP11wxStatusBar'|
c:\mingw\bin\..\lib\gcc\x86_64-w64-mingw32\8.2.0\..\..\..\..\x86_64-w64-mingw32\bin\ld.exe: C:\Users\Aadhish\Documents\Projects\x\xMain.cpp|82|undefined reference to `__imp_wxEVT_MENU'|
c:\mingw\bin\..\lib\gcc\x86_64-w64-mingw32\8.2.0\..\..\..\..\x86_64-w64-mingw32\bin\ld.exe: C:\Users\Aadhish\Documents\Projects\x\xMain.cpp|83|undefined reference to `__imp_wxEVT_MENU'|
c:\mingw\bin\..\lib\gcc\x86_64-w64-mingw32\8.2.0\..\..\..\..\x86_64-w64-mingw32\bin\ld.exe: C:\Users\Aadhish\Documents\Projects\x\xMain.cpp|55|undefined reference to `__imp__ZN7wxFrameD2Ev'|
c:\mingw\bin\..\lib\gcc\x86_64-w64-mingw32\8.2.0\..\..\..\..\x86_64-w64-mingw32\bin\ld.exe: obj\Debug\xMain.o||in function `xFrame::~xFrame()':|
C:\Users\Aadhish\Documents\Projects\x\xMain.cpp|87|undefined reference to `__imp__ZN7wxFrameD2Ev'|
c:\mingw\bin\..\lib\gcc\x86_64-w64-mingw32\8.2.0\..\..\..\..\x86_64-w64-mingw32\bin\ld.exe: obj\Debug\xMain.o||in function `xFrame::OnQuit(wxCommandEvent&)':|
C:\Users\Aadhish\Documents\Projects\x\xMain.cpp|95|undefined reference to `__imp__ZN12wxWindowBase5CloseEb'|
c:\mingw\bin\..\lib\gcc\x86_64-w64-mingw32\8.2.0\..\..\..\..\x86_64-w64-mingw32\bin\ld.exe: obj\Debug\xMain.o||in function `xFrame::OnAbout(wxCommandEvent&)':|
C:\Users\Aadhish\Documents\Projects\x\xMain.cpp|101|undefined reference to `__imp__Z12wxMessageBoxRK8wxStringS1_lP8wxWindowii'|
c:\mingw\bin\..\lib\gcc\x86_64-w64-mingw32\8.2.0\..\..\..\..\x86_64-w64-mingw32\bin\ld.exe: obj\Debug\xMain.o||in function `__static_initialization_and_destruction_0':|
C:\Users\Aadhish\Documents\Projects\x\xMain.cpp|50|undefined reference to `__imp__ZN7wxFrame13sm_eventTableE'|
c:\mingw\bin\..\lib\gcc\x86_64-w64-mingw32\8.2.0\..\..\..\..\x86_64-w64-mingw32\bin\ld.exe: obj\Debug\xMain.o||in function `wxWindowBase::GetBestVirtualSize() const':|
C:\MinGW\include\wxwidgets\include\wx\window.h|525|undefined reference to `__imp__ZNK12wxWindowBase11GetBestSizeEv'|
c:\mingw\bin\..\lib\gcc\x86_64-w64-mingw32\8.2.0\..\..\..\..\x86_64-w64-mingw32\bin\ld.exe: obj\Debug\xMain.o||in function `wxWindowBase::CanBeFocused() const':|
C:\MinGW\include\wxwidgets\include\wx\window.h|738|undefined reference to `__imp__ZNK12wxWindowBase9IsEnabledEv'|
c:\mingw\bin\..\lib\gcc\x86_64-w64-mingw32\8.2.0\..\..\..\..\x86_64-w64-mingw32\bin\ld.exe: obj\Debug\xMain.o||in function `wxWindowBase::HasCapture() const':|
C:\MinGW\include\wxwidgets\include\wx\window.h|1032|undefined reference to `__imp__ZN12wxWindowBase10GetCaptureEv'|
c:\mingw\bin\..\lib\gcc\x86_64-w64-mingw32\8.2.0\..\..\..\..\x86_64-w64-mingw32\bin\ld.exe: obj\Debug\xMain.o||in function `wxWindowBase::GetDefaultAttributes() const':|
C:\MinGW\include\wxwidgets\include\wx\window.h|1113|undefined reference to `__imp__ZN12wxWindowBase25GetClassDefaultAttributesE15wxWindowVariant'|
c:\mingw\bin\..\lib\gcc\x86_64-w64-mingw32\8.2.0\..\..\..\..\x86_64-w64-mingw32\bin\ld.exe: obj\Debug\xMain.o||in function `wxWindowBase::DoGetBestClientSize() const':|
C:\MinGW\include\wxwidgets\include\wx\window.h|1817|undefined reference to `__imp_wxDefaultSize'|
c:\mingw\bin\..\lib\gcc\x86_64-w64-mingw32\8.2.0\..\..\..\..\x86_64-w64-mingw32\bin\ld.exe: obj\Debug\xMain.o||in function `wxWindow::ShowWithEffect(wxShowEffect, unsigned int)':|
C:\MinGW\include\wxwidgets\include\wx\msw\window.h|89|undefined reference to `__imp__ZN8wxWindow17MSWShowWithEffectEb12wxShowEffectj'|
c:\mingw\bin\..\lib\gcc\x86_64-w64-mingw32\8.2.0\..\..\..\..\x86_64-w64-mingw32\bin\ld.exe: obj\Debug\xMain.o||in function `wxWindow::HideWithEffect(wxShowEffect, unsigned int)':|
C:\MinGW\include\wxwidgets\include\wx\msw\window.h|94|undefined reference to `__imp__ZN8wxWindow17MSWShowWithEffectEb12wxShowEffectj'|
c:\mingw\bin\..\lib\gcc\x86_64-w64-mingw32\8.2.0\..\..\..\..\x86_64-w64-mingw32\bin\ld.exe: obj\Debug\xMain.o||in function `wxWindow::MSWEndDeferWindowPos()':|
C:\MinGW\include\wxwidgets\include\wx\msw\window.h|756|undefined reference to `__imp_wxDefaultPosition'|
c:\mingw\bin\..\lib\gcc\x86_64-w64-mingw32\8.2.0\..\..\..\..\x86_64-w64-mingw32\bin\ld.exe: C:\MinGW\include\wxwidgets\include\wx\msw\window.h|757|undefined reference to `__imp_wxDefaultSize'|
c:\mingw\bin\..\lib\gcc\x86_64-w64-mingw32\8.2.0\..\..\..\..\x86_64-w64-mingw32\bin\ld.exe: obj\Debug\xMain.o||in function `wxTopLevelWindowBase::IsActive()':|
C:\MinGW\include\wxwidgets\include\wx\toplevel.h|201|undefined reference to `__imp__ZN12wxWindowBase9FindFocusEv'|
c:\mingw\bin\..\lib\gcc\x86_64-w64-mingw32\8.2.0\..\..\..\..\x86_64-w64-mingw32\bin\ld.exe: C:\MinGW\include\wxwidgets\include\wx\toplevel.h|201|undefined reference to `__imp__ZNK12wxWindowBase12IsDescendantEPS_'|
||More errors follow but not being shown.|
||Edit the max errors limit in compiler options...|
||=== Build failed: 50 error(s), 0 warning(s) (0 minute(s), 2 second(s)) ===|
I got these error. I know it's the error with libraries. I linked the libwxbase31ud.a.
Hope I explained everything.

You have UI elements so you need at least core library too (i.e. libwxmsw31ud_core.a).
There is a Library List page that you might find useful. And you can go to the folder where your libwxbase31ud.a currently is, to find the corresponding file for each library.
Another good place to look for lib details is the makefile.gcc of a sample that comes with wxWidgets.

Related

no valid method for accessing or setting values in protobuf class

I have been struggling with Google protobufs lately. I have written a proto file called Button.proto.
Here are its contents:
syntax = "proto3";
package robotjoystick;
message Button {
string name = 1;
int32 id = 2;
uint32 state = 3;
}
I successfully compiled it with this command (with the $USER replaced with the acctual computer user):
protoc -I=/home/$USER/robotjoystickserver --cpp_out=/home/$USER/robotjoystickserver/proto_classes Button.proto
I am using protobuf version 3.7.1.
My *.cpp file is calleddumbprrotos.cpp and it is not compiling for some reason.
Here is my *.cpp file:
// Client side C/C++ program to demonstrate Socket programming
#include <stdio.h>
#include <sys/socket.h>
#include <stdlib.h>
#include <netinet/in.h>
#include <string.h>
// This line was forgotten apparently - https://stackoverflow.com/questions/15660203/inet-pton-identifier-not-found
#include <arpa/inet.h>
// This one was also forgotten - https://www.reddit.com/r/learnprogramming/comments/3tlii5/clinux_why_is_write_or_close_not_declared_in_this/
#include <unistd.h>
// This is SDL 2.0, the joystick control library
#include <SDL2/SDL.h>
// For Ctrl+C quitting
#include <signal.h>
// for std::end
//#include <iostream>
// Now we import the header files the protobuf compiler generated.
#include "proto_classes/Button.pb.h"
// This is a standard port
#define PORT 8080
//#include<iostream>
using namespace std;
// For the protobuf generated class.
using namespace robotjoystick;
int main(int argc, char const *argv[])
{
// https://developers.google.com/protocol-buffers/docs/cpptutorial
// Verify that the version of the library that we linked against is
// compatible with the version of the headers we compiled against.
GOOGLE_PROTOBUF_VERIFY_VERSION;
// Broken method 1
/*
const string thename = "blah";
robotjoystick::Button * thebutton;
thebutton = new Button();
thebutton->set_name("john");
thebutton->set_id(12);
*/
// Broken method 2
const string thename = "blah";
robotjoystick::Button thebutton;
thebutton.set_name("john");
thebutton.set_id(12);
return 0;
}
The 2 sections of code I have labeled are 2 versions of the same thing that I am trying to accomplish, but both are throwing the same type of error and I have no idea how to interpret it. What do I need to do to make this code compile?
I should also mention that I installed protobuf 3.7.1 right off of my home directory (meaning that the zip file for protobuf was extracted there and then installed there).
The error I get when I currently run the code, the exact way it is, I get this error:
Compiling dumbprotos.cpp
/tmp/cc7HHVQf.o: In function `google::protobuf::internal::GetEmptyStringAlreadyInited[abi:cxx11]()':
dumbprotos.cpp:(.text._ZN6google8protobuf8internal27GetEmptyStringAlreadyInitedB5cxx11Ev[_ZN6google8protobuf8internal27GetEmptyStringAlreadyInitedB5cxx11Ev]+0x5): undefined reference to `google::protobuf::internal::fixed_address_empty_string[abi:cxx11]'
/tmp/ccMdby3z.o: In function `AddDescriptors_Button_2eproto()':
Button.pb.cc:(.text+0xa6): undefined reference to `google::protobuf::internal::AddDescriptors(google::protobuf::internal::DescriptorTable*, void (* const*)(), int)'
/tmp/ccMdby3z.o: In function `robotjoystick::Button::MergePartialFromCodedStream(google::protobuf::io::CodedInputStream*)':
Button.pb.cc:(.text+0x660): undefined reference to `google::protobuf::io::CodedInputStream::ReadTagFallback(unsigned int)'
Button.pb.cc:(.text+0x73f): undefined reference to `google::protobuf::internal::WireFormatLite::VerifyUtf8String(char const*, int, google::protobuf::internal::WireFormatLite::Operation, char const*)'
/tmp/ccMdby3z.o: In function `robotjoystick::Button::SerializeWithCachedSizes(google::protobuf::io::CodedOutputStream*) const':
Button.pb.cc:(.text+0x904): undefined reference to `google::protobuf::internal::WireFormatLite::VerifyUtf8String(char const*, int, google::protobuf::internal::WireFormatLite::Operation, char const*)'
/tmp/ccMdby3z.o: In function `robotjoystick::Button::InternalSerializeWithCachedSizesToArray(unsigned char*) const':
Button.pb.cc:(.text+0xa98): undefined reference to `google::protobuf::internal::WireFormatLite::VerifyUtf8String(char const*, int, google::protobuf::internal::WireFormatLite::Operation, char const*)'
/tmp/ccMdby3z.o: In function `robotjoystick::Button::GetMetadata() const':
Button.pb.cc:(.text+0x1386): undefined reference to `google::protobuf::internal::AssignDescriptors(google::protobuf::internal::AssignDescriptorsTable*)'
/tmp/ccMdby3z.o: In function `robotjoystick::Button* google::protobuf::Arena::CreateMaybeMessage<robotjoystick::Button>(google::protobuf::Arena*)':
Button.pb.cc:(.text+0x142e): undefined reference to `google::protobuf::internal::ArenaImpl::AllocateAligned(unsigned long)'
Button.pb.cc:(.text+0x144b): undefined reference to `google::protobuf::internal::ArenaImpl::AllocateAlignedAndAddCleanup(unsigned long, void (*)(void*))'
/tmp/ccMdby3z.o: In function `google::protobuf::io::CodedInputStream::ReadVarint32(unsigned int*)':
Button.pb.cc:(.text._ZN6google8protobuf2io16CodedInputStream12ReadVarint32EPj[_ZN6google8protobuf2io16CodedInputStream12ReadVarint32EPj]+0x78): undefined reference to `google::protobuf::io::CodedInputStream::ReadVarint32Fallback(unsigned int)'
/tmp/ccMdby3z.o: In function `google::protobuf::Arena::AllocHook(std::type_info const*, unsigned long) const':
Button.pb.cc:(.text._ZNK6google8protobuf5Arena9AllocHookEPKSt9type_infom[_ZNK6google8protobuf5Arena9AllocHookEPKSt9type_infom]+0x3d): undefined reference to `google::protobuf::Arena::OnArenaAllocation(std::type_info const*, unsigned long) const'
/tmp/ccMdby3z.o: In function `google::protobuf::internal::ArenaStringPtr::CreateInstance(google::protobuf::Arena*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const*)':
Button.pb.cc:(.text._ZN6google8protobuf8internal14ArenaStringPtr14CreateInstanceEPNS0_5ArenaEPKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE[_ZN6google8protobuf8internal14ArenaStringPtr14CreateInstanceEPNS0_5ArenaEPKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE]+0x23e): undefined reference to `google::protobuf::internal::ArenaImpl::AllocateAligned(unsigned long)'
Button.pb.cc:(.text._ZN6google8protobuf8internal14ArenaStringPtr14CreateInstanceEPNS0_5ArenaEPKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE[_ZN6google8protobuf8internal14ArenaStringPtr14CreateInstanceEPNS0_5ArenaEPKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE]+0x25b): undefined reference to `google::protobuf::internal::ArenaImpl::AllocateAlignedAndAddCleanup(unsigned long, void (*)(void*))'
/tmp/ccMdby3z.o: In function `google::protobuf::internal::InitSCC(google::protobuf::internal::SCCInfoBase*)':
Button.pb.cc:(.text._ZN6google8protobuf8internal7InitSCCEPNS1_11SCCInfoBaseE[_ZN6google8protobuf8internal7InitSCCEPNS1_11SCCInfoBaseE]+0x4d): undefined reference to `google::protobuf::internal::InitSCCImpl(google::protobuf::internal::SCCInfoBase*)'
/tmp/ccMdby3z.o: In function `google::protobuf::internal::OnShutdownDestroyMessage(void const*)':
Button.pb.cc:(.text._ZN6google8protobuf8internal24OnShutdownDestroyMessageEPKv[_ZN6google8protobuf8internal24OnShutdownDestroyMessageEPKv]+0x14): undefined reference to `google::protobuf::internal::DestroyMessage(void const*)'
Button.pb.cc:(.text._ZN6google8protobuf8internal24OnShutdownDestroyMessageEPKv[_ZN6google8protobuf8internal24OnShutdownDestroyMessageEPKv]+0x19): undefined reference to `google::protobuf::internal::OnShutdownRun(void (*)(void const*), void const*)'
/tmp/ccMdby3z.o: In function `google::protobuf::internal::InternalMetadataWithArena::default_instance()':
Button.pb.cc:(.text._ZN6google8protobuf8internal25InternalMetadataWithArena16default_instanceEv[_ZN6google8protobuf8internal25InternalMetadataWithArena16default_instanceEv]+0x5): undefined reference to `google::protobuf::UnknownFieldSet::default_instance()'
/tmp/ccMdby3z.o: In function `google::protobuf::internal::InternalMetadataWithArenaBase<google::protobuf::UnknownFieldSet, google::protobuf::internal::InternalMetadataWithArena>::mutable_unknown_fields_slow()':
Button.pb.cc:(.text._ZN6google8protobuf8internal29InternalMetadataWithArenaBaseINS0_15UnknownFieldSetENS1_25InternalMetadataWithArenaEE27mutable_unknown_fields_slowEv[_ZN6google8protobuf8internal29InternalMetadataWithArenaBaseINS0_15UnknownFieldSetENS1_25InternalMetadataWithArenaEE27mutable_unknown_fields_slowEv]+0x15c): undefined reference to `google::protobuf::internal::ArenaImpl::AllocateAligned(unsigned long)'
Button.pb.cc:(.text._ZN6google8protobuf8internal29InternalMetadataWithArenaBaseINS0_15UnknownFieldSetENS1_25InternalMetadataWithArenaEE27mutable_unknown_fields_slowEv[_ZN6google8protobuf8internal29InternalMetadataWithArenaBaseINS0_15UnknownFieldSetENS1_25InternalMetadataWithArenaEE27mutable_unknown_fields_slowEv]+0x176): undefined reference to `google::protobuf::internal::ArenaImpl::AllocateAlignedAndAddCleanup(unsigned long, void (*)(void*))'
/tmp/ccMdby3z.o:(.rodata._ZTVN13robotjoystick6ButtonE[_ZTVN13robotjoystick6ButtonE]+0xb8): undefined reference to `google::protobuf::Message::SpaceUsedLong() const'
collect2: error: ld returned 1 exit status
When I compile the code wth the other broken scenario,
const string thename = "blah";
robotjoystick::Button * thebutton;
thebutton = new Button();
thebutton->set_name("john");
thebutton->set_id(12);
I get this error instead:
Compiling dumbprotos.cpp
/tmp/ccaCT7Iy.o: In function `google::protobuf::internal::GetEmptyStringAlreadyInited[abi:cxx11]()':
dumbprotos.cpp:(.text._ZN6google8protobuf8internal27GetEmptyStringAlreadyInitedB5cxx11Ev[_ZN6google8protobuf8internal27GetEmptyStringAlreadyInitedB5cxx11Ev]+0x5): undefined reference to `google::protobuf::internal::fixed_address_empty_string[abi:cxx11]'
/tmp/ccfmvBXP.o: In function `AddDescriptors_Button_2eproto()':
Button.pb.cc:(.text+0xa6): undefined reference to `google::protobuf::internal::AddDescriptors(google::protobuf::internal::DescriptorTable*, void (* const*)(), int)'
/tmp/ccfmvBXP.o: In function `robotjoystick::Button::MergePartialFromCodedStream(google::protobuf::io::CodedInputStream*)':
Button.pb.cc:(.text+0x660): undefined reference to `google::protobuf::io::CodedInputStream::ReadTagFallback(unsigned int)'
Button.pb.cc:(.text+0x73f): undefined reference to `google::protobuf::internal::WireFormatLite::VerifyUtf8String(char const*, int, google::protobuf::internal::WireFormatLite::Operation, char const*)'
/tmp/ccfmvBXP.o: In function `robotjoystick::Button::SerializeWithCachedSizes(google::protobuf::io::CodedOutputStream*) const':
Button.pb.cc:(.text+0x904): undefined reference to `google::protobuf::internal::WireFormatLite::VerifyUtf8String(char const*, int, google::protobuf::internal::WireFormatLite::Operation, char const*)'
/tmp/ccfmvBXP.o: In function `robotjoystick::Button::InternalSerializeWithCachedSizesToArray(unsigned char*) const':
Button.pb.cc:(.text+0xa98): undefined reference to `google::protobuf::internal::WireFormatLite::VerifyUtf8String(char const*, int, google::protobuf::internal::WireFormatLite::Operation, char const*)'
/tmp/ccfmvBXP.o: In function `robotjoystick::Button::GetMetadata() const':
Button.pb.cc:(.text+0x1386): undefined reference to `google::protobuf::internal::AssignDescriptors(google::protobuf::internal::AssignDescriptorsTable*)'
/tmp/ccfmvBXP.o: In function `robotjoystick::Button* google::protobuf::Arena::CreateMaybeMessage<robotjoystick::Button>(google::protobuf::Arena*)':
Button.pb.cc:(.text+0x142e): undefined reference to `google::protobuf::internal::ArenaImpl::AllocateAligned(unsigned long)'
Button.pb.cc:(.text+0x144b): undefined reference to `google::protobuf::internal::ArenaImpl::AllocateAlignedAndAddCleanup(unsigned long, void (*)(void*))'
/tmp/ccfmvBXP.o: In function `google::protobuf::io::CodedInputStream::ReadVarint32(unsigned int*)':
Button.pb.cc:(.text._ZN6google8protobuf2io16CodedInputStream12ReadVarint32EPj[_ZN6google8protobuf2io16CodedInputStream12ReadVarint32EPj]+0x78): undefined reference to `google::protobuf::io::CodedInputStream::ReadVarint32Fallback(unsigned int)'
/tmp/ccfmvBXP.o: In function `google::protobuf::Arena::AllocHook(std::type_info const*, unsigned long) const':
Button.pb.cc:(.text._ZNK6google8protobuf5Arena9AllocHookEPKSt9type_infom[_ZNK6google8protobuf5Arena9AllocHookEPKSt9type_infom]+0x3d): undefined reference to `google::protobuf::Arena::OnArenaAllocation(std::type_info const*, unsigned long) const'
/tmp/ccfmvBXP.o: In function `google::protobuf::internal::ArenaStringPtr::CreateInstance(google::protobuf::Arena*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const*)':
Button.pb.cc:(.text._ZN6google8protobuf8internal14ArenaStringPtr14CreateInstanceEPNS0_5ArenaEPKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE[_ZN6google8protobuf8internal14ArenaStringPtr14CreateInstanceEPNS0_5ArenaEPKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE]+0x23e): undefined reference to `google::protobuf::internal::ArenaImpl::AllocateAligned(unsigned long)'
Button.pb.cc:(.text._ZN6google8protobuf8internal14ArenaStringPtr14CreateInstanceEPNS0_5ArenaEPKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE[_ZN6google8protobuf8internal14ArenaStringPtr14CreateInstanceEPNS0_5ArenaEPKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE]+0x25b): undefined reference to `google::protobuf::internal::ArenaImpl::AllocateAlignedAndAddCleanup(unsigned long, void (*)(void*))'
/tmp/ccfmvBXP.o: In function `google::protobuf::internal::InitSCC(google::protobuf::internal::SCCInfoBase*)':
Button.pb.cc:(.text._ZN6google8protobuf8internal7InitSCCEPNS1_11SCCInfoBaseE[_ZN6google8protobuf8internal7InitSCCEPNS1_11SCCInfoBaseE]+0x4d): undefined reference to `google::protobuf::internal::InitSCCImpl(google::protobuf::internal::SCCInfoBase*)'
/tmp/ccfmvBXP.o: In function `google::protobuf::internal::OnShutdownDestroyMessage(void const*)':
Button.pb.cc:(.text._ZN6google8protobuf8internal24OnShutdownDestroyMessageEPKv[_ZN6google8protobuf8internal24OnShutdownDestroyMessageEPKv]+0x14): undefined reference to `google::protobuf::internal::DestroyMessage(void const*)'
Button.pb.cc:(.text._ZN6google8protobuf8internal24OnShutdownDestroyMessageEPKv[_ZN6google8protobuf8internal24OnShutdownDestroyMessageEPKv]+0x19): undefined reference to `google::protobuf::internal::OnShutdownRun(void (*)(void const*), void const*)'
/tmp/ccfmvBXP.o: In function `google::protobuf::internal::InternalMetadataWithArena::default_instance()':
Button.pb.cc:(.text._ZN6google8protobuf8internal25InternalMetadataWithArena16default_instanceEv[_ZN6google8protobuf8internal25InternalMetadataWithArena16default_instanceEv]+0x5): undefined reference to `google::protobuf::UnknownFieldSet::default_instance()'
/tmp/ccfmvBXP.o: In function `google::protobuf::internal::InternalMetadataWithArenaBase<google::protobuf::UnknownFieldSet, google::protobuf::internal::InternalMetadataWithArena>::mutable_unknown_fields_slow()':
Button.pb.cc:(.text._ZN6google8protobuf8internal29InternalMetadataWithArenaBaseINS0_15UnknownFieldSetENS1_25InternalMetadataWithArenaEE27mutable_unknown_fields_slowEv[_ZN6google8protobuf8internal29InternalMetadataWithArenaBaseINS0_15UnknownFieldSetENS1_25InternalMetadataWithArenaEE27mutable_unknown_fields_slowEv]+0x15c): undefined reference to `google::protobuf::internal::ArenaImpl::AllocateAligned(unsigned long)'
Button.pb.cc:(.text._ZN6google8protobuf8internal29InternalMetadataWithArenaBaseINS0_15UnknownFieldSetENS1_25InternalMetadataWithArenaEE27mutable_unknown_fields_slowEv[_ZN6google8protobuf8internal29InternalMetadataWithArenaBaseINS0_15UnknownFieldSetENS1_25InternalMetadataWithArenaEE27mutable_unknown_fields_slowEv]+0x176): undefined reference to `google::protobuf::internal::ArenaImpl::AllocateAlignedAndAddCleanup(unsigned long, void (*)(void*))'
/tmp/ccfmvBXP.o:(.rodata._ZTVN13robotjoystick6ButtonE[_ZTVN13robotjoystick6ButtonE]+0xb8): undefined reference to `google::protobuf::Message::SpaceUsedLong() const'
collect2: error: ld returned 1 exit status
This is the script I am using to compile the code:
#!/bin/sh
echo "Compiling dumbprotos.cpp"
echo ""
g++ dumbprotos.cpp proto_classes/Button.pb.cc -o ./pleasework -std=c++11 -lSDL2 -lprotobuf
I think that is everything I need to show you guys. Did I miss anything? What do I need to do to make my *.cpp code compile?
I am on Ubuntu 16.04.
After thinking about the comment provided by #goduk, I thought I should look further into the linking library issue and find the files I need to source. It turns out that I was not linking to any specific location.
I decided to look through the docs under protobuf-3.7.1/src/README.md to explore further to find the .../lib/ directory. After re-reading those docs, a specific section caught my eye.
To compile a package that uses Protocol Buffers, you need to pass
various flags to your compiler and linker. As of version 2.2.0,
Protocol Buffers integrates with pkg-config to manage this. If you
have pkg-config installed, then you can invoke it to get a list of
flags like so:
pkg-config --cflags protobuf # print compiler flags
pkg-config --libs protobuf # print linker flags
pkg-config --cflags --libs protobuf # print both
For example:
c++ my_program.cc my_proto.pb.cc `pkg-config --cflags --libs protobuf`
On my laptop, the command pkg-config --cflags --libs protobuf returns -pthread -I/usr/local/include -L/usr/local/lib -lprotobuf -pthread.
Instead of trying to determine the correct compiling flags, I simply needed to call the required flags using pkg-config --cflags --libs protobuf at the end.
I had never heard of pkg-config before, but this solved all of my problems.
The final bash script line is now this:
g++ dumbprotos.cpp proto_classes/Button.pb.cc -o ./pleasework -std=c++11 -lSDL2 `pkg-config --cflags --libs protobuf`
Thanks for the help.
(This is a linker type issue.)
I should also mention that, if the protobuf object contains other protobuf objects, you have to include those in the command line call:
g++ my_program.cc my_proto_imported.pb.cc my_proto_containing.pb.cc `pkg-config --cflags --libs protobuf`
Meaning that my_proto_imported.pb.cc is a protobuf imported and used in my_proto_contained.pb.cc.

libmysqlclient compile error: In function `yaSSLv3_server_method'

I want to compile C files in ubuntu16.04, the makefile file is as follows:
TARGET := matchengine.exe
INCS = -I ../network -I ../utils
LIBS = -L ../utils -lutils -L ../network -lnetwork -Wl,-Bstatic -lev -ljansson -lmpdec -lmysqlclient -lz -lrdkafka -lssl -lcrypto -lhiredis -Wl,-Bdynamic -lm -lpthread -ldl
include ../makefile.inc
I have installed libmysqlclient-dev and mysql-client library using following command:
apt install mysql-client-5.6
apt-get install libmysqlclient-dev
While I compiled the C files , the following errors show:
/usr/lib/gcc/x86_64-linux-gnu/5/../../../x86_64-linux-gnu/libmysqlclient.a(my_default.cc.o):(.data.DW.ref.__gxx_personality_v0[DW.ref.__gxx_personality_v0]+0x0): undefined reference to `__gxx_personality_v0'
/usr/lib/gcc/x86_64-linux-gnu/5/../../../x86_64-linux-gnu/libmysqlclient.a(ssl.cpp.o): In function `yaSSLv3_server_method':
(.text+0x60): undefined reference to `operator new(unsigned long)'
/usr/lib/gcc/x86_64-linux-gnu/5/../../../x86_64-linux-gnu/libmysqlclient.a(ssl.cpp.o): In function `yaSSLv3_server_method':
(.text+0x9e): undefined reference to `operator delete(void*)'
/usr/lib/gcc/x86_64-linux-gnu/5/../../../x86_64-linux-gnu/libmysqlclient.a(ssl.cpp.o): In function `yaSSLv3_client_method':
(.text+0xe0): undefined reference to `operator new(unsigned long)'
/usr/lib/gcc/x86_64-linux-gnu/5/../../../x86_64-linux-gnu/libmysqlclient.a(ssl.cpp.o): In function `yaSSLv3_client_method':
(.text+0x121): undefined reference to `operator delete(void*)'
/usr/lib/gcc/x86_64-linux-gnu/5/../../../x86_64-linux-gnu/libmysqlclient.a(ssl.cpp.o): In function `yaTLSv1_server_method':
(.text+0x173): undefined reference to `operator new(unsigned long)'
.....
/usr/lib/gcc/x86_64-linux-gnu/5/../../../x86_64-linux-gnu/libmysqlclient.a(ripemd.cpp.o):(.data.rel.ro._ZTIN8TaoCrypt9RIPEMD160E[_ZTIN8TaoCrypt9RIPEMD160E]+0x0): undefined reference to `vtable for __cxxabiv1::__si_class_type_info'
/usr/lib/gcc/x86_64-linux-gnu/5/../../../x86_64-linux-gnu/libmysqlclient.a(dh.cpp.o): In function `TaoCrypt::DH::GeneratePrivate(TaoCrypt::RandomNumberGenerator&, unsigned char*)':
(.text+0x122): undefined reference to `operator delete[](void*)'
/usr/lib/gcc/x86_64-linux-gnu/5/../../../x86_64-linux-gnu/libmysqlclient.a(dh.cpp.o): In function `TaoCrypt::DH::GeneratePrivate(TaoCrypt::RandomNumberGenerator&, unsigned char*)':
(.text+0x145): undefined reference to `operator delete[](void*)'
/usr/lib/gcc/x86_64-linux-gnu/5/../../../x86_64-linux-gnu/libmysqlclient.a(dh.cpp.o): In function `TaoCrypt::DH::GeneratePrivate(TaoCrypt::RandomNumberGenerator&, unsigned char*)':
(.text+0x162): undefined reference to `operator delete[](void*)'
/usr/lib/gcc/x86_64-linux-gnu/5/../../../x86_64-linux-gnu/libmysqlclient.a(dh.cpp.o): In function `TaoCrypt::DH::GeneratePrivate(TaoCrypt::RandomNumberGenerator&, unsigned char*)':
(.text+0x1a0): undefined reference to `operator delete[](void*)'
/usr/lib/gcc/x86_64-linux-gnu/5/../../../x86_64-linux-gnu/libmysqlclient.a(dh.cpp.o): In function `TaoCrypt::DH::GeneratePublic(unsigned char const*, unsigned char*)':
(.text+0x2b3): undefined reference to `operator delete[](void*)'
/usr/lib/gcc/x86_64-linux-gnu/5/../../../x86_64-linux-gnu/libmysqlclient.a(dh.cpp.o):(.text+0x2d0): more undefined references to `operator delete[](void*)' follow

arm-none-eabi-gcc toolchain is not working

I have downloaded the toolchain from following link
https://launchpad.net/gcc-arm-embedded/5.0/5-2016-q1-update/+download/gcc-arm-none-eabi-5_3-2016q1-20160330-linux.tar.bz2
i made a script to add it to environmental path
export INSTALL_ROOT=`pwd`
TOOLS_PATH=$INSTALL_ROOT/
CROSS_PATH=$TOOLS_PATH/arm-none-eabi/bin
export PATH=$TOOLS_PATH/bin:$CROSS_PATH:$PATH
# Path to cross-tools
export CROSS_COMPILE=arm-none-eabi-
export CROSS_COMPILE_APPS=arm-none-eabi-
but if i use it in cross compilation i.e. using ./configure --error comes
./configure --host=arm-none-eabi
checking build system type... i686-pc-linux-gnu
checking host system type... arm-none-eabi
checking target system type... arm-none-eabi
checking for arm-none-eabi-gcc... arm-none-eabi-gcc
checking whether the C compiler works... no
aconfigure: error: in `/home/sameer/Downloads/pjsip_experiment/0706/pjproject-2.4.5':
aconfigure: error: C compiler cannot create executables
See `config.log' for more details
if i just compile a helloworld program then also error comes
arm-none-eabi-gcc hello.c -o out
/home/sameer/Downloads/toolchain/gcc-arm-none-eabi-5_3-2016q1/bin/../lib/gcc/arm-none-eabi/5.3.1/../../../../arm-none-eabi/lib/libc.a(lib_a-exit.o): In function `exit':
exit.c:(.text.exit+0x2c): undefined reference to `_exit'
/home/sameer/Downloads/toolchain/gcc-arm-none-eabi-5_3-2016q1/bin/../lib/gcc/arm-none-eabi/5.3.1/../../../../arm-none-eabi/lib/libc.a(lib_a-sbrkr.o): In function `_sbrk_r':
sbrkr.c:(.text._sbrk_r+0x18): undefined reference to `_sbrk'
/home/sameer/Downloads/toolchain/gcc-arm-none-eabi-5_3-2016q1/bin/../lib/gcc/arm-none-eabi/5.3.1/../../../../arm-none-eabi/lib/libc.a(lib_a-writer.o): In function `_write_r':
writer.c:(.text._write_r+0x24): undefined reference to `_write'
/home/sameer/Downloads/toolchain/gcc-arm-none-eabi-5_3-2016q1/bin/../lib/gcc/arm-none-eabi/5.3.1/../../../../arm-none-eabi/lib/libc.a(lib_a-closer.o): In function `_close_r':
closer.c:(.text._close_r+0x18): undefined reference to `_close'
/home/sameer/Downloads/toolchain/gcc-arm-none-eabi-5_3-2016q1/bin/../lib/gcc/arm-none-eabi/5.3.1/../../../../arm-none-eabi/lib/libc.a(lib_a-fstatr.o): In function `_fstat_r':
fstatr.c:(.text._fstat_r+0x20): undefined reference to `_fstat'
/home/sameer/Downloads/toolchain/gcc-arm-none-eabi-5_3-2016q1/bin/../lib/gcc/arm-none-eabi/5.3.1/../../../../arm-none-eabi/lib/libc.a(lib_a-isattyr.o): In function `_isatty_r':
isattyr.c:(.text._isatty_r+0x18): undefined reference to `_isatty'
/home/sameer/Downloads/toolchain/gcc-arm-none-eabi-5_3-2016q1/bin/../lib/gcc/arm-none-eabi/5.3.1/../../../../arm-none-eabi/lib/libc.a(lib_a-lseekr.o): In function `_lseek_r':
lseekr.c:(.text._lseek_r+0x24): undefined reference to `_lseek'
/home/sameer/Downloads/toolchain/gcc-arm-none-eabi-5_3-2016q1/bin/../lib/gcc/arm-none-eabi/5.3.1/../../../../arm-none-eabi/lib/libc.a(lib_a-readr.o): In function `_read_r':
readr.c:(.text._read_r+0x24): undefined reference to `_read'
collect2: error: ld returned 1 exit status
/home/sameer/Downloads/toolchain/gcc-arm-none-eabi-5_3-2016q1/bin/../lib/gcc/arm-none-eabi/5.3.1/../../../../arm-none-eabi/lib/libc.a(lib_a-exit.o): In function `exit':
exit.c:(.text.exit+0x2c): undefined reference to `_exit'
/home/sameer/Downloads/toolchain/gcc-arm-none-eabi-5_3-2016q1/bin/../lib/gcc/arm-none-eabi/5.3.1/../../../../arm-none-eabi/lib/libc.a(lib_a-sbrkr.o): In function `_sbrk_r':
sbrkr.c:(.text._sbrk_r+0x18): undefined reference to `_sbrk'
/home/sameer/Downloads/toolchain/gcc-arm-none-eabi-5_3-2016q1/bin/../lib/gcc/arm-none-eabi/5.3.1/../../../../arm-none-eabi/lib/libc.a(lib_a-writer.o): In function `_write_r':
writer.c:(.text._write_r+0x24): undefined reference to `_write'
/home/sameer/Downloads/toolchain/gcc-arm-none-eabi-5_3-2016q1/bin/../lib/gcc/arm-none-eabi/5.3.1/../../../../arm-none-eabi/lib/libc.a(lib_a-closer.o): In function `_close_r':
closer.c:(.text._close_r+0x18): undefined reference to `_close'
/home/sameer/Downloads/toolchain/gcc-arm-none-eabi-5_3-2016q1/bin/../lib/gcc/arm-none-eabi/5.3.1/../../../../arm-none-eabi/lib/libc.a(lib_a-fstatr.o): In function `_fstat_r':
fstatr.c:(.text._fstat_r+0x20): undefined reference to `_fstat'
/home/sameer/Downloads/toolchain/gcc-arm-none-eabi-5_3-2016q1/bin/../lib/gcc/arm-none-eabi/5.3.1/../../../../arm-none-eabi/lib/libc.a(lib_a-isattyr.o): In function `_isatty_r':
isattyr.c:(.text._isatty_r+0x18): undefined reference to `_isatty'
/home/sameer/Downloads/toolchain/gcc-arm-none-eabi-5_3-2016q1/bin/../lib/gcc/arm-none-eabi/5.3.1/../../../../arm-none-eabi/lib/libc.a(lib_a-lseekr.o): In function `_lseek_r':
lseekr.c:(.text._lseek_r+0x24): undefined reference to `_lseek'
/home/sameer/Downloads/toolchain/gcc-arm-none-eabi-5_3-2016q1/bin/../lib/gcc/arm-none-eabi/5.3.1/../../../../arm-none-eabi/lib/libc.a(lib_a-readr.o): In function `_read_r':
readr.c:(.text._read_r+0x24): undefined reference to `_read'
collect2: error: ld returned 1 exit status
What is wrong ?

P3DFFT compilation - "Undefined reference" but libraries are linked

I need help with compilation of P3DFFT. I'm literally lost in the process, because the compiler is complaining about "undefined reference" to lots of symbols, but those symbols are present in the libraries.
My command:
mpicc -g -O2 -I../../include -L/home/martin/fftw3/libs -lfftw3 /home/martin/p3dfft/build/libp3dfft.a driver_rand.c -o driver_rand
Compiler output:
driver_rand.c: In function ‘main’:
driver_rand.c:114:10: warning: ignoring return value of ‘fscanf’, declared with attribute warn_unused_result [-Wunused-result]
fscanf(fp,"%d %d %d %d %d\n",&nx,&ny,&nz,&ndim,&n);
^
driver_rand.c:137:8: warning: ignoring return value of ‘fscanf’, declared with attribute warn_unused_result [-Wunused-result]
fscanf(fp,"%d %d\n",dims,dims+1);
^
/tmp/cc52N8Sc.o: In function `Cp3dfft_setup':
/home/martin/p3dfft/sample/C/../../include/p3dfft.h:90: undefined reference to `p3dfft_setup'
/tmp/cc52N8Sc.o: In function `Cp3dfft_get_dims':
/home/martin/p3dfft/sample/C/../../include/p3dfft.h:100: undefined reference to `p3dfft_get_dims'
/home/martin/p3dfft/sample/C/../../include/p3dfft.h:100: undefined reference to `p3dfft_get_dims'
/tmp/cc52N8Sc.o: In function `Cp3dfft_clean':
/home/martin/p3dfft/sample/C/../../include/p3dfft.h:95: undefined reference to `p3dfft_clean'
/tmp/cc52N8Sc.o: In function `Cget_timers':
/home/martin/p3dfft/sample/C/../../include/p3dfft.h:105: undefined reference to `get_timers'
/tmp/cc52N8Sc.o: In function `Cset_timers':
/home/martin/p3dfft/sample/C/../../include/p3dfft.h:110: undefined reference to `set_timers'
/tmp/cc52N8Sc.o: In function `Cp3dfft_ftran_r2c':
/home/martin/p3dfft/sample/C/../../include/p3dfft.h:117: undefined reference to `p3dfft_ftran_r2c'
/tmp/cc52N8Sc.o: In function `Cp3dfft_btran_c2r':
/home/martin/p3dfft/sample/C/../../include/p3dfft.h:130: undefined reference to `p3dfft_btran_c2r'
/tmp/cc52N8Sc.o: In function `main':
/home/martin/p3dfft/sample/C/driver_rand.c:106: undefined reference to `set_timers'
/tmp/cc52N8Sc.o: In function `Cp3dfft_setup':
/home/martin/p3dfft/sample/C/../../include/p3dfft.h:90: undefined reference to `p3dfft_setup'
/tmp/cc52N8Sc.o: In function `Cp3dfft_get_dims':
/home/martin/p3dfft/sample/C/../../include/p3dfft.h:100: undefined reference to `p3dfft_get_dims'
/home/martin/p3dfft/sample/C/../../include/p3dfft.h:100: undefined reference to `p3dfft_get_dims'
/tmp/cc52N8Sc.o: In function `Cp3dfft_ftran_r2c':
/home/martin/p3dfft/sample/C/../../include/p3dfft.h:117: undefined reference to `p3dfft_ftran_r2c'
/tmp/cc52N8Sc.o: In function `Cp3dfft_btran_c2r':
/home/martin/p3dfft/sample/C/../../include/p3dfft.h:130: undefined reference to `p3dfft_btran_c2r'
/tmp/cc52N8Sc.o: In function `Cp3dfft_clean':
/home/martin/p3dfft/sample/C/../../include/p3dfft.h:95: undefined reference to `p3dfft_clean'
/tmp/cc52N8Sc.o: In function `main':
/home/martin/p3dfft/sample/C/driver_rand.c:258: undefined reference to `get_timers'
collect2: error: ld returned 1 exit status
Undefined symbols ARE present in libp3dfft.a:
nm ../../build/libp3dfft.a --defined-only | grep 'p3dfft_setup'
000000000000d030 T __p3dfft_MOD_p3dfft_setup
0000000000010ed0 T p3dfft_setup
nm ../../build/libp3dfft.a --defined-only | grep 'get_timers'
00000000000052f0 T get_timers
0000000000005230 T __p3dfft_MOD_get_timers
Do you have ANY idea what am I doing wrong?
I'm not familiar with your particular compiler, but I think you may need to correct the order of the source file and the libraries on your command line, i.e.
mpicc -g -O2 -I../../include -L/home/martin/fftw3/libs -lfftw3 /home/martin/p3dfft/build/libp3dfft.a driver_rand.c -o driver_rand
should probably be:
mpicc -g -O2 -I../../include driver_rand.c /home/martin/p3dfft/build/libp3dfft.a -L/home/martin/fftw3/libs -lfftw3 -o driver_rand

Ettus UHD, compiling Transceiver52M

I have a problem compiling Transceiver52M for OpenBTS, I have a Ettus B200 peripheral, and have installed UHD version UHD_003.010.git-156-g2d68f228.
But I get the following errors once I get to compiling Transceiver52M; the filing lines are (the full build output is here):
libtool: link: g++ -g -O2 -Wall -pthread -rdynamic -DTIMESTAMP_ISO=\"2016-03-28T20:57:00\" -o transceiver runTransceiver.o /usr/local/lib/libuhd.so ./.libs/libtransceiver.a ../GSM/.libs/libGSM.a ../C
ommonLibs/.libs/libcommon.a -ldl /usr/lib/x86_64-linux-gnu/libsqlite3.so -la53 -lzmq -pthread
./.libs/libtransceiver.a(UHDDevice.o): In function `uhd_device::stop()':
/home/openbts/dev/openbts/Transceiver52M/UHDDevice.cpp:673: undefined reference to `uhd::stream_cmd_t::stream_cmd_t(uhd::stream_cmd_t::stream_mode_t const&)'
./.libs/libtransceiver.a(UHDDevice.o): In function `uhd::usrp::multi_usrp::set_rx_gain(double, unsigned long)':
/usr/local/include/uhd/usrp/multi_usrp.hpp:500: undefined reference to `uhd::usrp::multi_usrp::ALL_GAINS'
./.libs/libtransceiver.a(UHDDevice.o): In function `uhd::usrp::multi_usrp::set_tx_gain(double, unsigned long)':
/usr/local/include/uhd/usrp/multi_usrp.hpp:786: undefined reference to `uhd::usrp::multi_usrp::ALL_GAINS'
./.libs/libtransceiver.a(UHDDevice.o): In function `uhd_device::writeSamples(short*, int, bool*, unsigned long long, bool)':
/home/openbts/dev/openbts/Transceiver52M/UHDDevice.cpp:810: undefined reference to `uhd::tx_metadata_t::tx_metadata_t()'
/home/openbts/dev/openbts/Transceiver52M/UHDDevice.cpp:814: undefined reference to `uhd::time_spec_t::from_ticks(long long, double)'
/home/openbts/dev/openbts/Transceiver52M/UHDDevice.cpp:847: undefined reference to `uhd::get_version_string()'
./.libs/libtransceiver.a(UHDDevice.o): In function `uhd_device::uhd_device(int, bool)':
/home/openbts/dev/openbts/Transceiver52M/UHDDevice.cpp:343: undefined reference to `uhd::time_spec_t::time_spec_t(long, double)'
./.libs/libtransceiver.a(UHDDevice.o): In function `uhd_device::parse_dev_type()':
/home/openbts/dev/openbts/Transceiver52M/UHDDevice.cpp:479: undefined reference to `uhd::device::get_tree() const'
/home/openbts/dev/openbts/Transceiver52M/UHDDevice.cpp:480: undefined reference to `uhd::fs_path::fs_path(char const*)'
./.libs/libtransceiver.a(UHDDevice.o): In function `rx_metadata_t':
/usr/local/include/uhd/types/metadata.hpp:37: undefined reference to `uhd::time_spec_t::time_spec_t(double)'
./.libs/libtransceiver.a(UHDDevice.o): In function `uhd::rx_metadata_t::reset()':
/usr/local/include/uhd/types/metadata.hpp:45: undefined reference to `uhd::time_spec_t::time_spec_t(double)'
./.libs/libtransceiver.a(UHDDevice.o): In function `uhd_device::restart(uhd::time_spec_t)':
/home/openbts/dev/openbts/Transceiver52M/UHDDevice.cpp:629: undefined reference to `uhd::stream_cmd_t::stream_cmd_t(uhd::stream_cmd_t::stream_mode_t const&)'
/home/openbts/dev/openbts/Transceiver52M/UHDDevice.cpp:637: undefined reference to `uhd::stream_cmd_t::stream_cmd_t(uhd::stream_cmd_t::stream_mode_t const&)'
./.libs/libtransceiver.a(UHDDevice.o): In function `uhd_device::start()':
/home/openbts/dev/openbts/Transceiver52M/UHDDevice.cpp:654: undefined reference to `uhd::msg::register_handler(void (* const&)(uhd::msg::type_t, std::string const&))'
/home/openbts/dev/openbts/Transceiver52M/UHDDevice.cpp:660: undefined reference to `uhd::time_spec_t::time_spec_t(double)'
/home/openbts/dev/openbts/Transceiver52M/UHDDevice.cpp:663: undefined reference to `uhd::time_spec_t::get_real_secs() const'
./.libs/libtransceiver.a(UHDDevice.o): In function `smpl_buf::avail_smpls(uhd::time_spec_t) const':
/home/openbts/dev/openbts/Transceiver52M/UHDDevice.cpp:987: undefined reference to `uhd::time_spec_t::to_ticks(double) const'
./.libs/libtransceiver.a(UHDDevice.o): In function `smpl_buf::read(void*, unsigned long, uhd::time_spec_t)':
/home/openbts/dev/openbts/Transceiver52M/UHDDevice.cpp:1033: undefined reference to `uhd::time_spec_t::to_ticks(double) const'
./.libs/libtransceiver.a(UHDDevice.o): In function `smpl_buf::write(void*, unsigned long, uhd::time_spec_t)':
/home/openbts/dev/openbts/Transceiver52M/UHDDevice.cpp:1074: undefined reference to `uhd::time_spec_t::to_ticks(double) const'
./.libs/libtransceiver.a(UHDDevice.o): In function `uhd_device::init_gains()':
/home/openbts/dev/openbts/Transceiver52M/UHDDevice.cpp:359: undefined reference to `uhd::meta_range_t::meta_range_t()'
./.libs/libtransceiver.a(UHDDevice.o): In function `uhd::usrp::multi_usrp::get_tx_gain_range(unsigned long)':
/usr/local/include/uhd/usrp/multi_usrp.hpp:838: undefined reference to `uhd::usrp::multi_usrp::ALL_GAINS'
./.libs/libtransceiver.a(UHDDevice.o): In function `uhd_device::init_gains()':
/home/openbts/dev/openbts/Transceiver52M/UHDDevice.cpp:362: undefined reference to `uhd::meta_range_t::start() const'
/home/openbts/dev/openbts/Transceiver52M/UHDDevice.cpp:363: undefined reference to `uhd::meta_range_t::stop() const'
/home/openbts/dev/openbts/Transceiver52M/UHDDevice.cpp:366: undefined reference to `uhd::meta_range_t::start() const'
/home/openbts/dev/openbts/Transceiver52M/UHDDevice.cpp:367: undefined reference to `uhd::meta_range_t::stop() const'
./.libs/libtransceiver.a(UHDDevice.o): In function `uhd_device::setTxFreq(double)':
/home/openbts/dev/openbts/Transceiver52M/UHDDevice.cpp:862: undefined reference to `uhd::tune_request_t::tune_request_t(double)'
/home/openbts/dev/openbts/Transceiver52M/UHDDevice.cpp:863: undefined reference to `uhd::tune_result_t::to_pp_string() const'
./.libs/libtransceiver.a(UHDDevice.o): In function `uhd_device::setRxFreq(double)':
/home/openbts/dev/openbts/Transceiver52M/UHDDevice.cpp:871: undefined reference to `uhd::tune_request_t::tune_request_t(double)'
/home/openbts/dev/openbts/Transceiver52M/UHDDevice.cpp:872: undefined reference to `uhd::tune_result_t::to_pp_string() const'
./.libs/libtransceiver.a(UHDDevice.o): In function `uhd_device::open(std::string const&, bool)':
/home/openbts/dev/openbts/Transceiver52M/UHDDevice.cpp:531: undefined reference to `uhd::device_addr_t::device_addr_t(std::string const&)'
/home/openbts/dev/openbts/Transceiver52M/UHDDevice.cpp:532: undefined reference to `uhd::device::find(uhd::device_addr_t const&, uhd::device::device_filter_t)'
/home/openbts/dev/openbts/Transceiver52M/UHDDevice.cpp:539: undefined reference to `uhd::device_addr_t::to_string() const'
/home/openbts/dev/openbts/Transceiver52M/UHDDevice.cpp:541: undefined reference to `uhd::usrp::multi_usrp::make(uhd::device_addr_t const&)'
./.libs/libtransceiver.a(UHDDevice.o): In function `stream_args_t':
/usr/local/include/uhd/stream.hpp:63: undefined reference to `uhd::device_addr_t::device_addr_t(std::string const&)'
./.libs/libtransceiver.a(UHDDevice.o): In function `uhd_device::open(std::string const&, bool)':
/home/openbts/dev/openbts/Transceiver52M/UHDDevice.cpp:543: undefined reference to `uhd::device_addr_t::to_string() const'
./.libs/libtransceiver.a(UHDDevice.o): In function `uhd_device::str_code(uhd::rx_metadata_t)':
/home/openbts/dev/openbts/Transceiver52M/UHDDevice.cpp:925: undefined reference to `uhd::time_spec_t::get_real_secs() const'
./.libs/libtransceiver.a(UHDDevice.o): In function `uhd_device::check_rx_md_err(uhd::rx_metadata_t&, long)':
/home/openbts/dev/openbts/Transceiver52M/UHDDevice.cpp:689: undefined reference to `uhd::time_spec_t::time_spec_t(double)'
/home/openbts/dev/openbts/Transceiver52M/UHDDevice.cpp:716: undefined reference to `uhd::operator<(uhd::time_spec_t const&, uhd::time_spec_t const&)'
/home/openbts/dev/openbts/Transceiver52M/UHDDevice.cpp:719: undefined reference to `uhd::time_spec_t::get_real_secs() const'
/home/openbts/dev/openbts/Transceiver52M/UHDDevice.cpp:718: undefined reference to `uhd::time_spec_t::get_real_secs() const'
./.libs/libtransceiver.a(UHDDevice.o): In function `uhd_device::readSamples(short*, int, bool*, unsigned long long, bool*, unsigned int*)':
/home/openbts/dev/openbts/Transceiver52M/UHDDevice.cpp:732: undefined reference to `uhd::time_spec_t::time_spec_t(double)'
./.libs/libtransceiver.a(UHDDevice.o): In function `rx_metadata_t':
/usr/local/include/uhd/types/metadata.hpp:37: undefined reference to `uhd::time_spec_t::time_spec_t(double)'
./.libs/libtransceiver.a(UHDDevice.o): In function `uhd::rx_metadata_t::reset()':
/usr/local/include/uhd/types/metadata.hpp:45: undefined reference to `uhd::time_spec_t::time_spec_t(double)'
./.libs/libtransceiver.a(UHDDevice.o): In function `uhd_device::readSamples(short*, int, bool*, unsigned long long, bool*, unsigned int*)':
/home/openbts/dev/openbts/Transceiver52M/UHDDevice.cpp:745: undefined reference to `uhd::time_spec_t::from_ticks(long long, double)'
/home/openbts/dev/openbts/Transceiver52M/UHDDevice.cpp:746: undefined reference to `uhd::time_spec_t::get_real_secs() const'
/home/openbts/dev/openbts/Transceiver52M/UHDDevice.cpp:781: undefined reference to `uhd::time_spec_t::get_real_secs() const'
/home/openbts/dev/openbts/Transceiver52M/UHDDevice.cpp:770: undefined reference to `uhd::get_version_string()'
./.libs/libtransceiver.a(UHDDevice.o): In function `uhd_device::str_code(uhd::async_metadata_t)':
/home/openbts/dev/openbts/Transceiver52M/UHDDevice.cpp:958: undefined reference to `uhd::time_spec_t::get_real_secs() const'
./.libs/libtransceiver.a(UHDDevice.o): In function `async_metadata_t':
/usr/local/include/uhd/types/metadata.hpp:169: undefined reference to `uhd::time_spec_t::time_spec_t(double)'
./.libs/libtransceiver.a(UHDDevice.o): In function `uhd_device::setPriority()':
/home/openbts/dev/openbts/Transceiver52M/UHDDevice.cpp:683: undefined reference to `uhd::set_thread_priority_safe(float, bool)'
collect2: error: ld returned 1 exit status
make[2]: *** [transceiver] Error 1
make[2]: Leaving directory `/home/openbts/dev/openbts/Transceiver52M'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/home/openbts/dev/openbts'
This is very symptomatic of having multiple competing UHD installations. Maybe you've installed UHD from your Linux Distro's repository and then installed UHD again, manually, atop? Or maybe you've installed it when building OpenBTS.
However, make sure that you've only got one installation that your build system will find, or else you'd see exactly what you're experiencing now.

Resources