I thought I might try out Visual Studio 2012 so I created a simple console 'hello world' application that makes a beep noise whenever it is run, but when I went to compile it it took 25 seconds. Now I know for a fact that the simplest of 'hello world' programs, on a modern system with 3.2gHz of i7 shouldn't take that long to compile. Is there a setting or feature that I could disable that was added in 2012 that made compiling basic console apps incredibly slow?
#include <iostream>
using namespace std;
string returnvalue;
int main()
{
cout << "Hello World\a";
return 0;
}
This sounds like there's something else on your system that is interfering with the compilation, as a single file like this should only take about a second to build. I would suggest running Process Monitor while doing a build and then look at the summaries in Tools -> Process Activity Summary/File Summary. It's likely that it'll point to the problem on your system which may be something like:
Virus/spyware scanner or some other process that hooks into all the file accesses. Desktop search tools do this too.
Permissions problem where a file or directory can't be read or written
Accessing files on a network drive which may be unavailable
Other network communication with servers that may not be available
Use pre-compiled headers. It will be slow the first time, but after that it will breeze right through it. Include <iostream> in your pre-compiled header .h file.
The easiest way would be to start over and use the default configuration, which uses pre-compiled headers. Or...
See here for how to add precompiled headers to an existing project: How to fix .pch file missing on build?
Related
I don't have formal VS training, and I usually use it to program simple tools for my research. (I'm a faculty member).
I'm currently working on a C++ library for Python using SWIG, so I followed the steps suggested in How to create a DLL with SWIG from Visual Studio 2010?
Step no. 25 says "You can't build the Debug version unless you build a debug version of Python itself", but I thought one should be able to build a debug version of the C++ stuff by writing a main that uses the library from C++ itself, without touching Python or involving Python at all. (Please let me know if I'm wrong.)
A while ago I tried creating two projects in one solution (one for the library, one for a testing app), but I wasn't quite convinced with the result, so I thought it was time to try configurations. I modified the Debug config for my SWIG project following the suggestions in Redifining C/C++ entry point in Microsoft Visual Studio 2015 and the comments (changed configuration type, extension, and entry point, and added additional dependencies vcruntimed.lib and ucrtd.lib, also excluded from build the .i and the _wrap.cxx files).
The project compiles and runs, but the methods/functions in the standard <random> C++ library are returning non-random numbers. Update/clarification: In the following code,
std::normal_distribution<double> rand::distn(0, 1);
std::uniform_real_distribution<double> rand::distu(0, 1);
std::mt19937_64 rand::generator;
void rand::init() {
generator.seed((unsigned long)time(NULL));
}
double rand::u01()
{
return distu(generator);
}
the function u01() returns 0.0 always, while when calling it from Python it works as expected.
I checked the code and the generator is being seeded correctly. Also the library is still working fine from Python, so I tend to think this is not a coding but a configuration issue.
I know this would make a better question if I posted a minimal working example, but before investing time (which I think I don't have) on it I was wandering if there is something obvious I'm missing, that a more knowledgeable VS user could easily spot. Please don't get me wrong, if I'm mistaken and the answer is not so apparent, I'll really try to make the time.
Thanks in advance.
I'm trying to run the demo code for suave (a webserver) in Xamarin Studio 5.9.8 on OS X El Capitan.
module ServerTest =
open Suave // always open suave
open Suave.Http.Successful // for OK-result
open Suave.Web // for config
startWebServer defaultConfig (OK "Hello World!")
It works as expected when I actually build the code. But when I try running it interactively, with ctrl + return, I get the error The namespace or module 'Suave' is not defined. I've looked around, and it looks like it's possible to use libraries interactively with Visual Studio. Is there a way to get this to work on OS X?
When you build your code, the information about referenced DLLs is contained not in the code itself, but elsewhere (the project file).
But when you execute the code in FSI, all FSI sees is the code. It doesn't have a project file from which to get references.
But since FSI still needs to load referenced DLLs occasionally (otherwise, it wouldn't be very useful), it offers a way to encode them in the code. This way is described in the page you linked - specifically, the #r directive.
Unfortunately, these directives are not supported when you build the code with the compiler. The compiler will generate an error when it sees them.
So it would seem that you have a choice: either execute the code with FSI or build it with compiler. Can't use the same code for both.
Fortunately, there are a couple of tricks to work around this.
First, you could leverage a special conditional compilation variable called INTERACTIVE and put the #r directive inside an #if such that only FSI will see it, but compiler won't:
#if INTERACTIVE
#r "./path/to/my.dll"
#endif
Second, you could create a separate script file that will load references and then load your actual code file:
#r "./path/to/my.dll"
#load "./my_code.fs"
And then execute this script file with FSI.
In both these cases, the paths are relative to the script file.
This means that the "not found" error you're getting is probably due to incorrect path to the Suave DLL. I seriously doubt that the DLL is located in the same directory with the code file. And also that it has no extension.
I've created Qt project using Visual studio 2012 32 bit and Qt5 SDK with the help of Visual studio Qt addon. I'm using Windows 7 ultimate OS.
I have created QApplication GUI Project which basically uses the following libraries:
qtmain.lib
Qt5Core.lib
Qt5Gui.lib
Qt5Network.lib
Ws2_32.lib
Winhttp.lib
Winmm.lib
Qt5Widgets.lib
Qt5PlatformSupport.lib
imm32.lib
And I have succeed in building the application binary without any errors.
I’m trying to run this application on test machine windows 7 desktop having following dlls copied there:
icudt51.dll
icuin51.dll
icuuc51.dll
libEGL.dll
libGLESv2.dll
Qt5Core.dll
Qt5Network.dll
Qt5GUI.dll
Qt5Widgets.dll
qwindows.dll [copied from msvc2012\plugins\platform folder ]
I’m getting the error:
Failed to load platform plugin “windows”. Available Platform are : while trying to run the application.
What would i have missed? How to make it run on windows platform? Please Help me to troubleshoot this.
I've followed the links posted about this problem previously. but none of them are solved my problem. What configuration I am missing?
The platform plugin dlls would need to be put into the platforms subfolder and then it will work.
Yet another solution: Early in your main function or whatever, call QCoreApplication::addLibraryPath(). A simple example:
std::ifstream configurationStream("whateverNameYouWant.conf");
std::stringstream configurationText;
configurationText << configurationStream.rdbuf();
auto ct = configurationText.str();
if (!ct.empty())
QCoreApplication::addLibraryPath(QString::fromStdString(ct));
Here I load the path from a .conf file of my own invention, so that the path won't be hardcoded into my program. Since I invented this file, I control its format; in this case it contains nothing but the path. The actual path I'm using is C:/qt5/qtbase/plugins; that directory contains platforms/qwindows.dll and other such files. One may adjust the paths for one's own case according to where one's Qt files are installed.
I guess it is also supposed to be possible to use a standard qt.conf file, using a format specified by Qt, to automatically load some special paths (including this plugins path) without having to add special code to your own program for the purpose: http://doc.qt.io/qt-5/qt-conf.html ...But I haven't ever managed to get that to work, for whatever reason. Maybe I'm making some simple mistake, I dunno.
An other solution is to add arguments to the QApplication object (or to the starting application).
For instance, you want to load qwindow.dll from C:\test\platforms.dll, you can instanciate QApplication object with the following code :
int ac = 4;
static char * av[] = {"myappli.exe","C:\\\\path\\to\\myappli.exe","-platformpluginpath","C:\\\\test"};
m_qApp = new QApplication(ac, av);
Be careful, the QTCore dll can't be into the directory C:\test (loading dll conflict)
If you specify a working directory different than the one where your executable is located, no matter the plugins are there, it will fail.
So, in that case, copy your file with a post build event.
And in:
Configuration properties->Debugging->Command
specify the full path of the executable.
This was tested on VStudio 2008.
Earlier I was using gtest for my project. For the time being I am using gmock and when I have provided the path for gmock.lib, gmock_mock.lib and ..\..\include too. Then the control is not at all going into the code.
Suppose previously it was like e.g.
main()
{
printf("Hello world"); //Kept the breakpoint here, control comes here
}
Now after adding .lib and include paths it is not at all executing just strats debug and ends without going anywhere...
Please help me.
Google test lets you write unit tests using the TEST macro. It is not intended for use with normal programs that already have a main(). If you want to use google test you should create another project.
I am trying to port a project including both SDL and WxWidgets to MacOS X with XCode 3.1.2. The project is fairly big, but I finally got it to compile successfully. However, it exits immediately after starting it with the message "MyApplication has exited with status 99".
For debugging purposes, I changed my main function to look like this:
int main(int argc, char *argv[])
{
cout <<"hello world";
cout <<"and goodbye";
throw "test";
}
I also added breakpoints to all three main function lines. However, the debugger does still not break and the application still exits right after startup.
The debug console output looks as follows:
(gdb) run [Switching to process 94140
local thread 0x3607] Running…
Debugger stopped. Can't find test.xml
!
Debugger stopped. Program exited with
status value:99.(gdb)
I do not know what file "can't find test.xml" refers to, why XCode is looking for it in the first place or if it is related to my problem at all.
This is my first XCode project, so I am clueless on how to proceed. Any hints would be greatly appreciated.
SDL uses some hack around your main function.
It's likely that your main code is never reached.
Try breaking on "start" and stepping from there - AFAIK "start" is the entry point to any macho executable.
What you're seeing looks like your binary exits with error code "99".
You may want to look for error code 99 in SDL or WX.
Later edit: from SDL site: The header file "SDL_main.h" remaps your main() function to the SDL_main() function with a function macro.
You probably don't have the right project settings. Which project template did you choose?
In the end I found that there was a different main() function in a unit test file from a third party library I had included by mistake.
And I expect that test.xml is a data file for that unit test, and it may have expected it in a default directory. Project > Edit Active Executable and make sure that the working directory on launch is where the code expects it to be (root, project directory, or executable directory).
I have to say, though, that I don't recommend learning a new tool by porting source code you're unfamiliar with to it. You are going to have a hard time telling what problems are due to learning Xcode from what problems are due to the odd expectations of SDL/WxWidgets.