How to build a koolplot library using VC++ 2010 - c++

I want to use simple plotting functions in my C++ code. Presently I am using Qt5 with VS2010 c++ compiler. I came across this library called koolplot. But I cannot buid it with VS2010 from its source files. I am opening vs2010 cmd and running nmake...It shows winbgim.h missing..I copied that header in MinGW include folder and ran it ...now it shows "Plotdata.h:warning: 'typedef' was ignored in this declaration" Please help...if any one knows a simple plotting library running with VS2010 please suggest..

According to its website, Koolplot is designed for the MinGW/gcc toolchain - you'll have to do a bit of leg work to get it to compile on Visual Studio, though I don't know specifically what you'd have to do without taking a closer look.
Also, the library seems to do its own window management and the like, so I'm not sure how well you'll be able to integrate it with Qt.

koolplot needs WinBGI library (BGI = Borland Graphics Interface?).
I have changed it to use native Win32 using VS2008:
http://www.tu-chemnitz.de/~heha/hs/koolplot-heha.zip/
It's still incomplete as a good Win32 implementation would implement koolplot in a DLL which self-registers a Window class, and has both C and C++ interface. Moreover, koolplot as-is doesn't support multiple scales, finer plotting options, GDIplus, and fast data update, so it's not the right thing to write an oscilloscope program.
It's C++ code is also outdated as there are lambda functions available now.
However, good integrating into Qt is another task.

Related

Embarcadero windows libraries and packages

This is my first time with Embarcadero RAD Studio (C++, not Delphi) and, despite of many searches on its site and the rest of Internet, I'm still confused with some concepts.
My goal, by now, is to set a OpenGL Core Profile and go on with OGL stuff (which I'm acquainted with). With other IDE/Compiler I'd add the opengl32 library, use wglCreateContextAttribsARB and glew.
Digging into Embarcadero files I find C:\Program Files (x86)\Embarcadero\Studio\20.0\lib\win32\release\psdk\opengl32.lib, C:\Program Files (x86)\Embarcadero\Studio\20.0\lib\win32c\release\psdk\opengl32.lib (note the 'c' after win32, what's that?) and C:\Program Files (x86)\Embarcadero\Studio\20.0\lib\win64\release\psdk\opengl32.a
So I suppose I could just "Project->Add to Project..." the library, instead of "import" from Windows system as it seems was needed many years ago. But I'm confused because RAD may add the required libs on its own, at least for controls, right?
But I've meet with ".pas" files, which seems to load anything needed. Actually, the C:\Program Files (x86)\Embarcadero\Studio\20.0\source\rtl\win\Winapi.OpenGLext.pas seems enough, so I could avoid glew. My confusion is that I don't know if a ".pas" file can be used (and how) for VCL C++, not Firemonkey, not Delphi.
I have not be able to find wglCreateContextAttribsARB, nor a replacement for setting a Core Profile context.
Summarizing:
Do I need to add system libs? How?
How to use ".pas" files?
Which is the difference between win32 and win32c dirs?
How to set a OGL Core Profile context? I mean, should I go with the route of retrieving a function pointer to
wglCreateContextAttribsARB or RAD provides another way?
Does RAD provide for C++ a replacement of glew?
1.Do I need to add system libs? How?
Normally yes. unless you are using a component that has taken care of adding the library. In Win32 you have to use #pragma link "opengl32.lib" and in win64 you have to add #pragma link "opengl32.a" to your cpp code.
2.How to use ".pas" files?
You do not need to add the files in the source directory to your project. Embarcadero is nice enough to include the source code for most of its components with the product. This is so you could understand how it works and if you need to change some behavior you can create a new class derived from the class that you want and override the function in question. In general C++ builder allows adding Pascal units to C++ project and it will take care of creating the header file automatically. But in your case it is not necessary.
3.Which is the difference between win32 and win32c dirs?
C++ builder comes with 2 32 bit compilers for Windows. One is clang based and supports C++14 and the libraries that have been compiled with it are in win32 directory. The other one is the classic compiler and the libraries that have been compiled with it are in win32c directory. Unless you have checked the "Use Classic Compiler" in project settings, you don't have to worry about it.
4.How to set a OGL Core Profile context? I mean, should I go with the route of retrieving a function pointer to wglCreateContextAttribsARB
or RAD provides another way?
I'm not aware of any components that RAD studio may provide. You should search https://torry.net/ or http://www.delphipages.com/ or many more places that exists out there for a component that helps you whith what you need.
5.Does RAD provide for C++ a replacement of glew?
What is "glew"?

Link c++ object during runtime?

I'm trying to write my first game in c++, and I want it to dynamically load everything from files. This includes the enemies, and I was wondering if there was a way to dynamically include their code at runtime, instead of linking the on compile, so that the levels are easily interchangeable. Lua might be an option but I have no clue where to start, and dll seems to be Windows-only (and I wouldn't know where to start there anyway). Can anyone help with this?
tl;dr I want to link in code to my c++ game at runtime.
For the Lua approach you first need to choose the version first. Right now there is the major version 5.1 and 5.2. My previous work was using 5.1 and for my new project I decided to update to 5.2, however I found that my favorite script wrapping tool (SWIG) does not work with 5.2. Just something to decide at the beginning, because you do not want to get a version working and then have to change it.
Lua comes with makefile build environment. My first experience of trying to build on Windows was a bit of a nightmare, did not appear to just run out-of-the-box, so I opted to create my own Visual Studio project at the time, and just include all the .C files in the project. There are two files which need to selectively included/excluded depending on how you intend to compile: lua.c and luac.c. If you are planning to embed Lua in your app, then exclude both of these files; they both contain a main() function and are designed to build console apps. Include all the rest of the C files in your project.
You should be able to compile easy from this point.
When you include the headers of Lua, keep in mind that the functions are C functions so if you are including them from C++ you need to wrap the file inclusion inside of: extern "C" {} - example: C++ Lua 5.1 Issue
Wrapping your interfaces in another topic and there are lots of resources available. My favorite is SWIG but there are lots of options, including hand coding the conversion of your C/C++ -> LUA -> C/C++ code. Would recommend just focusing on getting the first part working first, get the interpreter embedded so that you can run a "hello, world!" script from Lua inside your app.
So going by your requirement of crossplatform use and dynamic linking, what you're probably looking for is an environment like QT which has QLibrary: https://stackoverflow.com/a/9675063/453673
But https://softwareengineering.stackexchange.com/questions/88685/why-arent-more-desktop-apps-written-with-qt
MingW is the open-source equivalent for Visual C++, so it can help you writing code for Windows (though if I had a choice, I'd directly use Visual C++). The way dll's are loaded in Windows is somewhat similar to the way they're loaded in Linux, so you'll be able to write code with #ifdef's to do conditional compilation. I've written one such program a couple of years back.
To load a shared library(always with .so as suffix) under Linux, you could use dlopen(), dlsym() and dlclose()

GUI C++ Qt with Visual Studio 2010

I'm developing a C++ application that needs a GUI. I would like to use the Windows 7 Ribbon Framework, so I'm not interested in having my app compatible with OS different that windows. I would like to also use my preferred IDE, Visual Studio 2010 and obviously I would like to use standard C++ things like std::string, etc. I saw that there is Qt, it seems cool but as I understand I shoud use it with their own compiler because they provide some things that are not part of the standard c++ (slots keyword for example). Plus, I saw that I can use a QWinHost to host win32 controls but I'm not sure if I can host the ribbon control. Should I implement myself a little library to simply manage native win32 controls or should I go with Qt?
but as I understand I shoud use it with their own compiler
Nope, that's incorrect. You'll use your compiler - be it microsoft compiler, mingw-g++ or something else, as long as it is supported by Qt.
Qt provides their own additional preprocessor, called moc. Moc takes input files and based on their contents produce additional *.cpp files which contains standard c++ code. Those files are in turn fed to your "normal" compiler. All necessary build rules are handled automatically, as long as you use qmake to generate project.
Should I implement myself a little library to simply manage native win32 controls or should I go with Qt?
It is your code, and your decision to make. However, to me writing "little library" sounds a lot like reinventing the wheel. If I were you, I'd first tried to make the control work with Qt - because this way I won't have to reinvent the wheel - there are too many GUI toolkits already, so making another one alone is quite pointless.

Building/Running Lua from Visual Studio

I'm a total noob when it comes to linking and building with Visual Studio. I would like to integrate Lua into my C++ console application.
Can someone give a step by step on how to do this from getting the Lua dependencies from lua.org, to actually running a "Hello World from Lua" in VS, and all the steps in between.
Finding something like this online has been very difficult since most require prerequisite knowledge of building Lua and such.
Thanks :)
Start with the Lua for Windows package. It will get you a self-contained batteries included Lua installation. Lua for Windows is not an official distribution, but it is well respected by the Lua user community. You can use its lua.exe to gain experience with the language in a Windows environment, and its rich collection of tested extension modules is also available for use.
If you add its include and lib folders to your VS project configuration, you should be able to compile and link against Lua in short order.
One possible complication is that the LfW distribution is built against VC8's C runtime library. If that becomes a problem, then you can either compile Lua yourself as part of your Solution, or get a known good DLL that matches your specific version of Visual Studio from the Lua Binaries project.
Do remember that if you are using one of the distributed DLLs, it will have been compiled as C, and not C++. That means that you must wrap any references to the Lua include files in extern "C" {...} or you will have problems with linkage.
It really helps to have some experience with VS project configuration and building. In particular, experience with mixing C and C++ in a VS project is very helpful.
I heartily recommend following the advice already given about learning C and C++ and mixing the two together. Once you have that under your belt, you may want to check out LuaBind or LuaPlus for connecting C++ and Lua. You can do it manually (and you probably should, at first, to understand what's going on under the hood), but it's more efficient and cleaner, code-wise, to use one of those binding libraries. For debugging purposes, Decoda is a good choice; it can attach to processes started in VS which contain Lua code you want to check.

cross compiling c++ to iphone arm

I've scanned over the (outdated) article that is the first hit on google about ARM cross-compiling. I've also seen the article about compiling OpenCV to the iPhone and the general cross compiling instructions there. My question is can I call the apparently already configured gcc/g++ in the iPhone developer package (which I already have installed) like in the latter article? A lot of the OpenCV stuff seems superfluous to my needs.
If I can, what would the calls look like? Should I create a Makefile to make things easier?
Also, I need -lncurses library. Can I call them like normal, or do I need to specify it's path because I'm not calling the default gcc/g++?
If you're using the official SDK, compiling C++ for the iPhone is as simple as including cpp files in your project and hitting "build". Of course you can still go in and tweak the compiler switches - well, most of them.
As for ncurses, I'm not sure why you'd want to use that - but the only limitation you should have is that you can't link against dynamic libraries - so you'd have to linked the object code in.
A script that you can use as a basis for crosscompiling your libraries for iOs development.
Unfortunately the [n]curses package is not going to do you any good for the iPhone.
[n]curses is designed to be used with a terminal window. This is just not available for the iPhone you will need to learn how to use Coco to develop a GUI interface.