"Symbol Unresolved while linking Symbol"

Hi Everyone

I’m pretty new to Root so it is very well possible that I am asking a trivial/dumb question. However, I could not find a solution by myself for the following problem, even after extensive googling and going through the Root documentation, so I hope I will find a solution here - I’m already very thankful for your help! :slight_smile:

First off some Specs:
OS: Ubuntu 16.04
IDE: Codeblocks 16.01
Compiler: GNU GCC 5.4.0
Root Version: 6.10/00 (compiled from the sources)

General Description of the Problem:
I built a C++ project from the Scratch in Codeblocks, added the include paths, added the library paths, linked the Libraries.
I want to build a very simple GUI, using the root framework, that basically draws a chart once a textbutton is clicked.
For this, I build a new class “ui”, that contains all the GUI variables, a constructor and a function “push1” that draws the chart to the respective canvas.
Before Compiling, I run rootcling with the header in which the ui class is defined and the guiLinkDef.hh file containing the link definition, in order to generate a file “Dictoutput.cxx”, which is then also included into the codeblocks project.

If I put the definition of the function “push1” into the class “ui” (in the headerfile), everything works as it should.

However, once i only declare the function “push1” in the gui.hh header file, but put the definition in the gui.cpp file, I get the following error message:

IncrementalExecutor::executeFunction: symbol '_ZN2ui5push1Ev' unresolved while linking symbol '__cf_3'!
You are probably missing the definition of ui::push1()
Maybe you need to load the corresponding shared library?
Error in <TClingCallFunc::make_wrapper>: Failed to compile
  ==== SOURCE BEGIN ====
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wformat-security"
__attribute__((used)) extern "C" void __cf_3(void* obj, int nargs, void** args, void* ret)
#pragma clang diagnostic pop
  ==== SOURCE END ====
Error in <TClingCallFunc::Exec(address, interpVal)>: Called with no wrapper, not implemented!

What is the mistake I am making?
Here all the source codes of the project:


#include "TApplication.h"
#include "gui.hh"

int main()
  TApplication app{"test",0,0 };

  auto ui1 = new ui();
  return 0;



// Mainframe macro generated from application: C:\root_v5.34.36\bin\root.exe
// By ROOT version 5.34/36 on 2017-03-18 13:17:26

#ifndef ROOT_TGDockableFrame
#include "TGDockableFrame.h"
#ifndef ROOT_TGMenu
#include "TGMenu.h"
#ifndef ROOT_TGMdiDecorFrame
#include "TGMdiDecorFrame.h"
#ifndef ROOT_TG3DLine
#include "TG3DLine.h"
#ifndef ROOT_TGMdiFrame
#include "TGMdiFrame.h"
#ifndef ROOT_TGMdiMainFrame
#include "TGMdiMainFrame.h"
#ifndef ROOT_TGMdiMenu
#include "TGMdiMenu.h"
#ifndef ROOT_TGListBox
#include "TGListBox.h"
#ifndef ROOT_TGNumberEntry
#include "TGNumberEntry.h"
#ifndef ROOT_TGScrollBar
#include "TGScrollBar.h"
#ifndef ROOT_TGComboBox
#include "TGComboBox.h"
#ifndef ROOT_TGuiBldHintsEditor
#include "TGuiBldHintsEditor.h"
#ifndef ROOT_TRootBrowser
#include "TRootBrowser.h"
#ifndef ROOT_TGuiBldNameFrame
#include "TGuiBldNameFrame.h"
#ifndef ROOT_TGFrame
#include "TGFrame.h"
#ifndef ROOT_TGFileDialog
#include "TGFileDialog.h"
#ifndef ROOT_TGShutter
#include "TGShutter.h"
#ifndef ROOT_TGButtonGroup
#include "TGButtonGroup.h"
#ifndef ROOT_TGCommandPlugin
#include "TGCommandPlugin.h"
#ifndef ROOT_TGCanvas
#include "TGCanvas.h"
#ifndef ROOT_TGFSContainer
#include "TGFSContainer.h"
#ifndef ROOT_TGuiBldEditor
#include "TGuiBldEditor.h"
#ifndef ROOT_TGColorSelect
#include "TGColorSelect.h"
#ifndef ROOT_TGTextEdit
#include "TGTextEdit.h"
#ifndef ROOT_TGButton
#include "TGButton.h"
#ifndef ROOT_TGFSComboBox
#include "TGFSComboBox.h"
#ifndef ROOT_TGLabel
#include "TGLabel.h"
#ifndef ROOT_TGView
#include "TGView.h"
#ifndef ROOT_TGMsgBox
#include "TGMsgBox.h"
#ifndef ROOT_TRootGuiBuilder
#include "TRootGuiBuilder.h"
#ifndef ROOT_TGFileBrowser
#include "TGFileBrowser.h"
#ifndef ROOT_TGTab
#include "TGTab.h"
#ifndef ROOT_TGListView
#include "TGListView.h"
#ifndef ROOT_TGSplitter
#include "TGSplitter.h"
#ifndef ROOT_TGTextEntry
#include "TGTextEntry.h"
#ifndef ROOT_TGStatusBar
#include "TGStatusBar.h"
#ifndef ROOT_TGToolBar
#include "TGToolBar.h"
#ifndef ROOT_TGuiBldDragManager
#include "TGuiBldDragManager.h"
#ifndef ROOT_TGObject
#include "TGObject.h"

#include "Riostream.h"
#include "RQ_OBJECT.h"
#include "TCanvas.h"
#include "TRootEmbeddedCanvas.h"
#include "TF1.h"
#include "TObject.h"
#include "TApplication.h"

class ui{




void push1();

    TGMainFrame *fMainFrame1654;
    TGVerticalFrame *fVerticalFrame1325;
    TGHorizontalFrame *fHorizontalFrame1330 ;
    TGTextButton *fTextButton1353;
    TRootEmbeddedCanvas *fRootEmbeddedCanvas1337;



#include "gui.hh"

  // main frame
   fMainFrame1654 = new TGMainFrame(gClient->GetRoot(),10,10,kMainFrame | kVerticalFrame);

   // vertical frame
   fVerticalFrame1325 = new TGVerticalFrame(fMainFrame1654,577,559,kVerticalFrame);

   // horizontal frame
   fHorizontalFrame1330 = new TGHorizontalFrame(fVerticalFrame1325,573,26,kHorizontalFrame);
   fTextButton1353 = new TGTextButton(fHorizontalFrame1330,"fTextButton1353",-1,TGTextButton::GetDefaultGC()(),TGTextButton::GetDefaultFontStruct(),kRaisedFrame);
   fHorizontalFrame1330->AddFrame(fTextButton1353, new TGLayoutHints(kLHintsLeft | kLHintsTop,2,2,2,2));

   fVerticalFrame1325->AddFrame(fHorizontalFrame1330, new TGLayoutHints(kLHintsLeft | kLHintsTop | kLHintsExpandX,2,2,2,2));

   // embedded canvas
  fRootEmbeddedCanvas1337 = new TRootEmbeddedCanvas(0,fVerticalFrame1325,573,525,kSunkenFrame);
   Int_t wfRootEmbeddedCanvas1337 = fRootEmbeddedCanvas1337->GetCanvasWindowId();
   TCanvas *c123 = new TCanvas("c123", 10, 10, wfRootEmbeddedCanvas1337);
   fVerticalFrame1325->AddFrame(fRootEmbeddedCanvas1337, new TGLayoutHints(kLHintsLeft | kLHintsTop | kLHintsExpandX | kLHintsExpandY,2,2,2,2));

   fMainFrame1654->AddFrame(fVerticalFrame1325, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY,1,1,1,1));


   fTextButton1353->Connect("Clicked()", "ui",this,"push1()");

void ui::push1(){

   TF1 *fa1 = new TF1("fa1","sin(2*x)/x",0,10);


#ifndef guiLinkDef_h__
#define guiLinkDef_h__

#ifdef __CLING__
#pragma link off all globals;
#pragma link off all classes;
#pragma link off all functions;

#pragma link C++ class ui;
#pragma link C++ function ui::push1;


#endif // guiLinkDef_h__

The command I use to build the Dictionary:

rootcling -f DictOutput.cxx -c -p gui.hh guiLinkDef.hh

The dictionary file DictOutput.cxx that is generated by the above command:

// Do NOT change. Changes will be lost next time file is generated


#include <stddef.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include "RConfig.h"
#include "TClass.h"
#include "TDictAttributeMap.h"
#include "TInterpreter.h"
#include "TROOT.h"
#include "TBuffer.h"
#include "TMemberInspector.h"
#include "TInterpreter.h"
#include "TVirtualMutex.h"
#include "TError.h"

#ifndef G__ROOT
#define G__ROOT

#include "RtypesImp.h"
#include "TIsAProxy.h"
#include "TFileMergeInfo.h"
#include <algorithm>
#include "TCollectionProxyInfo.h"

#include "TDataMember.h"

// Since CINT ignores the std namespace, we need to do so in this file.
namespace std {} using namespace std;

// Header files passed as explicit arguments
#include "gui.hh"

// Header files passed via #pragma extra_include

namespace ROOT {
   static TClass *ui_Dictionary();
   static void ui_TClassManip(TClass*);
   static void delete_ui(void *p);
   static void deleteArray_ui(void *p);
   static void destruct_ui(void *p);

   // Function generating the singleton type initializer
   static TGenericClassInfo *GenerateInitInstanceLocal(const ::ui*)
      ::ui *ptr = 0;
      static ::TVirtualIsAProxy* isa_proxy = new ::TIsAProxy(typeid(::ui));
      static ::ROOT::TGenericClassInfo 
         instance("ui", "gui.hh", 132,
                  typeid(::ui), ::ROOT::Internal::DefineBehavior(ptr, ptr),
                  &ui_Dictionary, isa_proxy, 0,
                  sizeof(::ui) );
      return &instance;
   TGenericClassInfo *GenerateInitInstance(const ::ui*)
      return GenerateInitInstanceLocal((::ui*)0);
   // Static variable to force the class initialization
   static ::ROOT::TGenericClassInfo *_R__UNIQUE_DICT_(Init) = GenerateInitInstanceLocal((const ::ui*)0x0); R__UseDummy(_R__UNIQUE_DICT_(Init));

   // Dictionary for non-ClassDef classes
   static TClass *ui_Dictionary() {
      TClass* theClass =::ROOT::GenerateInitInstanceLocal((const ::ui*)0x0)->GetClass();
   return theClass;

   static void ui_TClassManip(TClass* ){

} // end of namespace ROOT

namespace ROOT {
   // Wrapper around operator delete
   static void delete_ui(void *p) {
      delete ((::ui*)p);
   static void deleteArray_ui(void *p) {
      delete [] ((::ui*)p);
   static void destruct_ui(void *p) {
      typedef ::ui current_t;
} // end of namespace ROOT for class ::ui

namespace {
  void TriggerDictionaryInitialization_DictOutput_Impl() {
    static const char* headers[] = {
    static const char* includePaths[] = {
    static const char* fwdDeclCode = R"DICTFWDDCLS(
#line 1 "DictOutput dictionary forward declarations' payload"
#pragma clang diagnostic ignored "-Wkeyword-compat"
#pragma clang diagnostic ignored "-Wignored-attributes"
#pragma clang diagnostic ignored "-Wreturn-type-c-linkage"
extern int __Cling_Autoloading_Map;
class __attribute__((annotate("$clingAutoload$gui.hh")))  ui;
    static const char* payloadCode = R"DICTPAYLOAD(
#line 1 "DictOutput dictionary payload"


#include "gui.hh"

    static const char* classesHeaders[]={
"ui", payloadCode, "@",

    static bool isInitialized = false;
    if (!isInitialized) {
        headers, includePaths, payloadCode, fwdDeclCode,
        TriggerDictionaryInitialization_DictOutput_Impl, {}, classesHeaders);
      isInitialized = true;
  static struct DictInit {
    DictInit() {
  } __TheDictionaryInitializer;
void TriggerDictionaryInitialization_DictOutput() {


And how do you build and link your application?

Cheers, Bertrand.

Hi Bertrand

Thanks for your answer.
I build and link my application in Codeblocks. I link in the Build Options of the Project (added the path to the root libraries in ProjectBuildOptions–>Search Directories–>Linker (Add the path to the ROOT library) and in ProjectBuildOptions–>Search Directories–>Compiler (Add the path to the ROOT include files) and in ProjectBuildOptions–>Linker Settings --> (Added the links to the Root Libraries).

Cheers, Andy

Could you simply try to build on the command line:

g++ `root-config --cflags --glibs` -o gui main.cpp gui.cc DictOutput.cxx

If it works, then there is an error in your Codeblocks configuration…

Just tried (renamed the file gui.cc to gui.cpp in the meantime, so I executed:

g++ `root-config --cflags --glibs` -o gui main.cpp gui.cpp DictOutput.cxx

… which leads to the following error: :confused:

/tmp/cc1ySlfp.o: In function `main':
main.cpp:(.text+0x43): undefined reference to `TApplication::TApplication(char const*, int*, char**, void*, int)'
main.cpp:(.text+0x73): undefined reference to `TApplication::Run(bool)'
main.cpp:(.text+0x87): undefined reference to `TApplication::~TApplication()'
main.cpp:(.text+0xbc): undefined reference to `TApplication::~TApplication()'
/tmp/cc1ySlfp.o: In function `__static_initialization_and_destruction_0(int, int)':
main.cpp:(.text+0x104): undefined reference to `TVersionCheck::TVersionCheck(int)'
/tmp/cc1ySlfp.o: In function `TApplicationImp::~TApplicationImp()':
main.cpp:(.text._ZN15TApplicationImpD2Ev[_ZN15TApplicationImpD5Ev]+0x24): undefined reference to `TString::~TString()'
/tmp/cc1ySlfp.o: In function `TApplicationImp::IsA() const':
main.cpp:(.text._ZNK15TApplicationImp3IsAEv[_ZNK15TApplicationImp3IsAEv]+0xd): undefined reference to `TApplicationImp::Class()'
/tmp/cc1ySlfp.o: In function `TApplicationImp::ShowMembers(TMemberInspector&) const':
main.cpp:(.text._ZNK15TApplicationImp11ShowMembersER16TMemberInspector[_ZNK15TApplicationImp11ShowMembersER16TMemberInspector]+0x11): undefined reference to `TApplicationImp::Class()'
main.cpp:(.text._ZNK15TApplicationImp11ShowMembersER16TMemberInspector[_ZNK15TApplicationImp11ShowMembersER16TMemberInspector]+0x27): undefined reference to `ROOT::Class_ShowMembers(TClass*, void const*, TMemberInspector&)'
/tmp/cc1ySlfp.o: In function `TCanvasImp::IsA() const':
main.cpp:(.text._ZNK10TCanvasImp3IsAEv[_ZNK10TCanvasImp3IsAEv]+0xd): undefined reference to `TCanvasImp::Class()'
/tmp/cc1ySlfp.o: In function `TCanvasImp::ShowMembers(TMemberInspector&) const':
main.cpp:(.text._ZNK10TCanvasImp11ShowMembersER16TMemberInspector[_ZNK10TCanvasImp11ShowMembersER16TMemberInspector]+0x11): undefined reference to `TCanvasImp::Class()'
main.cpp:(.text._ZNK10TCanvasImp11ShowMembersER16TMemberInspector[_ZNK10TCanvasImp11ShowMembersER16TMemberInspector]+0x27): undefined reference to `ROOT::Class_ShowMembers(TClass*, void const*, TMemberInspector&)'
/tmp/cc1ySlfp.o:(.rodata._ZTV10TCanvasImp[_ZTV10TCanvasImp]+0x100): undefined reference to `TCanvasImp::Streamer(TBuffer&)'
/tmp/cc1ySlfp.o:(.rodata._ZTV15TApplicationImp[_ZTV15TApplicationImp]+0x80): undefined reference to `TApplicationImp::Streamer(TBuffer&)'
/tmp/ccD8R4Hs.o: In function `ui::ui()':
gui.cpp:(.text+0x2d): undefined reference to `TGClient::Instance()'
gui.cpp:(.text+0x35): undefined reference to `TGClient::GetRoot() const'
gui.cpp:(.text+0x60): undefined reference to `TGMainFrame::TGMainFrame(TGWindow const*, unsigned int, unsigned int, unsigned int)'
gui.cpp:(.text+0x93): undefined reference to `TGFrame::GetDefaultFrameBackground()'
gui.cpp:(.text+0xfc): undefined reference to `TGFrame::GetDefaultFrameBackground()'
gui.cpp:(.text+0x165): undefined reference to `TGButton::GetDefaultGC()'
gui.cpp:(.text+0x16d): undefined reference to `TGGC::operator()() const'
gui.cpp:(.text+0x175): undefined reference to `TGTextButton::GetDefaultFontStruct()'
gui.cpp:(.text+0x1ae): undefined reference to `TGTextButton::TGTextButton(TGWindow const*, char const*, int, unsigned long, unsigned long, unsigned int)'
gui.cpp:(.text+0x313): undefined reference to `TGFrame::GetDefaultFrameBackground()'
gui.cpp:(.text+0x352): undefined reference to `TRootEmbeddedCanvas::TRootEmbeddedCanvas(char const*, TGWindow const*, unsigned int, unsigned int, unsigned int, unsigned long)'
gui.cpp:(.text+0x3c1): undefined reference to `TCanvas::TCanvas(char const*, int, int, int)'
gui.cpp:(.text+0x3dc): undefined reference to `TRootEmbeddedCanvas::AdoptCanvas(TCanvas*)'
gui.cpp:(.text+0x4c1): undefined reference to `TGMainFrame::SetMWMHints(unsigned int, unsigned int, unsigned int)'
gui.cpp:(.text+0x5bb): undefined reference to `TQObject::Connect(char const*, char const*, void*, char const*)'
gui.cpp:(.text+0x5cb): undefined reference to `TObject::operator delete(void*)'
gui.cpp:(.text+0x5de): undefined reference to `TObject::operator delete(void*)'
gui.cpp:(.text+0x5f1): undefined reference to `TObject::operator delete(void*)'
gui.cpp:(.text+0x604): undefined reference to `TObject::operator delete(void*)'
gui.cpp:(.text+0x614): undefined reference to `TObject::operator delete(void*)'
/tmp/ccD8R4Hs.o:gui.cpp:(.text+0x624): more undefined references to `TObject::operator delete(void*)' follow
/tmp/ccD8R4Hs.o: In function `ui::push1()':
gui.cpp:(.text+0x6f7): undefined reference to `TF1::TF1(char const*, char const*, double, double, TF1::EAddToList)'
gui.cpp:(.text+0x76d): undefined reference to `TObject::operator delete(void*)'
/tmp/ccD8R4Hs.o: In function `__static_initialization_and_destruction_0(int, int)':
gui.cpp:(.text+0x7ad): undefined reference to `TVersionCheck::TVersionCheck(int)'
/tmp/ccD8R4Hs.o: In function `TObject::operator new(unsigned long)':
gui.cpp:(.text._ZN7TObjectnwEm[_ZN7TObjectnwEm]+0x14): undefined reference to `TStorage::ObjectAlloc(unsigned long)'
/tmp/ccD8R4Hs.o: In function `TObject::TObject()':
gui.cpp:(.text._ZN7TObjectC2Ev[_ZN7TObjectC5Ev]+0xd): undefined reference to `vtable for TObject'
gui.cpp:(.text._ZN7TObjectC2Ev[_ZN7TObjectC5Ev]+0x5a): undefined reference to `TObject::fgObjectStat'
gui.cpp:(.text._ZN7TObjectC2Ev[_ZN7TObjectC5Ev]+0x6e): undefined reference to `TObject::AddToTObjectTable(TObject*)'
/tmp/ccD8R4Hs.o: In function `TQObjSender::TQObjSender()':
gui.cpp:(.text._ZN11TQObjSenderC2Ev[_ZN11TQObjSenderC5Ev]+0x15): undefined reference to `TQObject::TQObject()'
gui.cpp:(.text._ZN11TQObjSenderC2Ev[_ZN11TQObjSenderC5Ev]+0x1a): undefined reference to `vtable for TQObjSender'
gui.cpp:(.text._ZN11TQObjSenderC2Ev[_ZN11TQObjSenderC5Ev]+0x3d): undefined reference to `TString::TString()'
gui.cpp:(.text._ZN11TQObjSenderC2Ev[_ZN11TQObjSenderC5Ev]+0x4e): undefined reference to `TQObject::~TQObject()'
/tmp/ccD8R4Hs.o: In function `TQObjSender::~TQObjSender()':
gui.cpp:(.text._ZN11TQObjSenderD2Ev[_ZN11TQObjSenderD5Ev]+0xd): undefined reference to `vtable for TQObjSender'
gui.cpp:(.text._ZN11TQObjSenderD2Ev[_ZN11TQObjSenderD5Ev]+0x2f): undefined reference to `TQObject::Disconnect(char const*, void*, char const*)'
gui.cpp:(.text._ZN11TQObjSenderD2Ev[_ZN11TQObjSenderD5Ev]+0x3f): undefined reference to `TString::~TString()'
gui.cpp:(.text._ZN11TQObjSenderD2Ev[_ZN11TQObjSenderD5Ev]+0x4b): undefined reference to `TQObject::~TQObject()'
/tmp/ccD8R4Hs.o: In function `TGDimension::~TGDimension()':
gui.cpp:(.text._ZN11TGDimensionD2Ev[_ZN11TGDimensionD5Ev]+0xd): undefined reference to `vtable for TGDimension'
/tmp/ccD8R4Hs.o: In function `TGLayoutHints::TGLayoutHints(unsigned long, int, int, int, int)':
gui.cpp:(.text._ZN13TGLayoutHintsC2Emiiii[_ZN13TGLayoutHintsC5Emiiii]+0x40): undefined reference to `vtable for TGLayoutHints'
gui.cpp:(.text._ZN13TGLayoutHintsC2Emiiii[_ZN13TGLayoutHintsC5Emiiii]+0x4c): undefined reference to `vtable for TGLayoutHints'
/tmp/ccD8R4Hs.o: In function `TGVerticalFrame::TGVerticalFrame(TGWindow const*, unsigned int, unsigned int, unsigned int, unsigned long)':
gui.cpp:(.text._ZN15TGVerticalFrameC2EPK8TGWindowjjjm[_ZN15TGVerticalFrameC5EPK8TGWindowjjjm]+0x41): undefined reference to `TGCompositeFrame::TGCompositeFrame(TGWindow const*, unsigned int, unsigned int, unsigned int, unsigned long)'
gui.cpp:(.text._ZN15TGVerticalFrameC2EPK8TGWindowjjjm[_ZN15TGVerticalFrameC5EPK8TGWindowjjjm]+0x46): undefined reference to `vtable for TGVerticalFrame'
gui.cpp:(.text._ZN15TGVerticalFrameC2EPK8TGWindowjjjm[_ZN15TGVerticalFrameC5EPK8TGWindowjjjm]+0x52): undefined reference to `vtable for TGVerticalFrame'
gui.cpp:(.text._ZN15TGVerticalFrameC2EPK8TGWindowjjjm[_ZN15TGVerticalFrameC5EPK8TGWindowjjjm]+0x6b): undefined reference to `TGWindow::SetWindowName(char const*)'
gui.cpp:(.text._ZN15TGVerticalFrameC2EPK8TGWindowjjjm[_ZN15TGVerticalFrameC5EPK8TGWindowjjjm]+0x7c): undefined reference to `TGCompositeFrame::~TGCompositeFrame()'
/tmp/ccD8R4Hs.o: In function `TGHorizontalFrame::TGHorizontalFrame(TGWindow const*, unsigned int, unsigned int, unsigned int, unsigned long)':
gui.cpp:(.text._ZN17TGHorizontalFrameC2EPK8TGWindowjjjm[_ZN17TGHorizontalFrameC5EPK8TGWindowjjjm]+0x41): undefined reference to `TGCompositeFrame::TGCompositeFrame(TGWindow const*, unsigned int, unsigned int, unsigned int, unsigned long)'
gui.cpp:(.text._ZN17TGHorizontalFrameC2EPK8TGWindowjjjm[_ZN17TGHorizontalFrameC5EPK8TGWindowjjjm]+0x46): undefined reference to `vtable for TGHorizontalFrame'
gui.cpp:(.text._ZN17TGHorizontalFrameC2EPK8TGWindowjjjm[_ZN17TGHorizontalFrameC5EPK8TGWindowjjjm]+0x52): undefined reference to `vtable for TGHorizontalFrame'
gui.cpp:(.text._ZN17TGHorizontalFrameC2EPK8TGWindowjjjm[_ZN17TGHorizontalFrameC5EPK8TGWindowjjjm]+0x6b): undefined reference to `TGWindow::SetWindowName(char const*)'
gui.cpp:(.text._ZN17TGHorizontalFrameC2EPK8TGWindowjjjm[_ZN17TGHorizontalFrameC5EPK8TGWindowjjjm]+0x7c): undefined reference to `TGCompositeFrame::~TGCompositeFrame()'
/tmp/cc7TqHOy.o: In function `ROOT::GenerateInitInstanceLocal(ui const*)':
DictOutput.cxx:(.text+0x54): undefined reference to `TIsAProxy::TIsAProxy(std::type_info const&)'
DictOutput.cxx:(.text+0xae): undefined reference to `ROOT::Internal::DefineBehavior(void*, void*)'
DictOutput.cxx:(.text+0xda): undefined reference to `ROOT::TGenericClassInfo::TGenericClassInfo(char const*, char const*, int, std::type_info const&, ROOT::Internal::TInitBehavior const*, TClass* (*)(), TVirtualIsAProxy*, int, int)'
DictOutput.cxx:(.text+0xf7): undefined reference to `ROOT::TGenericClassInfo::~TGenericClassInfo()'
DictOutput.cxx:(.text+0x10b): undefined reference to `ROOT::TGenericClassInfo::SetNew(void* (*)(void*))'
DictOutput.cxx:(.text+0x11a): undefined reference to `ROOT::TGenericClassInfo::SetNewArray(void* (*)(long, void*))'
DictOutput.cxx:(.text+0x129): undefined reference to `ROOT::TGenericClassInfo::SetDelete(void (*)(void*))'
DictOutput.cxx:(.text+0x138): undefined reference to `ROOT::TGenericClassInfo::SetDeleteArray(void (*)(void*))'
DictOutput.cxx:(.text+0x147): undefined reference to `ROOT::TGenericClassInfo::SetDestructor(void (*)(void*))'
/tmp/cc7TqHOy.o: In function `ROOT::ui_Dictionary()':
DictOutput.cxx:(.text+0x1d5): undefined reference to `ROOT::TGenericClassInfo::GetClass()'
/tmp/cc7TqHOy.o: In function `(anonymous namespace)::TriggerDictionaryInitialization_DictOutput_Impl()':
DictOutput.cxx:(.text+0x5b1): undefined reference to `TROOT::RegisterModule(char const*, char const**, char const**, char const*, char const*, void (*)(), std::vector<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, int>, std::allocator<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, int> > > const&, char const**)'
/tmp/cc7TqHOy.o: In function `__static_initialization_and_destruction_0(int, int)':
DictOutput.cxx:(.text+0x64c): undefined reference to `TVersionCheck::TVersionCheck(int)'
collect2: error: ld returned 1 exit status

And what is the result of root-config --cflags --glibs?

Please see below:

-pthread -std=c++11 -m64 -I/home/andreas/Software/Root/include -L/home/andreas/Software/Root/lib -lGui -lCore -lRIO -lNet -lHist -lGraf -lGraf3d -lGpad -lTree -lRint -lPostscript -lMatrix -lPhysics -lMathCore -lThread -lMultiProc -pthread -lm -ldl -rdynamic

(i installed root to this directory so the path is correct)

It’s weird, it really looks like it doesn’t link against the ROOT libraries. For me it works just fine…

Yes, really weird error that already bothers me for 2 days :stuck_out_tongue:
What happends when you execute the program and push the button? does it draw?

It confuses me that the compilation works from Codeblocks, and the gui starts, just when i click the button, I get the error.

Even more confusing is that this error doesnt show up when I define the function push1() in the headerfile gui.h instead of gui.cpp… then everything works fine.

Is it possible that root wasn’t compiled properly or there is some problem with the configuration of root paths?

edit: or any problems with the configuration of cling maybe?
I also tried a different compiler (LLVM Clang) and a different IDE (QT Creator) - same issue.

I’ll investigate and let you know

With ROOT master it works, when pushing the button it draws a TF1…
BTW, which version of ROOT are you using?
(and can you replace TApplication app{"test", 0, 0}; by TApplication app("test", 0, 0); in main.cpp?)

I can replace the curly brackets with the normal ones, yes - but the result stays the same. (no compiler error but the same error message when the button is clicked.

I am using Root 6.10/00.

OK, I’ll try 6.10.00. Which platform/compiler?


No LSB modules are available.
Distributor ID:	Ubuntu
Description:	Ubuntu 16.04.2 LTS
Release:	16.04
Codename:	xenial


gcc (Ubuntu 5.4.0-6ubuntu1~16.04.4) 5.4.0 20160609
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO

IDE: Codeblocks:

Starting Code::Blocks Release 16.01  rev 10760 Feb  2 2016, 03:15:41 - wx2.8.12 (Linux, unicode) - 64 bit


gcc (Ubuntu 5.4.0-6ubuntu1~16.04.4) 5.4.0 20160609
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO

So it works fine for me with ROOT v6.10/00 on CentOS7 gcc4.8

as a quick thing to try can you change the compilation command from:

g++ `root-config --cflags --glibs` -o gui main.cpp gui.cpp DictOutput.cxx


g++ -o gui main.cpp gui.cpp DictOutput.cxx `root-config --cflags --glibs` 

(I’m not crazy, order matters :stuck_out_tongue: )

1 Like

Thanks @eguiraud, this fixes the issue for me (I just tried on a new Ubuntu VM, and managed to reproduce the issue…)

WOW, thank you so much, it finally works now!

Could you elaborate what exactly is going on that this issue appears?
Because I still don’t understand why the problem only arises if I define the function push1() outside of the class / in a source file. defining the constructor outside of the class on the other hand doesn’t create an issue…

Thx so much, also to bellenot for all the effort.

The problem only appears if push1() is defined in a source file because that is the case in which you have to resolve the push1 symbol at linking time (the last step required to produce an executable, which happens after compilation, see e.g. here).

About why the order matters when linking, from the gcc manual here:

-l library
Search the library named library when linking. (The second alternative with the library as a separate argument is only for POSIX compliance and is not recommended.)
It makes a difference where in the command you write this option; the linker searches and processes libraries and object files in the order they are specified. Thus, foo.o -lz bar.o searches library z after file foo.o but before bar.o. If bar.o refers to functions in z, those functions may not be loaded.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.