MySQL with C++ program - c++

I need to write a C++ Windows App to fetch data from a text file stored in a web site (http:.../my.txt) and contains data as follows :
m[mi++]="16.11.12 11:35:00|3366;3448;5352;431|3426;3508;5421;438|3396;3480;5364;443|3515;3598;5560;437|3622;3704;5741;472|3483;3561;5193;442|3454;3536;5464;440|3748;3835;5527;474|3385;3469;5367;436|3326;3413;4800;701;24|8092;8274;12800;688;30"
m[mi++]="19.12.12 11:35:00|3366;3448;5352;431|3426;3508;5421;438|3396;3480;5364;443|3515;3598;5560;437|3622;3704;5741;472|3483;3561;5193;442|3454;3536;5464;440|3748;3835;5527;474|3385;3469;5367;436|3326;3413;4800;701;24|8092;8274;12800;688;30"
I need to read the first 2 inputs of data (start with m[mi++]) each 2 minutes and take the first two parameters from each ones and store it in mySQL table as a script file as follows
Date Data
16.11.12 11:35:00 3366;3448;5352;431
19.12.12 11:35:00 3366;3448;5352;431
Which C++ IDE (not MS visual studio) that is good to use with MySQL without any complication. I tried Netbeans and Eclipse but I've got errors with both MinG and Cygwin

Actually, its not about IDE. Everyting should work almost everywhere (if you have up to date compiller and set things up correctly). I personally use MSVS and mysql++ library. Everything work just fine.
There is no such a thing as IDE for C++ and MySQL development. Just use IDE you want and add libraries correctly. You didnt wrote, what library are you using, so I cant help you more.

I would say that CodeLite (codelite.org) or Code::Blocks (codeblocks.org are decent alternatives. You might need to Checkout wxDevCpp (DevCpp is dead), Anjuta, KDevelop, QT Creator and more.
I personally find MSVS a complicated IDE also I personally believe Eclipse and Netbeans should be used in Java (they Work with C++ both with right plugins)
My personal vote to CodeLite

Related

How can I change build tools for projects in VS Code?

I want to build a C++ code but it errors. When I check the error message it's related with .NET. I have C# extensions but this isn't C# and I want to change this to g++ for C++ projects. I have g++ installed and added to path however I don't know how can I configure it to build with that for C++ codes.
Edit: I marked the answer as a solution but I also found an easier way for me:
https://code.visualstudio.com/docs/cpp/config-msvc
cl.exe basically.
One option (probably not the one you want to) is to build it from integrated terminal.
You can download c/c++ extension along with the cmake tools extension to have buttons for build/run configuration.

VSCode c++ configuring for vc toolchain

I'm trying to start a work in vscode , latest C++ plugin version supports ms debugger, so as I'm mostly working under windows it was a signal to try this.
c++ tools plugin from MS and cmake tools were installed.
my test project was however not built . the problem is clear , but I need an advice from experienced vscode users how to solve this right.
cmake doesn't see vc compiler.
(after using QtCreator) I expected that vscode could detect vc installation... however that's not so. ok, I have a two ways:
fill environment variables INCLUDE/LIB/PATH with a headers, libs and binaries
just run vcvarsall.bat x64
Second way is a simple and reliable. so final question is:
how to run .bat at the begining of vscode start?
(I don't mean write another bat/cmd, prepare the environment and run vscode inside the same script after that)
Although the question is fairly old, I'll try to give a useful answer, in case others stumble across, just like I did.
I believe what you are trying to achieve is not possible. Code inherits the environment it was started with. If you did not launch it from a developer command prompt, you will not be able build and debug. (Building might be possible if every task first starts the vcvarsall.bat, but that slows things down by a lot. Debugging I think will still not work.)
If you are willing to, you can check out vector-of-bools CMake Tools extension which does build automation as well as automatic MSVC detection. It builds using CMake (thus you need to write your build scripts using CMake), but it will take care of building just by pressing F7, like what most VS users are familiar with.

building curl 7.46.0 on windows without cmd

curl being new to me, I am figuring out an easier way to compile it on Windows. I've managed to find a good documentation explaining in layman's terms all the steps, however this doc is based on curl-7.9.6.
It was simpler since curllib.dsw which is the Visual Studio Project file for curllib was found in folder curl-7.9.6\lib. So building it was resulting in libcurl.dll + libcurl.lib
Unfortunately this project file is no more in the latest version 7.46.0, and I would not like to mess around using other techniques I am not familiar with, compiler other than msvc (e.g MinGw), and if possible without resorting to cmd.
I have already done some researches online before posting this thread, but we never know maybe someone has written on this topic very simple documentation that everyone could understand and willing to share it publicly to get both the static library file and DLL (raised just above) or have found a way to get back the project file (.dsw) in the latest release which will a priori be straightforward to compile using Visual Studio 2013 (v120)
Best

How to migrate Borland C++ 5.02 application to Windows 7?

Currently we are migrating our applications developed in Borland C++ 5.02 on Windows XP to Windows 7. While executing the application on Windows 7, I am getting the error message
VBX library init Failure.
While trying to find the cause on the Internet, I was able to identify the error was because of BIVBX31N.EXE and BIVBX31N.dll.
How can I port a Borland C++ 5.02 application to Windows 7, solving the BIVBX31N.EXE and BIVBX31N.dll related issues?
If you're stuck using this product, here is what I recommend.
Simple answer: Don't use the IDE, but continue to use the command line tools:
bcc32.exe (the compiler) still works fine in Windows 8.
ilink32.exe (the linker) still works fine as well.
Both can be found in the bin sub-folder.
You can get some of the command line information by opening the IDE (project) file in Notepad or a hex editor (it isn't a text file, but you can read most stuff in Notepad). Or if you do have access to Windows XP you can open it there just to copy the settings for usage in the command-line tools.
Just use some other IDE or editor like Notepad++ to edit your source files. You can use an older version of Visual C++ to edit the RC files, or Notepad or other tools.
If you want really want to make it slick, set up your IDE to run an "external tool" when you click a toolbar button, to have it run your command-line tools to compile + link (and optionally run the EXE file). You can probably find a debugger tool as well, but I haven't needed that yet, so haven't checked.
My best recommendation is to start the process of porting your code to Visual Studio.
You can use a library like OWLNext if you've used the OWL library in Borland.
The other alternative is is to use Windows Virtual PC (or other such virtual machine) to run Borland in an integrated Windows XP mode. See an example here.
This can be probable answer ???
You have to download configured Borland Compiler from http://www.4shared.com/get/Gs41_5yA/borland_for_graphics.html or http://dwij.co.in/graphics-c-programming-for-windows-7-borland-compiler/.
Put your Borland’s ‘bin’ folder into Environmental Variables.
Now go inside folder ‘bin’ & edit file bcc32.cfg as per your folder structure. This file contains settings of headers & libraries.
-I"D:\Borland\include;"
-L"D:\Borland\lib;D:\Borland\Lib\PSDK"
Now create any C/C++ Program say myprogram.cpp
Use following command to compile this bunch of code:
F:\>bcc32 myprogram.cpp
Congratulations !!!.

Visual Studio Questions/C++

I'm a hobbyist developer and have a background with Java (IDE of choice was Eclipse). I'm using Visual Studio Express 2010 and wanting to learn C++.
Few questions:
I create a "HelloWorld" in C++ and compiles/runs in VS/Windows. When I try to compile it under Linux/GCC, it obviously throws tons of errors. Default windows console project includes windows specific files; but if just create an "Empty Project" it throws tons of linker/build errors. What's the best practices here to keep my code portable?
Why is it creating 47 files for 8 lines of code?
How do you format code? You can do Edit->Format Selection, but the hotkeys don't work?
How do I output to VS's 'Output' Window? ( like eclipse does when you run a console java app )
It keeps reverting my "Project Location" to my "home directory" every time I restart. How do you change it? Is it a bug? Because it's Express edition?
Is there a way to keep it from switching to Debug view when it runs?
I create a "HelloWorld" in C++ and
compiles/runs in VS/Windows. When I
try to compile it under Linux/GCC, it
obviously throws tons of errors.
Default windows console project
includes windows specific files; but
if just create an "Empty Project" it
throws tons of linker/build errors.
What's the best practices here to keep
my code portable?
For portable code, avoid VS wizards entirely. Use Make/NMake if you're starting with rocks and sticks, or the portable build system of your preference (Ant, CMake, etc.) Some of these will spit out a VS solution/project file for you to use.
Why is it creating 47 files for 8
lines of code?
Wizards are magical like that.
How do you format code? You can do
Edit->Format Selection, but the
hotkeys don't work?
Ctrl-K Ctrl-F (under Edit, Advanced)
How do I output to VS's 'Output'
Window? ( like eclipse does when you
run a console java app )
Lookup OutputDebugString() for the debug window. Output window should get all cout/cerr output.
It keeps reverting my "Project
Location" to my "home directory" every
time I restart. How do you change it?
Is it a bug? Because it's Express
edition?
Probably hidden in options somewhere - don't know that one, sorry.
Is there a way to keep it from
switching to Debug view when it runs?
Launch using Ctrl+F5 to run without the debugger attached.
Have fun!
I create a "HelloWorld" in C++ and compiles/runs in VS/Windows. When I try to compile it under Linux/GCC, it obviously throws tons of errors. Default windows console project includes windows specific files; but if just create an "Empty Project" it throws tons of linker/build errors. What's the best practices here to keep my code portable?
It's fairly difficult to keep your code truly portable if you're writing Windows applications. Standard C++ will obviously work on either platform, but Linux can't run Windows applications, and vice versa. Remember that console applications are also considered Windows applications. They're not any more "pure" just because they are text-based, rather than graphical. Windows applications have their own entry point, different from the standard main function found in ANSI C++ (technically, main is still there, but it's hidden and called internally by the Windows libraries).
The best thing to do is not to link to any of the Windows headers. Unfortunately, you won't be very satisfied with the results. About all that you'll be able to generate is library code. You can't get a UI on the screen unless you use the Windows functions to do it.
An "Empty Project" is just what it says—empty. I assume the build errors are because you're trying to call functions that aren't defined anywhere. You'll find that you need to include windows.h to get off the ground, which instantly makes your code non-portable.
Why is it creating 47 files for 8 lines of code?
This is obviously an exaggeration; none of the wizards produce anywhere near that many code files. Especially not the "Empty Project", which doesn't create any at all.
A Win32 console application includes the following 5 files:
stdafx.h and stdafx.cpp — these files are used to enable "precompiled headers", meaning that Visual Studio will compile all of your headers once, and only recompile them when they change, rather than recompiling them each time you build the project. This used to provide enormous speed boosts, and still does on large projects. You probably don't need or care about this for small projects, but it's not a bad idea to get familiar with their usage if you're going to be developing in Visual Studio.
A targetver.h file, whose only purpose is to specify the earliest version of Windows that you want your application to run on. This is necessary because later versions of Windows add additional functionality that wasn't available in previous versions. Your app won't run if you link to functions or libraries that don't exist. Set this up once and then forget about it.
A <projectname>.cpp file, which is the implementation code for your application. This is pretty standard stuff—it includes the _tmain function, which is the entry point for a console app.
A ReadMe.txt file, which you can immediately delete. It contains some introductory information and describes the files that have been added to your project. (Yes, reading this yourself could have answered this question.)
A Win32 application would have a few more files, but most of the same ones as well. In particular, you'll see a resource file (with the extension .rc) that contains the icons, dialogs, bitmaps, cursors, etc. used in your program.
If you don't like this structure, you can either forgo the use of a wizard, or modify it yourself. There's nothing set in stone about it.
How do you format code? You can do Edit->Format Selection, but the hotkeys don't work?
Formatting code works fine. I'm not sure why people are telling you that Visual Studio doesn't support this, or that you'll need a third-party plug-in. There's no "Format Document" command as there is in C#, but the "Format Selection" command works just fine. The only difference is, you have to select something in order for it to be enabled.
The default keyboard extension for that command is CtrlK, Ctrl+F. It also works fine, right out of the box. My typical workflow is to hit Ctrl+A first to select all.
How do I output to VS's 'Output' Window? ( like eclipse does when you run a console java app )
I don't know what Eclipse does, nor do I know anything about Java. What do you want this to do? When and what things do you want to get written to the "Output" window? A console application will run in a console window, not in the "Output" window. That's not what it's for.
It's intended for debugging purposes. The OutputDebugString function is one way of utilizing it. The output of the standard cerr keyword should be automatically redirected to the "Output" window.
It keeps reverting my "Project Location" to my "home directory" every time I restart. How do you change it? Is it a bug? Because it's Express edition?
This isn't a bug, it's a feature. Visual Studio is designed for working with projects and solutions, not one-off code files. So by default, it prompts you to specify a project folder, a location to store your files. And what better place for the default location than your home folder?
If you don't like that location, you can change it. Under the "Tools" menu, select "Options". Expand the "Projects and Solutions" category, and click the "General" item. Then, change the path of the "Projects location" (the top textbox). Couldn't get much simpler than that.
Is there a way to keep it from switching to Debug view when it runs?
I frankly don't understand how this question makes any sense at all. When you run an application with the debugger attached, Visual Studio switches to a different window layout specifically optimized for debugging. I just answered a similar question. The upshot is that there's no way of telling Visual Studio to use the same window layout for both design and debug view, but I also can't imagine why you'd want to, either. Different things are useful, depending on what you're currently doing.
The two window layouts are customizable, and your changes are remembered. I've customized mine heavily from the defaults; it's very likely that your tastes vary as well. There are lots of great features, like the "Locals" window, which shows a listing of all the values of the local variables in scope at the point where you break into your program's execution.
Also remember that the default "Debug" and "Release" build configurations have nothing to do with whether or not Visual Studio automatically attaches the debugger to your application's process. If you want to start your app without the debugger attached, select "Start without Debugging" from the Debug menu, or press Ctrl+F5. There are lots of side effects to this though, and it's probably not what you wanted. Without the debugger attached, you lose most of what Visual Studio provides to you as an IDE. You might as well just run the app from Windows Explorer without even launching VS.
Finally, if you prefer Eclipse (or at least are already accustomed to its nuances and prefer not to learn Visual Studio's), you can still use it for C++ development. Download it here.
If you're just wanting to learn C++ and you don't necessarily care about the platform, I would probably avoid using Visual Studio to start with. Visual Studio provides some functionality for managing projects and builds, but honestly, I think you're better off learning how to manage code files and use the compiler on the command line first, then working up from there.
If you're on Windows, I'd recommend installing Cygwin and getting the GNU compiler tools through the Cygwin setup utility (gcc or g++).
This is a bit of an opinionated answer, but my experience with C++ on Windows leads me to believe that you'd be better served trying to learn C++ from more of a unix-like angle. Windows C++ adds a whole layer of crap that will just confuse you when you're getting started.