Creating and plotting graphs in C++

E398b669a8b7f969fccd57df2775facd
0
Oyvind 101 Jan 29, 2007 at 08:26

Hello, folks!

In my master’s thesis, I will make a small application which communicates with an external unit, and shows the data in form of a graph on a screen. This application will be a part of the tool that is going to be used in my experiment.

First of all, I use C++ as programming language.

My problem is that there is very difficult to find good examples of libraries that work with my compiler. I use Visual Studio 2005 .NET. I have tried “koolplot”, “vogle” and another library in which I don’t remember the name of right now. None of them are accepted by my compiler.

I have tried to implement an example using the vogle library, but i get the error messages “error C2660: ‘vinit’ : function does not take 1 arguments” and other messages like this even if the documentation from vogle says that the parameters are right!
( http://www-h.eng.cam.ac.uk/help/tpl/graphics/vogle/node3.html )

So, we can fairly say that I am a little confused right now. :)

Does any of you know what I am doing wrong, or how to solve this problem? In case you do, I would be very thankful if you will give me some hints. ;)

Regards,
Oyvind

10 Replies

Please log in or register to post a reply.

Cd577ee1cb56aa2ad5645b7daa0a2830
0
eddie 101 Jan 29, 2007 at 09:00

I haven’t used said libraries, but can’t you look at the header definition for whichever functions you’re trying to use, and determine the proper parameters from that?

What exactly is your level of proficiency with C++?

E398b669a8b7f969fccd57df2775facd
0
Oyvind 101 Jan 29, 2007 at 11:27

@eddie

I haven’t used said libraries, but can’t you look at the header definition for whichever functions you’re trying to use, and determine the proper parameters from that?

I have taken a look at the header file (vogle.h) that I used, and it seems like the functions are defined different there than in the documentation (that I gave a link to). I have found a new package now with other files, where the functions are defined correctly, but I still get many compiler errors.

Errors like: “error LNK2019: unresolved external symbol “void __cdecl vinit(char *)” (?vinit@@YAXPAD@Z) referenced in function _main” is what I get now.

In my program, I have written:
vinit(“X11”);

and in vogle.h, the function is defined:
extern void vinit(char *device);
@eddie

What exactly is your level of proficiency with C++?

I had a couple of C++ courses when I took my bachelor of engineering degree some years ago, so I have mostly learned foundational C++ and object oriented programming in C++. I haven’t been working with graphical C++ before, so that is new to me.

E398b669a8b7f969fccd57df2775facd
0
Oyvind 101 Jan 29, 2007 at 14:19

Btw, is there a standard library in Visual Studio .NET that contains a possibility to create and plot graphs? I cannot find any, but my supervisor believes that there is one. :)

Cd577ee1cb56aa2ad5645b7daa0a2830
0
eddie 101 Jan 29, 2007 at 15:03

@Oyvind

Errors like: “error LNK2019: unresolved external symbol “void __cdecl vinit(char *)” (?vinit@@YAXPAD@Z) referenced in function _main” is what I get now.

In my program, I have written:
vinit(“X11”);

and in vogle.h, the function is defined:
extern void vinit(char *device);

What you’re witnessing are *linker* errors. In short, with that particular error, make sure you’re linking against the correct libraries, where said functions are defined.

No offense, but it sounds like you need a quick brush up on C++ and what the various warnings/errors imply. Visual Studio has very good help if you go look up the CXXX warning code you’re seeing (You should see something like “error C4278: error message here” – the C4278 is something you can look for in the help). Unresolved symbols and matching your calling code to what’s in the headers is a pretty basic problem to be having, so the help should be able to steer you along quite well.

Cd577ee1cb56aa2ad5645b7daa0a2830
0
eddie 101 Jan 29, 2007 at 15:05

@Oyvind

Btw, is there a standard library in Visual Studio .NET that contains a possibility to create and plot graphs? I cannot find any, but my supervisor believes that there is one. :)

I’m personally not familiar with one, but if there is one I’d expect it to be part of the .NET Framework. You’d have to be writing managed C++ at that point however.

E398b669a8b7f969fccd57df2775facd
0
Oyvind 101 Jan 29, 2007 at 15:09

Ok. Thanks, Eddie! :)

If anyone else has some more clues about graphs in Visual Studio (or graphs in general), please let me know. :)

A8433b04cb41dd57113740b779f61acb
0
Reedbeta 167 Jan 29, 2007 at 18:17

It might be easier for your C++ tool to communicate with Excel and use its graphing features rather than drawing graphs all by itself. I don’t know exactly how this can be done but I think Excel’s chart engine is exported as a COM object (or something like that) referred to as “Microsoft Graph”.

This of course supposes that you don’t mind being tied to Windows. In the case you want this to be GNU/Linux friendly, I’d just use gnuplot, which you can control with a shell script or something.

E398b669a8b7f969fccd57df2775facd
0
Oyvind 101 Jan 31, 2007 at 10:49

I got an advice to use the graphical library “gdi” to draw my graphs. Do anyone know what header files and such I need in order to code in gdi?

46407cc1bdfbd2db4f6e8876d74f990a
0
Kenneth_Gorking 101 Jan 31, 2007 at 15:07

GDI is what windows uses to render stuff, go to msdn for more details.

1adc0b2bb32c3f4bd30c509398464867
0
Cipher3D 101 Feb 06, 2007 at 07:13

If you want to plot graphs very easily, I suggest learning VPython instead. It has an extremely simple graph API that works well for scientific visualization type stuff.