ASE Home Page Products Download Purchase Support About ASE
ChartDirector Support
Forum HomeForum Home   SearchSearch

Message ListMessage List     Post MessagePost Message

  error : undefined reference to ' '
Posted by thibault on Sep-15-2021 20:06
Hi,

I installed ChartDirector in my linux (x86_64) ubuntu 18 for qtCreator.

I setup the following paths:

INCLUDEPATH += /opt/ChartDirector/include

LIBS += -L[/opt/ChartDirector/lib]

But the compilation fails when I want to use chart function like:

Chart::chartTime2(...)

XYChart *c = new XYChart(....)

It's saying error : undefined reference to ' ' and nothing works

  Re: error : undefined reference to ' '
Posted by Peter Kwan on Sep-16-2021 01:23
Hi thibault,

In ChartDirector for C++, there is a simple Qt project in "ChartDirector/qtdemo/helloworld". Have you tried it? You can use qtCreator to open the qt project file at "ChartDirector/qtdemo/helloworld/helloworld.pro" and compile and run it. Please let me know if the helloworld sample code works in your machine.

If the helloworld sample code works, it confirms ChartDirector works on your machine. For your case, I think there may be some issue in the project file. The followings are the key lines in the helloworld project file:

INCLUDEPATH += ../../include
LIBS += -L../../lib -lchartdir
QMAKE_RPATHDIR += ../../lib

For your case, it seems you have not linked with the ChartDirector shared object "libchartdir.so", so there will be undefined reference to every ChartDirector function that you use. Please add "-lchartdir" to link to the ChartDirector shared object. I suggest to use:

INCLUDEPATH += /opt/ChartDirector/include
LIBS += -L/opt/ChartDirector/lib -lchartdir

Also, it seems you have not specified the runtime path. Note that the LIBS is only used by the linker to link your code. It tells the linker which shared object to use and the search path to find the shared object. So the code can compile and link successfully. However, it does not tell the executable where to find the shared object. So when you run the executable, it still cannot find the shared object. You have to either set the runtime path so that the executable can find the shared object at runtime, like:

QMAKE_RPATHDIR += /opt/ChartDirector/lib

Alternatively, you can copy the "libchartdir.so*" (including libchartdir.so, libchartdir.so.7 and libchartdir.so.7.0.0) to the default search path of your operating system, such as to "/usr/lib".  In this way, you do not need to specify the runtime search path QMAKE_RPATHDIR or the link time search path -L/opt/ChartDirector/lib.

Regards
Peter Kwan