What to do next after building wxWidgets successfully : Visual Studio 2010 - c++

I have downloaded c++ open source application which was created using under Linux IDE/Editor (or maybe something NOT Windows) and its no longer supported.
This time I want to edit and recompile it using VS 2010.
Error(s) left (mostly prefixed with "wx") such as:
"wxString is undefined"
"wxStaticText expected a type specifier"
etc... makes me think that this is all about wxWidgets.
After successfully building wxWidgets, what to do next to integrate it to the actual c++ program for me to be able to edit and compile using VS 2010?
I use BorlandC++ last 2 years ago but not familiar with GUI packages.

The first step is to tell the compiler where to look for the wxWidgets include files.
So, you need to find out where these files are, which depends on where you installed and built wxWidgets.
On my system, this is C:\Program Files (x86)\wxWidgets-2.8.12
I consider the best way is to, instead of hard-coding the path in every project, create an environment variable WXROOT to store the path to your wxWidgets folder.
Control Panel | System | Advanced | Environment variables
Now you have to tell the compiler about this
Visual Studio | Project | Properties | C/C++ | Additional Include Directories
What you add here depends on what kind of build you are doing. If you are doing a unicode release build, then this will be a good start
"$(WXROOT)\lib\vc_lib\mswu";"$(WXROOT)\include"
Now you should have fixed your compiler errors.
Next you will get some linker errors ....

Maybe the errors are caused because you are using wxwidget 2.8 which is unsupported in VS 2010.
Try building wxwidgets 2.9 or use VS 2008. I had no problem building wxwidgets 2.9 on VS 2010.
Wxwidgets site home says "While this is still officially a development release because some API details are still not frozen, we believe that 2.9.3 can be used in production environment".
About what to do after successfully build it, take a look at this http://wiki.wxwidgets.org/Microsoft_Visual_C%2B%2B_Guide
You may want to use the tutorial of the section "Creating a new project from a sample" 'cause creating a project by hand is a little bit complicated as wxwidgets requires some extra configuration and not just to set and include and libs dir as most of the libs does.

Here is a video which shows how to start with Visual Studio.
Also you can take a look at samples directory and create your own project based on configuration of projects from that directory.

May be I am little bit late , But this will help newcomers to wxwidgets.
First of all Goto Wxwidgets directory(to download path) in my case it is "C:\Users\WxWidgets_all".
Now in that folder goto build directory.Now open Visual Studio Command prompt. If you have already installed Visual Studio then you can easily find it through start menu.
Now in command prompt go upto <Path to your wxWidgets>/build/msw/ . Now run Following Commands.
nmake /f makefile.vc--For Static Library and Debug Version
nmake /f makefile.vc SHARED=1--For SHARED Library and Debug Version
nmake /f makefile.vc BUILD=release--For SHARED Library and Release Version
After completing it , you will have dll or lib in "<path to wxwidgets>\lib\" depending on option provided in above commands.
Now include all files related to wxwidgets in your project.Mainly two paths are required to include "<path to wxwidgets>\inlcude\" and "<path to wxwidgets>\lib\vc_<lib\dll>".
After that link your wxwidgets generated library to your project.To do this inlcude "<path to wxwidgets>\lib\vc_<lib\dll>" to your project property in library section.
Now add below preprocessors to your project.
_WINDOWS
NDEBUG(For Release)
_DEBUG(For Debug)
_CRT_SECURE_NO_DEPRECATE=1
_CRT_NON_CONFORMING_SWPRINTFS=1
_SCL_SECURE_NO_WARNINGS=1
__WXMSW__
_UNICODE
After that add following library to your project from "<path to wxwidgets>\lib\vc_<lib\dll>"
wxbase30u_net
wxmsw30u_core
wxbase30u
wxtiff
wxjpeg
wxpng
wxzlib
wxregexu
wxexpat
wxmsw30u_adv
Based on your compiled options , library name can be little bit different.
I think I have covered all the steps to run wxWidgets.
Even if you got errors , You can check minimal project in "<path to wxwidgets>\samples"
directory. Try to run that project , and even if you got error then your wxwidgets is not built properly.
Hope this will help.

Related

Compiling Qt projects in Qt/MsBuild format without Qt VS Tools installed

I have many Qt projects in Visual Studio, using the new Qt/MsBuild format provided by the Qt VS Tools. When compiling in my development environment, where I have the Qt VS Tools installed, everything works flawlessly (compiling from IDE and from command line).
We have a computer dedicated to nightly builds, where only the compiler and msbuild are available (no IDE nor Qt VS Tools are installed).
When compiling the projects in such computer we get an error:
QtMsBuild: could not locate qt.targets, qt.props; project may not build correctly.
Followed by several lines such as
e:********\Preferences.h(4): fatal error C1083: Cannot open include file: 'ui_Preferences.h': No such file or directory
(Project contains Preferences.ui).
How can I solve such errors when Qt VS Tools are not installed?
One solution provided by the Tools' creators is to copy %LOCALAPPDATA%\QtMsBuild into each project directory. But we are talking about hundred of projects. Doing manually, and more on, pushing them as part of the project itself doesn't sound very elegant.
One option would be to add a pre-build step that copies it from a common place into each project (and adding a **/QtMsBuild line to each .gitignore file). Again, looks like too much work.
When looking at the .vcxproj file for the Qt project you find this fragment (the reason for the solution provided by creators):
<PropertyGroup Condition="'$(QtMsBuild)'=='' or !Exists('$(QtMsBuild)\qt.targets')">
<QtMsBuild>$(MSBuildProjectDirectory)\QtMsBuild</QtMsBuild>
</PropertyGroup>
So, the simplest solution (without being able to install the tools), is to copy the %LOCALAPPDATA\QtMsBuild directory (from a system with the Tools installed) into the night computer (in any common place, but I decided to keep the location used by the tools) and then setting an environment variable:
set QtMsBuild=%LOCALAPPDATA%\QtMsBuild
PS: do not add double quotes to the variable (at least I had problems with them, so VS couldn't find the files).
Update 9-14-2020
I'm not sure on which version it started, but Qt projects created with (at least) the v2.5.2 Qt VS Tools fails to compile indicating that the Qt version has not been set. To solve so, you can
Copy the Registry entries from a computer with tools installed, located at HKCU\SOFTWARE\Digia\Versions.
If you will rely on a single Qt version (but that may be update globally for all projects), you can skip the Registry and just set the Qt version of all projects to $(DefaultQtVersion) (the same used in past project formats) and define an environment variable pointing to the directory of the version: set DefaultQtVersion=c:\Qt\Qt_5_15_0\Win32, for example.
I had problems in my case setting up $Env:QtToolsPath="$Env:QT_PATH\bin" fixed the problem. (It was not finding qmake for some checks). This, I think, is required when using QtMsBuild v3.3
Not sure if this info is 100% correct but may help someone.
For me to use MsBuild with Qt using QtMsBuild (not installing Visual Studio and/or VS plugins), I need to set up:
Example (PowerShell):
- $Env:PATH="$Env:MSBUILD_PATH;$Env:PATH"
- $Env:QT_PATH="D:\BuildTools\Qt\5.15.1\msvc2019_64"
- $Env:QtMsBuild="D:\BuildTools\Qt\QtMsBuild303" #303 Against visual studio project version
- $Env:QtToolsPath="$Env:QT_PATH\bin" #Support QtMSBuild , At desktop is done by the plug in
- $Env:PATH="$Env:QtMsBuild;$Env:PATH"
- $Env:PATH="$Env:QT_PATH\bin;$Env:PATH"
I hit this and got it working.
I followed #cbuchart 's advice; but needed to do a little more/different.
So here is what I did. I copied %LOCALAPPDATA%\QtMsBuild to my repo. I then edited my .vcxproj with a text editor. I adjusted the line that looks like:
<QtMsBuild Condition="'$(QtMsBuild)'=='' OR !Exists('$(QtMsBuild)\qt.targets')">$(MSBuildProjectDirectory)\QtMsBuild</QtMsBuild>
To be:
<QtMsBuild Condition="'$(QtMsBuild)'=='' OR !Exists('$(QtMsBuild)\qt.targets')">$(MSBuildProjectDirectory)\..\QtMsBuild</QtMsBuild>
Depending on the relative location of where your project(s) are to the copied QtMsBuild directory you might want to adjust this. In my case the .vcxproj was in a directory one level from the directory that contains the QtMsBuild directory I copied.
Next in the QtMsBuild/Qt.props file I added the following:
<PropertyGroup>
<DefaultQtVersion>$(MSBuildThisFileDirectory)\..\Qt5.15.0\msvc2019_64</DefaultQtVersion>
<QtToolsPath>$(DefaultQtVersion)\bin</QtToolsPath>
</PropertyGroup>
That was added right after the opening Project tag in that file.
This was as #cbuchart mentioned something might have changed. I didn't do the Registry idea; but added those lines instead. I think it is possible to add them to a different file that gets imported before Qt.props if desired.
Now as for what this "Qt5.15.0\msvc2019_64" is; you'll need the tools, includes, libraries from a computer with Qt installed in order to build (also DLLs if your build needs to run the executable (i.e. tests)). This might be a lot of files so you can reduce it some if you know what you are doing. It might make sense to have these be put into it's own submodule or something.
After that it should uic/moc files and ultimately build (and run).
I got too. Maybe you need update your visual studio and then restart your computer ...
problem solved. reason: install 'qt vs tools' latest version but the visual studio
not support of it.

Install pdcurses on Visual Studio 2017

I was making a 2048 game on Code::Blocks, but due to debugging problems, I move to Visual Studio Community 2017. It seems that conio.h doesn't work there, so I'm trying to switch to curses.h library.
I've read a lot of tutorials, but none of them worked for me. I visited their website and downloaded the .zip file with 384 kilobytes (KB), but I do not know what to do with these files.
Help, please?
I have found a very useful website which talks about PDCurses and its installation in Visual Studio. Even though it is for 2010/2013, it really worked for me in VS2017 — even the demo programs (with very minute changes)!
So here is the steps I did (since you already have PDCurses):
Take the developer command prompt of VS2017 community edition and type
in set PDCURSES_SRCDIR=<PDCurses Directory Location>; in my case it
was
set PDCURSES_SRCDIR=C:\pdcurses-master
Note: Here we are setting up the environment variable needed for compilation. If you need additional functionality defined by the pdcurses library, you may want to set corresponding variables in this step. For example, if you need wide character support, you can use set WIDE=1. To see what all are the options available, you can open up the make file (mentioned in next step) in any text editor and look for if conditionals.
Navigate in the command window to the directory of PDCurses/win32 (in my case C:\pdcurses-master\win32)
nmake –f vcwin32.mak
(This is the make file for PDCurses.) It will create the pdcurses.lib for our Visual Studio.
Now we need to incorporate the generated library into our project. So open up your project and go to project properties
In “VC++ Directories”, change:
Include directories: Add a new file-path to PDCurses installation directory, in my case it is C:\pdcurses-master.
Library directories: Add a new file-path to PDCurses installation library directory, in my case it is C:\pdcurses-master\win32.
In C/C++:
In “Code Generation” tab, change “Runtime Library” to “Multithreaded Debug (/MTd)”. (Usually, it is set already)
In Linker:
In “Input” tab, add pdcurses.lib to Additional Dependencies (I initially got confused - remember, it is the input tab of linker)
Click on Apply, and OK.
Then wow! I ran some sample programs (demos) from the pdcurses project and all of them worked for me with very slight modifications.
Note: I created a Windows (also known as Win32, as in Win32 API) console application with Visual Studio 2017 and loaded the project. I did include stdafx.h and compilation was successful and I was able to see the output in the terminal window.
The above website also provides a PDF document too. The instruction there starts from the downloading the pdcurses from website.
This is old news now, but it might help somebody to know that pdcurses is packaged up on vcpkg.
To use it, (assuming you have vcpkg installed, of course, (Installing vcpkg) )
vcpkg install pdcurses
and you're off to the races. vcpkg will take care of making sure the include and library paths are all set.

A matching Debug configuration cannot be found in the wxWidgets directory you specified.

I have tried to setup and create wxWidgets project using wxWindgets installer and code::block-mingw installations.
When I am trying to create a wx-widgets smith project, I have below problem
A matching Debug configuration cannot be found in the wxWidgets directory you specified.
This means Debug target of your project will not build
Are you sure you want to continue with these settings ?
does anybody have any idea about this and what is the recommended way to setup wxWidgets and code-block in Windows ?
Did you compile your wxWidgets as a debug build? I got the same error, because I only buitl wxWidgets as a release build. However, I didn't intend to use the debug build anyway, because I didn't want to debug it, just use it. So you can continue with your project and then you have to replace the library names with the correct ones. Mostly this means removing the d at the end of the library name.
If you want to use a debug build, you have to build wxWidgets as a debug as well.
To fix the library names, you'd have to right-click on your project and go to "Build options... -> Linker settings".
Update
To compile it using MingW you have to follow this guide.
You may also have to adjust the include paths in your build options:
D:\src\c\wxWidgets_3.0.0\lib\gcc_lib\msw
D:\src\c\wxWidgets_3.0.0\include
And for the linker:
D:\src\c\wxWidgets_3.0.0\lib\gcc_lib
Problem is solved by following the exact instruction provided in Compiling wxWidgets 3.0.0 to develop Code::Blocks (MSW) section. I couldn't build wxWidgets correctly in windows. After I build wxWidget the same alert message mentioned in the question was popped when creating wxWidgets project using Code::Block but I dismissed and continue to create the project. This time it was worked.

MySQL Connector C++ 64bit build from source in Visual Studio 2012

I am trying to build the mySQL Connector C++ from source in Visual Studio 2012 for the 64-bit architecture.
I understand that it depends on some boost header files and the C connector.
Running CMake produces a project file, but that project file doesn't compile because of a big list of very confusing errors which probably have to do something with the include files, and an even bigger list of warnings. The official site is of little help.
Could some one please list all the steps in successfully compiling the C++ Connector?
In order to build it you need to have the following:
You need to have installed either the MySQL server or the MySQL C Connector.
Have installed the Boost C++ libraries or have the source files for it. Please note that there is not need to build boost as you only need the header files.
Have CMake installed. When installing CMake it will ask you if you want it included in the PATH variable, you should select yes to make it easier later to use it.
Once you have all three available, open VS2012 x64 Native Tools Command Prompt and from the source root directory of the MySQL C++ Connector you need to issue the following:
set MYSQL_DIR=c:\PROGRA~1\MySQL\MYSQLC~1.1
cmake -G "Visual Studio 11 Win64" ^
-DBOOST_ROOT:STRING=C:\Users\user\DOWNLO~1\BOOST_~1\BOOST_~1 ^
-DMYSQL_LIB_DIR:STRING=c:\PROGRA~1\MySQL\MYSQLC~1.1\LIB
devenv.com MySQLCPPCONN.sln /build Release
The first command defines the MYSQL_DIR variable that points to the installation of the MySQL server or the MySQL C Connector.
The second command call cmake to prepare a VS project that will be 64bit. There seems to be a problem with the MYSQL_LIB_DIR variable and it does not get generated, so we need to define it manually. MYSQL_LIB_DIR has the value of MYSQL_DIR ending with a \LIB.
Third command is optional, it will build the project from command prompt without opening VS.
It is recommended that you use the DOS paths for the variables.
To do that, navigate to the directory you want to convert to DOS path and call for %I in (.) do echo %~sI. It will give you the converted path.
It's really tough task and I've spent lot of hours figuring this out.
There are two issues here:
C++ Connector and MySQL libraries they have provided have been generated with Visual Studio 2010. Hence we can not use them as it is under VS2012 (It gives version mismatch error)
They also have not specified exact compiler options under which they have compiled these libraries. If our compiler settings are different, we'll end up in lots and lots of (especially linker related) errors.
Considering these facts, the only way is to build ourselves these libraries. Building MySQL is quick but building connector is little complicated.
Here are steps I am sharing. In my case I wanted to link these libraries statically with my project so I built these libraries accordingly. You may want to make relevant changes wherever necessary as per your need.
Before continuing with these steps, please download and install CMake on your system.
Steps to build MySQL server:
Download MySQL source. Extract them. Go in extracted folder in command prompt.
Create BLD forder
Go in BLD folder through command prompt
Run
cmake .. -G "Visual Studio 11 2012 Win64"
It will create MySQL.sln
Open MySQL.sln in Visual Studio and build only 'mysqlclient' library (as only this would be needing by application)
This will build libraries in mysql-5.6.24\BLD\libmysql\< Configuration > folder which we link in our project.
Steps to build C++ connector:
Download mysql-connector-c++ source. Extract it. Go in extracted folder in command prompt.
Create BLD forder
Go in BLD folder through command prompt
Run this command (Make sure we've built MySQL server before this, in Release and Debug mode. Also make sure we've downloaded Boost sources)
cmake .. -DMYSQL_INCLUDE_DIR="..\..\mysql-5.6.24\include" -DMYSQL_LIB_DIR:STRING="..\mysql-5.6.24\BLD\libmysql\Release" -DBOOST_ROOT:STRING="..\Boost\boost_1_54_0" -DMYSQL_CLIENT_STATIC_LINKING=1 -G "Visual Studio 11 2012 Win64"
It will create MYSQLCPPCONN.sln
Open MYSQLCPPCONN.sln in Visual Studio and make changes to 'mysqlcppconn-static' project:
A. Under C/C++ -> General -> Additional Include Directories put this (for All Configurations)
nativeapi;..\;..\..\;..\cppconn;..\..\cppconn;..\..\..\mysql-5.6.24\include;..\..\..\mysql-5.6.24\BLD\include;..\..\..\Boost\boost_1_54_0
B. In Code Genaration, change Runtime Library to Multithreaded (Debug or non-Debug depends on configuration) and NOT DLL
C. Under Librarian -> All Options keep "Additional Options" and "Ignore Specific Default Libraries" to blank (for All Configurations)
D. Under Librarian -> General keep "Ignore Specific Default Libraries" to blank (for All Configurations)
Build only 'mysqlcppconn-static' library project (as only this would be needing by application to connect to MySQL server)
This would generate library in mysql-connector-c++-1.1.5\BLD\driver\< Configuration > folder which we link in our project.

How to build wxmathPlot for win32?

I downloaded the latest wxmathplot but the readme is a bit sparse with instructions on how to build on win32 platform.
Has anyone used this library for win32? Can someone point me to the docs or give some hints/advice on how to build for win32 targets.
We'll eventually use this for cross platform stuff, for now it is just win32 until we port our other code.
I presume I have to use CMake, but have not used it before and it is not obvious to me how to build this all - I have already installed CMake, but I am apparently too stupid to figure out how to build this library/samples.
Well, I managed to make an SLN file, but it was not obvious.
I use wxMathPlot. I simply add mathplot.cpp and mathplot.h to the MSVS2008 C++ projects that need to use it. This compiles and links without my having to do anything special.
Here is a partial answer - to get
CMake to build an sln file:
Well, unfortunately there is no good
documentation on how to build
wxMathPlot on Windows, but it is very
simple. Just use CMake:
http://www.cmake.org/
Download and install it, then open
CMake gui, selecting the directory
where you uncompressed wxMathPlot and
a target build directory. click
Configure twice and then click
Generate. CMake does all its magic and
you'll get project files to build
wxMathPlot depending on your compiler.
For example, if you use Visual Studio,
a solution sln file is generated: open
it and build.
That works for building an sln file