DPlot Forum Index DPlot
http://www.dplot.com
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

undefined ref to AddData8

 
Post new topic   Reply to topic    DPlot Forum Index -> C, C++, C#
View previous topic :: View next topic  
Author Message
scotts



Joined: 06 Apr 2008
Posts: 2

PostPosted: Sun Apr 06, 2008 7:18 pm    Post subject: undefined ref to AddData8 Reply with quote

Using MinGw, I keep getting the following link error
C:\Program Files\MinGWStudio\AICont\Tst1.c:134: undefined reference to `DPlot_AddData8@24'
collect2: ld returned 1 exit status


If I comment out that line, the original DPLOT call works
I include DPlot.h, x is double x[500]. I mess around with the curve argument (use 0,1, or 2) without resolution


Any advice?

Code:
for(i=0; (x[i]=i)<=499; i++);
   printf("%f\n",x[499]);

         int NP=500;
         memset(&DPlot,0,sizeof(DPlot));
         DPlot.Version      = DPLOT_DDE_VERSION;
         DPlot.DataFormat   = DATA_XYXY;
         DPlot.MaxCurves      = 1;   // Must be >= number of curves we plot
         DPlot.MaxPoints      = 20000;   // Anything >= NP will do
         DPlot.NumCurves      = 1;
         DPlot.Scale         = SCALE_LINEARX_LINEARY;
         DPlot.LegendX      = 0.05f;
         DPlot.LegendY      = 0.05f;
         DPlot.NP[0]         = NP;
         //DPlot.NP[1]         = NP;
         DPlot.LineType[0]   = LINESTYLE_SOLID;
         
         DocNum = DPLOT_PLOT(&DPlot,x,x,"[ManualScale(0,-.50,1000,1000)][TickInterval(1,50,50)]"
         "[Caption(\"DPLOTLIB XY Test\")]"
         "[ClearEditFlag()]");
         for(i=0;i<500;i++)
            x[i]=i+500;
         
         //printf("%d\n", DATA_XYYY);
         
         DPlot_AddData8(DocNum,DATA_XYXY,500,0,x,x);  //THIS IS THE LINE 
Back to top
View user's profile Send private message
DPlotAdmin
Site Admin


Joined: 24 Jun 2003
Posts: 2310
Location: Vicksburg, Mississippi

PostPosted: Mon Apr 07, 2008 9:18 am    Post subject: Reply with quote

Using gcc (which I'm admittedly a complete novice with) I could never get an import library to work correctly. Your error message indicates that either you aren't using an import library at all, or you're having the same problems I did when trying to create one that would work.

If you look near the bottom of dplot.h you should see:

Code:
#ifdef __GNUC__

/* With GCC we'll resolve DPLOTLIB references at runtime rather than linking to an import library...
   mainly because I can't figure out how to create an import library for GCC that works properly!    */


followed by declarations for the various DPLOTLIB functions and the dPlot_Init function, which loads the DLL and gets the addresses of those functions.

Also take a look at the WinMain procedure in any of the C demo programs. dPlot_Init is called there. No import library is used and there won't be any "unresolved external" errors.

Please let me know whether this helps or not.
_________________
Visualize Your Data
support@dplot.com
Back to top
View user's profile Send private message Send e-mail Visit poster's website
scotts



Joined: 06 Apr 2008
Posts: 2

PostPosted: Mon Apr 07, 2008 11:32 am    Post subject: Reply with quote

I have the following in my code:

Code:
#ifdef __GNUC__
   HINSTANCE dll;
    if((dll = dPlot_Init()) == NULL)
   {
      printf("LoadLibrary for DPLOTLIB.DLL failed.\n");
      exit(0);
   }
#endif
FreeLibrary(dll);


I'm getting the same error whether I link to dplotlib.dll or not.

Do I need to change this??
Back to top
View user's profile Send private message
DPlotAdmin
Site Admin


Joined: 24 Jun 2003
Posts: 2310
Location: Vicksburg, Mississippi

PostPosted: Mon Apr 07, 2008 12:56 pm    Post subject: Reply with quote

I think I overlooked something: instead of calling DPlot_AddData8 you'll want to call dPlot_AddData8 (note d vs. D). The former is the actual name of the function; the latter is a trick that makes use of LoadLibrary/GetProcAddress rather than linking to an import library.
_________________
Visualize Your Data
support@dplot.com
Back to top
View user's profile Send private message Send e-mail Visit poster's website
sseidman



Joined: 24 Aug 2005
Posts: 8

PostPosted: Mon Apr 07, 2008 7:51 pm    Post subject: Reply with quote

That seems to have done it. Thanks. Any more of these little changes for the LoadLibrary that I might find?
Back to top
View user's profile Send private message
DPlotAdmin
Site Admin


Joined: 24 Jun 2003
Posts: 2310
Location: Vicksburg, Mississippi

PostPosted: Tue Apr 08, 2008 8:12 am    Post subject: Reply with quote

No, that's it. If you use a lower case d for all of the DPLOTLIB functions then everything should work correctly with gcc w/o linker errors.
_________________
Visualize Your Data
support@dplot.com
Back to top
View user's profile Send private message Send e-mail Visit poster's website
sseidman



Joined: 24 Aug 2005
Posts: 8

PostPosted: Tue Apr 08, 2008 8:09 pm    Post subject: Reply with quote

Everything sort of works now. Thanks. The only problem I'm having is that calls to dPlot_AddData8 really seem to be slowing down my app, and causing data acquisition buffer overruns, even adding 50 points at a time. I know this might be a tough debug, but I thought I'd just give it a shout out in case this is something you've seen before.

Thanks again
Back to top
View user's profile Send private message
DPlotAdmin
Site Admin


Joined: 24 Jun 2003
Posts: 2310
Location: Vicksburg, Mississippi

PostPosted: Tue Apr 08, 2008 10:08 pm    Post subject: Reply with quote

Whether 50 points is a lot or not of course depends on how often you're updating.

In general, though, everything will work much better if you use the ManualScale command with any real-time plotting. If you don't do that, then DPlot must examine your data to find the mins/maxes and redraw the entire plot after every call to DPlot_AddData. If you do use ManualScale, then the plot isn't redrawn; instead only line segments between the new points are added to the existing plot. If a new X exceeds the X extents then the plot window pans to the right. For this to work, though, you of course need to have a rough idea of what your Y extents will be.

You will probably also want to turn off antialiasing, which is a real performance hog. To turn it off use [GeneralOptions(32,0)].
_________________
Visualize Your Data
support@dplot.com
Back to top
View user's profile Send private message Send e-mail Visit poster's website
sseidman



Joined: 24 Aug 2005
Posts: 8

PostPosted: Wed Apr 09, 2008 7:47 am    Post subject: Reply with quote

This seems much closer!

I get a big dwell right at the beginning of my Data Acquisition, and then everything seems to be catching up nicely. I'm wondering if the original call to DPLOT takes a bunch of time after the graph is already up, and dPlot_AddData8 is actually quite speedy. I'll try putting in a sizable dwell after the first DPLOT call before starting Data Acquisition. Seems much more promising than things looked yesterday.

Thanks again. Looks to be a wonderful application for my needs.
Back to top
View user's profile Send private message
sseidman



Joined: 24 Aug 2005
Posts: 8

PostPosted: Wed Apr 09, 2008 8:22 am    Post subject: Reply with quote

The dwell seems to have done it. It needs to be somewhere between 30 and 50 seconds, and after that Add_Data seems quite able to keep up with at least 10 updates of 50 points per second.
Back to top
View user's profile Send private message
DPlotAdmin
Site Admin


Joined: 24 Jun 2003
Posts: 2310
Location: Vicksburg, Mississippi

PostPosted: Wed Apr 09, 2008 8:44 am    Post subject: Reply with quote

Quote:
The dwell seems to have done it. It needs to be somewhere between 30 and 50 seconds,...


I can't imagine why you'd need to put your app to sleep for 30 seconds with an XY plot. DPlot does go through a lot of initialization at startup, but certainly not 30 seconds' worth. Are you sure that there isn't some sort of timing issue causing your app to make many identical calls to DPlot_AddData with that first step?
_________________
Visualize Your Data
support@dplot.com
Back to top
View user's profile Send private message Send e-mail Visit poster's website
sseidman



Joined: 24 Aug 2005
Posts: 8

PostPosted: Wed Apr 09, 2008 10:36 am    Post subject: Reply with quote

I have a few different library calls from different libraries, and I have a feeling the loads are interfering with each other, and I have to wait while all this is being sorted out. I'm using National Instruments Daqmx drivers, and they seem to work nicely enough when they have the whole thread to themselves, but they don't seem to be playing nicely with others.

I know I should probably work on preloading all of these libraries, and not sleep in my main thread, but I'm not a great c programmer. I don't even know if the whole library gets loaded at linking, or whether everything gets resolved at the first call to the library (seems like the latter, though).

Anyhow, I moved my app to a function generator, and it's working pretty well. Thanks for all the help. I do notice a hiccup when I Add_Data8 that lies outside of the manually set y-axis range. It's easy enough for me to clip the plotted data to the manual range, but I'm passing the info along for development purposes.

As a next step, I think I'll grab control of the x-axis values and try to make the data scroll a bit more smoothly, instead of falling off the axis and jumping a half screen at a time. Looks like this will be a breeze.
Back to top
View user's profile Send private message
DPlotAdmin
Site Admin


Joined: 24 Jun 2003
Posts: 2310
Location: Vicksburg, Mississippi

PostPosted: Wed Apr 09, 2008 10:52 am    Post subject: Reply with quote

Quote:
As a next step, I think I'll grab control of the x-axis values and try to make the data scroll a bit more smoothly, instead of falling off the axis and jumping a half screen at a time. Looks like this will be a breeze.


Before spending too much time on that see the SetPanFraction command - that might do what you want.
_________________
Visualize Your Data
support@dplot.com
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    DPlot Forum Index -> C, C++, C# All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group