I want to use Notepad and invoke the compiler and linker from the command prompt.
No IDE no make , nmake or anything like similar because I want to know the exact syntax required to do the following:
1. create a static library
2. create a dll
Yes, I have browsed the MSDN site but the examples I saw assume one is using the IDE which does a lot of setup behind the scenes
Pls Note: I know how to compile executables using cl also setting up the env using vcvarsall.bat. My question is about compiling static libraries and dlls.
I am using Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 15.00.30729.01 for 80x86.
Suggestions on to use some other compiler ( gcc, mingw, intel etc.) will not be helpful at the moment.
The C++ compiler is named cl. The compiler options are well-documented on MSDN. The linker is named link. The linker options are also well-documented on MSDN.
You'll need to run vcvarsall.bat to be able to build with the Visual C++ toolchain; this batch file sets up all the required environment variables and such. If you've installed Visual Studio, you should have a shortcut on your Start Menu entitled "Visual Studio Command Prompt." This shortcut will get you a command prompt and run that batch file.
For DLLs, pass the /c flag to cl.exe (which compiles but doesn't link), and pass the /DLL flag to link.exe. Instead of making an executable, it makes a DLL.
For static libraries, use the lib.exe program.
There are multiple approaches, all of which are handily documented in one place:
Visual C++ Concepts: Building a C/C++ Program
Building on the Command Line
Note that the build system completely changed between VC++ 2008 (which you're using) and VC++ 2010 (which is the current release).
A couple of minor things to add.
Personally I wouldn't use Windows batch files.
I would use nmake http://msdn.microsoft.com/en-us/library/dd9y37ha(v=vs.71).aspx building outside of visual studio is nmake's day job and that's the standard way to build visual studio projects for release say on a build machine, rather than in a development environment.
The other thing in nmake's favour is that if cross-platform is important to you then cmake ( http://www.cmake.org/ ) is a brilliant tool for dynamically creating Windows nmake files and non-Windows make files and it comes with ctest for running your unittests and selftests.
Advert over.
Related
I just want the VC++ compiler, since some C++ graphics libraries (I'm planning to use and learn bgfx...) require it for compilation. For this I’ve downloaded and installed Ms. Build Tools ’13. However, I can’t find it.
My attempts:
1) I’ve ran Windows Command Prompt using the Batch input cl and it echoed 'cl'is not recognized as an internal or external command, operable program or batch file..
2) I’ve searched for a file with filename cl.exe on both "C:\Programs Files" and "C:\Programs Files (x86)" paths recursively and nothing. There’s no top folder related to MsVC++ or VC++ too, on the disk.
I cannot try to install Build Tools ’15 (nor VS) since the installer downloads at minimum 3 gygabytes and my network isn’t good.
Where can I find the compiler? Otherwise, is there any cross-platform graphics library (at least for Windows and Mac) that doesn’t need MSVC++ (e.g., just G++), please?
As a commenter mentioned, the Microsoft Build Tools 201x include tools to build managed apps (i.e. .Net apps), not native C++ apps. That's the answer to "where is cl.exe?" It's not there. It was never there.
That's true for the Microsoft Build Tools 2015 too, despite what you think and said. You're mixing up Microsoft Build Tools 2015 and Visual C++ 2015 Build Tools. Note the "C++" there (and the order of some of the words).
The Visual C++ Build Tools are the supported and recommended way by Microsoft to Build visual C++ projects without installing Visual Studio.
If your problem is internet connection get someone else to download it for you, seriously. You're really looking at it the wrong way.
Another alternative is the Enterprise WDK. It's "only" 1.9GB.
Otherwise, is there any cross-platform graphics library (at least for Windows and Mac) that doesn’t need MSVC++
Yes, you should be able to use modern OpenGL in a cross-platform way under Mingw using
GLFW (since it's a CMAKE compile-it-yourself library) and the excellent GLAD for handling loading of the modern openGL API on windows.
How can i get C++ coding in eclipse to act like coding in java?
In java, i can nicely add external jar files and the code assist can nicely suggest methods or suggest adding unimplemented methods for interfaces.
But in C++ mode, it doesn't seem to work when i include external header files. What else should i try?
Eclipse CDT itself does not come with any compilers/libraries therefore you need to select and install a toolchain. There are a few options for this
Visual Studio (cl)
MinGW (g++)
Cygwin (g++)
Note, you can get VS Express for free and if you are a student can even get the professional version from Dreamspark
Once you have installed any of these you can select them as the toolchain for your C/C++ projects, this will enable you to build your projects nicely from within eclipse.
Also, you may need to point eclipse to the library files used by your compiler, for instance I use the VS2010 toolchain under Eclipse CDT so I must add
"C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include"
to the include directories in build settings.
Edit: Sorry if it wasn't clear, once you've done this code completion should work for your C/C++ projects.
I built dcraw.c (http://www.cybercom.net/~dcoffin/dcraw/dcraw.c) as a windows command line application with cygwin / gcc before. Today I built it with visual studio 2008 as that allows including the libraries LIBJPEG and LCMS into the exe file and does not require the cygwin1.dll either. Also the VC built version seems to be faster. So much for the prelude.
The actual question is this: When I use the final application say as in dcraw -T -4 *.NEF
The cygwin / gcc built version will process all NEF files in my directory while the visual studio built one says: *.NEF: Invalid argument
I have no idea why that is and am looking for a way to fix this. Any help would be greatly appreciated.
I believe you need to add setargv.obj to be linked in. It will expand the wildcards. If you are using the command line (cl.exe), you can just specify it on the command line:
cl yourfile.c /link setargv.obj
In a Visual Studio project, you can add it to the Additional Dependencies field in the Linker Input options in the project properties.
Are you running both builds from the same type of command interpreter? On Unix systems, the shell expands wildcards; Windows cmd.exe doesn't, leaving it to the program to do if necessary. If you're running one build from cmd and the other from Cygwin's bash, that could explain the different behaviors.
I am trying to get started with an existing open source project (QuantLib) using Linux operating system. However it seems that most developers use Visual Studio (judging from the project files committed with the source).
Which Linux C++ IDE would be most compatible with VS project files? Is there a way to import/export them, so that I don't have to create my own projects from scratch (and update them every time someone adds a new file)?
EDIT: Its all unmanaged code
In my experience, the best method for doing dual-development on Linux & Windows is to throw away the existing Visual Studio project files and, instead, use CMake to generate the platform-specific build environment. It's capable of outputting Nmake makefiles (for command-line Windows builds), Visual Studio projects, and Linux makefiles. The documentation leaves a bit to be desired but once you have it up and running, it's very easy to maintain.
The FAQ provides installation instructions for MinGW. It seems that there is a GNU Makefile included, so you don't need to mess with Visual Studio project files.
Aparantly they they only build on MAC and Windows.
Instructions here: http://quantlib.org/install/macosx.shtml
But since MAC is basically BSD Unix it should be identical (or with little trouble) to get it up and running on Linux.
The following should work (though you may need to look at the configure options)
1) Install Boost.
2) ./configure
3) make
You'll definitely want to check out Mono, it might be just what you're looking for: http://monodevelop.com/
I've done a decent search, but can't seem to find a way to get Visual Studio 2008 to use a unix Makefile, or even to create some MSVC compatible equivalent from the Makefile. Does anyone have ideas or similar issues?
Note: I already know the benefits/drawbacks of using Makefiles or not, and I don't want to hear your opinion. All I'm interested in right now is creating a Windows library from some originally unix code which only has a Makefile, and getting something functional out of it.
TIA.
You can also use cccl with make for windows.
cccl is a wrapper around Microsoft
Visual C++'s cl.exe and link.exe. It
converts Unix compiler parameters into
parameters understood by cl and link.
What you can do is create a project from existing code. Visual C++ does a pretty good job at compilation without makefiles.
You could also install MinGW and that has make and the compilers.
http://www.mingw.org/
Use the nmake commandline tool. Note it doesn't support everything that GNU Make does so you may need to edit the Makefile to make it compatible but it's the closest thing to what you want.
Typically what I see people do is use them the other way around: Use make as the master build system and have it invoke Visual Studio to build its stuff in batch mode.
I don't have 2008 on me, but w/ VisualStudio2005 you can build a solution with a rule something like this
release = "Win32 Debug"
progname.exe : progname.sln
devenv $< /Rebuild /"$(release)/"
(Note: I had to use spaces in this example, as tab just takes me to the next field.)