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

  1. #1
    Registered User
    Join Date
    Aug 2009
    Posts
    9

    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.

  2. #2
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,336
    Presumably if you have attempted to compile, you have errors. Fix the errors.

  3. #3
    Registered User
    Join Date
    Aug 2009
    Posts
    9
    Thanks for the reply.

    You are correct, there are many compile errors. I am confused because the source code has already been successfully compiled into a ".a" file - why would there be errors in a recompile?

    The first few error messages are copied below (there are 188 total messages). Does this mean anything to you?

    Code:
    ------ Build started: Project: libkoolplot, Configuration: Debug Win32 ------
    Compiling...
    koolplot.cpp
    c:\documents and settings\roberto\desktop\13aug\koolplot - for lib compile\koolplot\plotdata.h(125) : warning C4003: not enough actual parameters for macro 'min'
    c:\documents and settings\roberto\desktop\13aug\koolplot - for lib compile\koolplot\plotdata.h(125) : error C2059: syntax error : ')'
    c:\documents and settings\roberto\desktop\13aug\koolplot - for lib compile\koolplot\plotdata.h(125) : error C2334: unexpected token(s) preceding ':'; skipping apparent function body
    c:\documents and settings\roberto\desktop\13aug\koolplot - for lib compile\koolplot\plotdata.h(125) : error C2760: syntax error : expected '{' not ';'
    c:\documents and settings\roberto\desktop\13aug\koolplot - for lib compile\koolplot\plotdata.h(126) : warning C4003: not enough actual parameters for macro 'max'
    c:\documents and settings\roberto\desktop\13aug\koolplot - for lib compile\koolplot\plotdata.h(126) : error C2144: syntax error : 'double' should be preceded by '}'
    c:\documents and settings\roberto\desktop\13aug\koolplot - for lib compile\koolplot\plotdata.h(126) : error C2059: syntax error : ')'
    c:\documents and settings\roberto\desktop\13aug\koolplot - for lib compile\koolplot\plotdata.h(126) : error C2334: unexpected token(s) preceding ':'; skipping apparent function body
    c:\documents and settings\roberto\desktop\13aug\koolplot - for lib compile\koolplot\plotdata.h(126) : error C2760: syntax error : expected '{' not ';'
    c:\documents and settings\roberto\desktop\13aug\koolplot - for lib compile\koolplot\plotdata.h(127) : error C2144: syntax error : 'void' should be preceded by '}'
    c:\documents and settings\roberto\desktop\13aug\koolplot - for lib compile\koolplot\plotdata.h(127) : error C2143: syntax error : missing ')' before '{'
    c:\documents and settings\roberto\desktop\13aug\koolplot - for lib compile\koolplot\plotdata.h(127) : error C2059: syntax error : ')'
    c:\documents and settings\roberto\desktop\13aug\koolplot - for lib compile\koolplot\plotdata.h(127) : error C2143: syntax error : missing ';' before ')'
    c:\documents and settings\roberto\desktop\13aug\koolplot - for lib compile\koolplot\plotdata.h(127) : error C2143: syntax error : missing ')' before '{'
    c:\documents and settings\roberto\desktop\13aug\koolplot - for lib compile\koolplot\plotdata.h(127) : error C2334: unexpected token(s) preceding '{'; skipping apparent function body
    c:\documents and settings\roberto\desktop\13aug\koolplot - for lib compile\koolplot\plotdata.h(142) : warning C4002: too many actual parameters for macro 'max'
    c:\documents and settings\roberto\desktop\13aug\koolplot - for lib compile\koolplot\plotdata.h(142) : error C2226: syntax error : unexpected type 'Plotdata'
    c:\documents and settings\roberto\desktop\13aug\koolplot - for lib compile\koolplot\plotdata.h(142) : error C2334: unexpected token(s) preceding ':'; skipping apparent function body
    c:\documents and settings\roberto\desktop\13aug\koolplot - for lib compile\koolplot\plotdata.h(142) : error C2760: syntax error : expected '{' not ';'
    c:\documents and settings\roberto\desktop\13aug\koolplot - for lib compile\koolplot\plotdata.h(146) : warning C4002: too many actual parameters for macro 'min'
    c:\documents and settings\roberto\desktop\13aug\koolplot - for lib compile\koolplot\plotdata.h(146) : error C2144: syntax error : 'void' should be preceded by '}'
    c:\documents and settings\roberto\desktop\13aug\koolplot - for lib compile\koolplot\plotdata.h(146) : error C2226: syntax error : unexpected type 'Plotdata'
    c:\documents and settings\roberto\desktop\13aug\koolplot - for lib compile\koolplot\plotdata.h(146) : error C2334: unexpected token(s) preceding ':'; skipping apparent function body
    c:\documents and settings\roberto\desktop\13aug\koolplot - for lib compile\koolplot\plotdata.h(146) : error C2760: syntax error : expected '{' not ';'
    c:\documents and settings\roberto\desktop\13aug\koolplot - for lib compile\koolplot\plotdata.h(148) : error C2144: syntax error : 'bool' should be preceded by '}'
    c:\documents and settings\roberto\desktop\13aug\koolplot - for lib compile\koolplot\plotdata.h(149) : error C2143: syntax error : missing ')' before ';'
    c:\documents and settings\roberto\desktop\13aug\koolplot - for lib compile\koolplot\plotdata.h(149) : error C2059: syntax error : ')'
    c:\documents and settings\roberto\desktop\13aug\koolplot - for lib compile\koolplot\plotdata.h(149) : error C2143: syntax error : missing ';' before ')'
    c:\documents and settings\roberto\desktop\13aug\koolplot - for lib compile\koolplot\plotdata.h(149) : error C2143: syntax error : missing ')' before ';'
    c:\documents and settings\roberto\desktop\13aug\koolplot - for lib compile\koolplot\plotdata.h(149) : error C2238: unexpected token(s) preceding ';'
    c:\documents and settings\roberto\desktop\13aug\koolplot - for lib compile\koolplot\koolplot.cpp(198) : fatal error C1903: unable to recover from previous error(s); stopping compilation

  4. #4
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    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?
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  5. #5
    Registered User
    Join Date
    Aug 2009
    Posts
    9
    Quote Originally Posted by Elysia View Post
    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?
    Thank you for your reply!

    The build documentation provided is in the form of a makefile:

    Code:
    CC = gcc.exe
    
    libkoolplot.a: plotdata.o plotstream.o koolplot.o bgi_util.o
    	ar -rv libkoolplot.a plotdata.o plotstream.o koolplot.o bgi_util.o
    
    clean:
    	rm *.o 
    	rm *.exe 
    	rm libkoolplot.a
    
    CC_FLAGS = -x c++ -O3 -fno-rtti -fno-exceptions -fno-common -fshort-enums -pedantic-errors
    
    LINK_FLAGS = -lbgi -lgdi32 -lcomdlg32 -luuid -loleaut32 -lole32 -lstdc++ -lsupc++ 
    
    plotdata.o: Plotdata.cxx Plotdata.h
    	$(CC) $(CC_FLAGS) -c  Plotdata.cxx -o plotdata.o
    
    plotstream.o: Plotstream.cxx Plotstream.h Plotdata.h
    	$(CC) $(CC_FLAGS) -c  Plotstream.cxx -o plotstream.o
    
    koolplot.o: koolplot.c koolplot.h Plotstream.h Plotdata.h
    	$(CC) $(CC_FLAGS) -c  koolplot.c -o koolplot.o
    	
    bgi_util.o: bgi_util.cpp bgi_util.h
    	$(CC) $(CC_FLAGS) -c  bgi_util.cpp -o bgi_util.o
    
    kplot.o: kplot.c
    	$(CC) $(CC_FLAGS) -c  kplot.c -o kplot.o
    
    kplot.exe: kplot.o libkoolplot.a
    	$(CC)  -mwindows -o kplot.exe -s kplot.o libkoolplot.a $(LINK_FLAGS)
    
    all: kplot.exe
    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?

  6. #6
    Registered User
    Join Date
    May 2003
    Posts
    1,619
    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
    You ever try a pink golf ball, Wally? Why, the wind shear on a pink ball alone can take the head clean off a 90 pound midget at 300 yards.

  7. #7
    Ugly C Lover audinue's Avatar
    Join Date
    Jun 2008
    Location
    Indonesia
    Posts
    489
    We love macros! Yeah, we love macros!

    You may need Eclipse IDE help to highlight errors.

    Otherwise just click the topmost error in the built output and fix the errors.
    Just GET it OFF out my mind!!

  8. #8
    Registered User
    Join Date
    Aug 2009
    Posts
    9
    Quote Originally Posted by Cat View Post
    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
    I tried this, but the errors were exactly the same. Should I put this in every file that includes "plotdata.h"? I'll try that next and see what happens.

  9. #9
    Registered User
    Join Date
    Aug 2009
    Posts
    9
    Quote Originally Posted by audinue View Post
    We love macros! Yeah, we love macros!

    You may need Eclipse IDE help to highlight errors.

    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.

    Thanks!

  10. #10
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,336
    Quote Originally Posted by beRto. View Post
    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?

  11. #11
    Registered User
    Join Date
    Aug 2009
    Posts
    9
    Quote Originally Posted by tabstop View Post
    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)?

    Thanks for the continued help!

  12. #12
    Registered User
    Join Date
    Aug 2009
    Posts
    9
    Quote Originally Posted by Cat View Post
    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?

    Code:
    #ifndef Plotdata_H
    #define Plotdata_H
    
    #undef max
    #undef min 
    
    #include <cmath>
    #include <vector>
    #include <iostream>
    
    using namespace std;
    
    *****continues******

  13. #13
    Registered User
    Join Date
    Aug 2009
    Posts
    9
    So I got rid of the max/min macro problems (see previous post), and the remaining errors seem to be related to math functions. Specifically, there are 4 complaints of functions not defined:
    • 'round': identifier not found
      'remquol': identifier not found
      'trunc': identifier not found
      'isfinite': identifier not found


    I figured that all of these functions should be defined in <cmath>, which is included at several locations in the code. However, an online search indicated that <cmath> does not include a round function (how could this have compiled originally?):
    cmath (math.h) - C++ Reference
    C++ Programming :: What's up with rounding in cmath?!

    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!

    Code:
    ------ Build started: Project: libkoolplot, Configuration: Debug Win32 ------
    Compiling...
    koolplot.cpp
    Plotstream.cpp
    c:\documents and settings\roberto\desktop\13aug\koolplot - for lib compile\koolplot\plotstream.cpp(42) : warning C4305: 'initializing' : truncation from 'double' to 'const float'
    c:\documents and settings\roberto\desktop\13aug\koolplot - for lib compile\koolplot\plotstream.cpp(62) : warning C4996: 'strcpy': This function or variable may be unsafe. Consider using strcpy_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
            c:\program files\microsoft visual studio 9.0\vc\include\string.h(74) : see declaration of 'strcpy'
    c:\documents and settings\roberto\desktop\13aug\koolplot - for lib compile\koolplot\plotstream.cpp(147) : error C3861: 'round': identifier not found
    c:\documents and settings\roberto\desktop\13aug\koolplot - for lib compile\koolplot\plotstream.cpp(223) : error C3861: 'round': identifier not found
    c:\documents and settings\roberto\desktop\13aug\koolplot - for lib compile\koolplot\plotstream.cpp(225) : error C3861: 'round': identifier not found
    c:\documents and settings\roberto\desktop\13aug\koolplot - for lib compile\koolplot\plotstream.cpp(234) : error C3861: 'remquol': identifier not found
    c:\documents and settings\roberto\desktop\13aug\koolplot - for lib compile\koolplot\plotstream.cpp(236) : error C3861: 'remquol': identifier not found
    *****CONTINUES (90 errors total)*****

  14. #14
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,336
    Quote Originally Posted by beRto. View Post
    So I got rid of the max/min macro problems (see previous post), and the remaining errors seem to be related to math functions. Specifically, there are 4 complaints of functions not defined:
    • 'round': identifier not found
      'remquol': identifier not found
      'trunc': identifier not found
      'isfinite': identifier not found


    I figured that all of these functions should be defined in <cmath>, which is included at several locations in the code. However, an online search indicated that <cmath> does not include a round function (how could this have compiled originally?):
    cmath (math.h) - C++ Reference
    C++ Programming :: What's up with rounding in cmath?!

    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.

  15. #15
    Registered User
    Join Date
    Aug 2009
    Posts
    9
    Quote Originally Posted by tabstop View Post
    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?

    Thanks!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Problems passing a file pointer to functions
    By smitchell in forum C Programming
    Replies: 4
    Last Post: 09-30-2008, 02:29 PM
  2. sequential file program
    By needhelpbad in forum C Programming
    Replies: 80
    Last Post: 06-08-2008, 01:04 PM
  3. Formatting the contents of a text file
    By dagorsul in forum C++ Programming
    Replies: 2
    Last Post: 04-29-2008, 12:36 PM
  4. archive format
    By Nor in forum A Brief History of Cprogramming.com
    Replies: 0
    Last Post: 08-05-2003, 07:01 PM
  5. Making a LIB file from a DEF file for a DLL
    By JMPACS in forum C++ Programming
    Replies: 0
    Last Post: 08-02-2003, 08:19 PM