I've been lurking stackoverflow for well over a year now and I've finally ran into a problem that I just can't seem to have any luck with. I'm trying to build a simple proof of concept application that uses libtorrent before I try anything complicated. I can get the examples built just fine using bjam and I can get my own simple application (a clone of simple_client.cpp really) to compile and run just fine using a little hack by modifying the bjam file. But I'd prefer to not be anchored down using bjam, so could anyone lend a hand on getting the examples to compile using the MSVC commandline? I've tried variations of the following command
cl -D _WIN32_WINNT=0x0501 -D TORRENT_WINDOWS=1 /EHsc /I C:\Libs\boost_1_54_0\ torrenter.cpp /I C:\Libs\libtorrent-rasterbar-0.15.6\include\libtorrent /I C:\Libs\libtorrent-rasterbar-0.15.6\include\ /I C:\Libs\libtorrent-rasterbar-0.15.6\zlib /link /LIBPATH:C:\Libs\boost_1_54_0\lib
but I'm met with all kinds of errors like redefined functions and such. I've got a feeling that it has to do with some preprocessor defines that I need to feed into cl but I really have no clue what I need to give it.
I've got boost 1.54.0 installed, libtorrent 0.15.6, and MSVC Express 2012 edition and I'm on window 7 64-bit.
Any help you guys could give would really be appreciated, thanks!
if you invoke bjam with the additional arguments "-an" it will, instead of building, print out all the command lines it's executing. This may be useful. -a means to rebuild all unconditionally, -n means to print out the command lines instead of executing them.
However, given the limited command line length in the windows shell, it's forced to use response files. This means you won't get a full view of the command line without also opening up one of the .rsp files for the bulk of the arguments.
Related
So I just got into using VS Code. I am currently working with C++ and I am using Mingw as my compiler. So far I have been using the terminal at the bottom of VS Code to compile and run like this:
g++ program.cpp then doing ./program.exe
The process of using the terminal at the bottom is time consuming especially when I need to compile and run code frequently. This is also annoying when creating classes when you have to compile multiple files into .o extensions etc.
Can anyone help with this process? Am I doing something wrong, should there be an easier way? Maybe a makefile?
Thanks!
If you want to compile and run C++ code in visual studio code(Vs-code) in windows. This include following steps.
Download Visual studio code.
Go on Add extension Type C++ and install "C/C++" by Microsoft.
Go to Visual Code studio docs for "C++" OR https://code.visualstudio.com/docs/languages/cpp
Install MinGW-x64 vis MSYS2 website and run this on shell "pacman -S --needed base-devel mingw-w64-x86_64-toolchain"
Then go to windows setting and look for Edit environment variables for your account. Then in advance settings >> Environment Variable.
In "system variable" choose path and edit it and add a new path.
You can find a new path in your directory where you have installed the MinGW-x64. you might find it in C:\msys64\mingw64\bin. or where ever you have installed it.
When you have added the new path then go to any shell/cmd and Type g++ --version
if you get the version then you have succeded.
If you find something like command not recognized then please check where you have done wrong or skipped any step.
Otherwise startover.
thanks--
Whenever I use the :!make % command, vim returns "make is not recognized as an internal or external command, operable program, or batch file." I have tried set makrprg=\"C:\\Program\ Files\ (x86)\\Microsoft\ Visual\ Studio\ 14.0\\VC\\bin\\cl.exe\". However, the same message appears. I believe the error may be in the path I have set, or the format of my statement; however, I am not sure if there is any other underlying cause.
I would greatly appreciate any input. Thanks in advance!
FYI:
I use a Windows 8 computer, and the compiler I typically use is the Microsoft Visual Studio 14.0 compiler.
! is a VIM command that invokes the shell. !make tells the shell to run whatever the shell can fund under the name make. If you want to use VIM's makeprg, you need to use the VIM command :make.
Having said that, setting makeprg to sonething that is not a real make-style program is probably going to work only in the very simplest scenario.
You can run the compiler directly with !cl %. You need to put cl.exe in your PATH and probably set up other environment so that cl can find libraries and include files.
This is because you do not have the make executable installed, which is what vim is looking for. If you're looking to compile on the command line with make, I would recommend switching from the Visual Studio compiler to MinGW
make is a Unix tool, and while it is also available for Windows (in various flavors, native, Cygwin, or MinGW), it is usually not what you will be using together with MS Visual Studio.
It is difficult to be specific, since you told us nothing about the project you are trying to compile, but I will try.
If your project is set up as a Visual Studio solution, you can compile it using devenv:
devenv /build release mysolution.sln
devenv /build release /project mysolution/myproject/myproject.vcxproj
Your project might also be set up for NMake (which is a make-like tool shipping with MSVC):
nmake [target]
The two commands above require the current shell to be properly set up, which can be achieved by starting a "Visual Studio Command Line" from the start menu, or running %VS120COMNTOOLS%\..\..\VC\vcvarsall.bat from whatever shell you happen to work from. (Adjust VS120COMNTOOLS to whatever version of MSVC you are using.)
Or your project might actually be set up using "real" makefiles, in which case I second Levi: It seems like make is not installed, or has not been added to your PATH environment variable.
make [target]
I am trying to migrate an old MFC project to VS 2012 and one of the errors I get is this one:
From what I read is that it has something to do with Help Files, which are not supported on Windows 7.
I thought that maybe Windows is searching for the hcw path so I added to the Environment Variables, but I still get the error. From the code I can see that the command is called inside .mak files:
start /wait hcw /C /E /M "hlp\$(InputName).hpj"
Anyone has an idea how can I get rod of the error ?
Just ran into the same issue. VS 6 project promoted to VS2013.
To eliminate the error. remove the Projectname.hpj file from the project.
Your project requires Microsoft Help Workshop.
Could be a problem in the post build step.
I'm just getting started with c++ development and I would like to use emacs to write the code and then compile and run it from within emacs using the visual studio 6 compiler. I have already googled around a bit but just can't seem to find an explanation of how this is done.
Any pointers?
Thanks for your help,
joerg
I have done this as a matter of course over the past few years. There are two ways to do this:
In the older versions of VS (including VS 6.0), there is a button to export the nmake file for the project. I do this on occasion and then use nmake to compile. I have
(setq compile-command "nmake debug ")
in my .xemace/init.el for this. You have to add the name of the nmake file, and nmake.exe has to be in your path. (BTW, I modified compilation-error-regexp-alist-alist to help moving through the errors. Let me know if you want this as well.)
Newer versions of VS do not have the button to export the nmake file. For these I call devenv.com. In this case I have
(setq compile-command "devenv.com /build Debug ")
in my .xemacs/init.el. You have to add the name of the .sln file. Although I did not do this with VS 6.0, I believe that it may work as well.
I am not sure if you would consider merely swapping the text editor inside of Visual Studio with Emacs, but here is a sf.net project which does just that.
http://sourceforge.net/projects/visemacs/
Checkout http://www.kuro5hin.org/story/2003/4/1/21741/10470
As a followup to Andrew Stein's answer, to do a command line build on Visual Studio 6 without using nmake, use the syntax:
msdev wspname.dsw /make "project - Win32 Debug"
Visual Studio is an IDE
It uses the cl.exe compiler underneath.
We use emacs with GNU make (gmake), which is wrapped with our own gmake wrapper executable and it works very well.
Just set up simple a keybinding to invoke cl.exe on .c/.cpp files that you are compiling to build your .obj files. We have one keybinding for initializing a compile in a folder, which will make all .obj files that are not up to date, but this is purely handled by GNU make.
We also have other keybindings, e.g. for linking the executable and starting it etc.
A bit off topic, but why are you using visual studio 6? The compilers (as well as stripped down IDEs) for the current version of visual studio are available for free from Microsoft.
In either case, you can invoke the compiler from the commandline so it should be as simple as setting up a makefile.
If you just want to set up a single file to compile then put this at the top of your file...
// -*- compile-command:"g++ test.cpp -g -lwinmm -o test.exe"; -*-
See my blog post on this
Of course you need to adjust to use CL.EXE and choose the appropriate arguments.
For launching make it's a bit trickier since you have to run make as if you were in the parent source directory, when you are editing a file further down the hierarchy.
The only way I know of to do that is to put this at the top of every file ...
// -*- compile-command:"nmake"; default-directory:"c:/projectroot/"; -*-
I was wondering whether it's possible to use Microsoft's C++ compiler and linker with NetBeans IDE?
If so, what's the best way of doing it.
P.S. I'm not interested in Mingw.
EDIT: Is it possible to get NetBeans to do error parsing (so that I can click on error and have NetBeans open the right file), intellisense, etc? I know NetBeans can work with g++ make files. Why not with nmake?
I am currently writing a plugin/toolchain to use Visual C++ on Netbeans.
You can find the project called VCC4N on source forge or on NetBeans plugins.
To be honest, I always do my spare time coding inside an ide (e.g. code::blocks, monodevelop, anjuta) or an editor (virtually always scite), and the compiling I do in a terminal via a makefile (handwritten, cmake, automake).
This isn't really a problem w.r.t. time to compile: F7 (or some other of the F keys) vs. (alt+tab, up, enter), where (alt+tab) and (up) are pressed nearly at the same time, but I get the great benefit of having up to full screen compiler reports, and often I am anyways testing my programs in a terminal. Also, it makes my code more independent of the IDE (ever tried to get a makefile from code::blocks for distribution purposes?).
The visual studio compiler is called cl.exe and the linker is link.exe. These are present in particular visual studio directories. From inside visual studio > project properties > C++ > Command Line, or by disabling "Suppress Banner" option there, you can find the command that visual studio runs. You can call these command lines from inside netbeans.
Getting all the file names into the list to compile may be more tricky. You need a build system for this. You can try to use the same mechanism that visual studio uses, but sorry my knowledge fails there. Alternatively, you can use CMake or some other build system. Then, whenever you add/delete a source file, you would have to update the CMakelist.txt to be able to compile.
You can get syntax highlighting, code graphing etc from netbeans without having a compiler installed I think (not certain, you may need cygwin or mingw for parsing). What you must do is create at least an empty makefile. If you want to use Microsoft's compiler then you either need to:
a) Write the makefile yourself to compile eveything using cl
b) Call on msdev from the makefile with the project name and it will compile everything
b) Call something like scons from the makefile to compile everything
I use netbeans to develop cross platform software, at this time though, I don't actually run the builds from netbeans.