koolplot - looking for library file for Visual C++ Express

This is a discussion on koolplot - looking for library file for Visual C++ Express within the C++ Programming forums, part of the General Programming Boards category; Hello,
I am trying to get koolplot ( Simplest Graph Plotting for C or C++ ) to work with Visual ...

koolplot - looking for library file for Visual C++ Express

Hello,

I am trying to get koolplot (Simplest Graph Plotting for C or C++) to work with Visual Express. The site provides a linux library file (libkoolplot.a), and I am trying to recompile the code to generate a Windows library file instead (e.g. libkoolplot.lib). Unfortunately, I just can't get this to work.

koolplot also requires the WinBGIm library (WinBGIm - Borland BGI emulation for MingW). Similarly, the WinBGIm site provides a ".a" library file. In this case, I was able to successfully recompile WinBGIm to generate a ".lib" file and I can now use the WinBGIm commands. I would like to do the same with koolplot!

Does anyone have a compiled ".lib" koolplot file that will work with Visual Express? Can anyone shed some light on the steps required to get koolplot to compile into a .lib?

Thanks!

p.s. I am new to programming, so please let me know if there are any problems with my plan/process.

While they do mean something to me, it's hard to pinpoint why they occur.
Like the macro error - the code is passing too many parameters to a macro (ie passing 3 parameters when it expects 2). It could be that there are several versions of the macro in different headers and you include the wrong header, for example.
Syntax errors are impossible to predict why they occur without seeing actual code.

It could be that they are using some build system. Or some language extensions. Or something else. Impossible to say.
Is there any documentation on how to build it?

While they do mean something to me, it's hard to pinpoint why they occur.
Like the macro error - the code is passing too many parameters to a macro (ie passing 3 parameters when it expects 2). It could be that there are several versions of the macro in different headers and you include the wrong header, for example.
Syntax errors are impossible to predict why they occur without seeing actual code.

It could be that they are using some build system. Or some language extensions. Or something else. Impossible to say.
Is there any documentation on how to build it?

Based on the makefile, I understood that the library file I am trying to generate depends on 4 files:

plotdata.o
plotstream.o
koolplot.o
bgi_util.o

So I copied those (4) .cpp files and their corresponding (4) .h files into Visual Express. I then tried to build and received the series of errors. I am not sure how I would have introduced syntax errors, but obviously something is wrong. Did I misinterpret the makefile? Maybe I included some unnecessary files, or excluded something important?

I know that koolplot depends on winBGIm. I have added my winBGIm library file to the include path, but I did not add it with a linker (the linker did not seem to be available in "static library" mode). Could it be something related to this?

Otherwise just click the topmost error in the built output and fix the errors.

I don't mind working through errors; but, I am confused asabout why there would be errors in the source code. Given that the files were previously compiled successfully into a ".a" library with minGW, why would there be macro errors in Visual C++? Is this typical/possible? I just want to make sure I am not "fixing" problems that do not exist.

I don't mind working through errors; but, I am confused asabout why there would be errors in the source code. Given that the files were previously compiled successfully into a ".a" library with minGW, why would there be macro errors in Visual C++? Is this typical/possible? I just want to make sure I am not "fixing" problems that do not exist.

Thanks!

Welcome to the world of "compiler-specific" and "implementation defined". There's probably a way in Visual Studio to turn off compiler extensions (which is what min/max are), I just don't remember what it is. Somewhere in project options -- linker maybe?

Welcome to the world of "compiler-specific" and "implementation defined". There's probably a way in Visual Studio to turn off compiler extensions (which is what min/max are), I just don't remember what it is. Somewhere in project options -- linker maybe?

OK, so the problems could be compiler specific. I searched for a means to turn off compiler extensions, but no luck yet. There is no "linker" available in the project options because I selected static library as the project type. Could this be a problem - is static library the right project type? I think so, because I am trying to build a .lib, but I could be wrong.

Where should I search for the max/min macros that are causing problems? Would these necessarily be in my code, or could they be in another library that is being referenced (e.g. a standard library etc)?

It looks like there are macros called "max" and "min" screwing things up.

Before the #include "plotdata.h" line throw this:

#undef max
#undef min

Well, I tried something else by putting the #undef lines at the top of the actual Plotdata.h file. I'm not sure if that's what you meant, but doing so eliminated all of the max/min macro problems! Will there be any unintended consequences to this, or is it ok to put them in Plotdata.h?

I then tried changing all of the <cmath> includes to <math.h>, but this did not solve the problem.

Another online forum had a thread that said "Round doesn't work with Microsoft Visual Studio, and I suspect it probably doesn't work with many other Windows C++ compilers (i.e. I can't find it in the Borland C manual). "round - Math.h - C Reference with Worked Examples
Why would there be a conflict using these math functions in Visual C++?

Does anyone have ideas on how I should proceed? It seems like the remaining problems are relatively minor - I just need the program to recognize these standard math functions!

I then tried changing all of the <cmath> includes to <math.h>, but this did not solve the problem.

Another online forum had a thread that said "Round doesn't work with Microsoft Visual Studio, and I suspect it probably doesn't work with many other Windows C++ compilers (i.e. I can't find it in the Borland C manual). "round - Math.h - C Reference with Worked Examples
Why would there be a conflict using these math functions in Visual C++?

Does anyone have ideas on how I should proceed? It seems like the remaining problems are relatively minor - I just need the program to recognize these standard math functions!

Ah. So, there's C, and then there's C. Or to be more specific, there's the 1989 version of C, and the 1999 version of C. round, and remquo, and trunc, and isfinite all appear in the 1999 version, but not the 1989 version. And C++ (and consequently <cmath>) appeared after 1989, but before 1999 (at least as far as ISO is concerned), so the 1999 additions are not available.

That said, many C++ compilers also have new-style C compilers, so those 1999 features are available in C++ as well. VS is not one of them.

Ah. So, there's C, and then there's C. Or to be more specific, there's the 1989 version of C, and the 1999 version of C. round, and remquo, and trunc, and isfinite all appear in the 1999 version, but not the 1989 version. And C++ (and consequently <cmath>) appeared after 1989, but before 1999 (at least as far as ISO is concerned), so the 1999 additions are not available.

That said, many C++ compilers also have new-style C compilers, so those 1999 features are available in C++ as well. VS is not one of them.

hmmm... so if I understood you correctly, the VS compiler does not include features that would allow me to use these math functions (round, trunc, etc)? In that case, what can I do? Given that I want to use VS, is there a workaround? Maybe I need to redefine these functions myself?

Are these functions available in Quincy, code::break, or similar? If I used one of those programs to generate the .lib file, could I then use that same .lib file in VS?