Hi Peter,

See below.

Regards,

Arjen

From: Peter Williams <petesweet2...@gmail.com>
Sent: 22 July 2020 21:39
To: plplot-general@lists.sourceforge.net
Subject: [Plplot-general] Linking in Linux

Hello Plplot
I am at present migrating some PlPlot programs from Windows 10 to linux (mint 
64 bit),
To facilitate this I have downloaded cmake and Plplot-5.15.0.tar.gz from your 
website.
Following the instructions from your wiki I built an installation consisting of 
static
libraries. In order to test the installation  I wrote a very simple program 
PlPlotTest.c:

#include <stdio.h>
#include "plplot.h"
int main()
{
 printf("Plotting example\n");
 plsdev("ps"); plsfnam("TestPlplot.ps");plinit();
 plenv(-1.0 , 1.0 ,-1.0,1.0,1,2);
 pljoin(-0.5,-0.5,0.5,0.5);
 plend();
 printf("Plot finished\n");
 return 1;
}
and attempted to compile it with

gcc -c -I /home/peter/plplot/install_directory/include/plplot PlPlotTest.c
gcc -o PlPlotTest.exe PlPlotTest.o  -L /home/peter/plplot/install_directory/lib 
 -lplplot -lcsirocsa  -lqsastime -lm -lX11

An object file PlPlotTest.o was generated with no errors, but the linking 
failed with the messages:

/usr/bin/ld: /home/peter/plplot/install_directory/lib/libplplot.a(xwin.c.o): in 
function `plD_init_xw':
xwin.c:(.text+0x470): undefined reference to `pthread_mutexattr_init'

/usr/bin/ld: xwin.c:(.text+0x481): undefined reference to 
`pthread_mutexattr_settype'
/usr/bin/ld: xwin.c:(.text+0x519): undefined reference to `pthread_create'
/usr/bin/ld: /home/peter/plplot/install_directory/lib/libplplot.a(xwin.c.o): in 
function `plD_tidy_xw':
xwin.c:(.text+0xcd0): undefined reference to `pthread_cancel'
/usr/bin/ld: xwin.c:(.text+0xcec): undefined reference to `pthread_join'
collect2: error: ld returned 1 exit status

>>AM: These unresolved symbols are from the pthreads library. I am not sure 
>>why, but CMake has decided that you should use pthreads – the xwin.c source 
>>file contains a macro PL_USE_PTHREADS_XWIN. And when that is defined at 
>>compile time, from the configuration file, the relevant code is compiled in.

The solution is therefore: add -lpthread as a link option (not -lpthreads 😊).

DISCLAIMER: This message is intended exclusively for the addressee(s) and may 
contain confidential and privileged information. If you are not the intended 
recipient please notify the sender immediately and destroy this message. 
Unauthorized use, disclosure or copying of this message is strictly prohibited. 
The foundation 'Stichting Deltares', which has its seat at Delft, The 
Netherlands, Commercial Registration Number 41146461, is not liable in any way 
whatsoever for consequences and/or damages resulting from the improper, 
incomplete and untimely dispatch, receipt and/or content of this e-mail.
_______________________________________________
Plplot-general mailing list
Plplot-general@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/plplot-general

Reply via email to