is there any way to create a new visual studio project without using IDE, Instead use command prompt??
I am working on a project which will generate small C++ progra
Visual Studio projects are just XML files, so you can just study their format and write them out. (The format changed from 2008 to 2010.) Solution files are a custom text format, but not that complicated either.
Finally, devenv.exe has a switch for "don't start the IDE, just compile this solution on the command line", which you can use to compile the resulting solution.
Let CMake make your project files for you. It uses a much more legible syntax, and you can also generate project files for a variety of other build systems.
As an example, here's a very basic CMake file:
project(Foo)
cmake_minimum_required(VERSION 2.8)
#project source files
file (GLOB HEADER_FILES "*.h" "*.hpp")
file (GLOB SOURCE_FILES "*.cpp")
# build
add_executable(Foo ${SOURCE_FILES})
target_link_libraries(Foo ${LIBS})
And here's the solution file it generates.
Microsoft Visual Studio Solution File, Format Version 11.00
# Visual Studio 2010
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ALL_BUILD", "ALL_BUILD.vcxproj", "{66E5A2EB-A802-44A1-AC9C-906752330405}"
ProjectSection(ProjectDependencies) = postProject
{1A246EDB-1F39-4776-A9C0-C81AC67D1924} = {1A246EDB-1F39-4776-A9C0-C81AC67D1924}
{A0601C1A-BC0F-45D0-BDB1-C5056BD69958} = {A0601C1A-BC0F-45D0-BDB1-C5056BD69958}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Foo", "Foo.vcxproj", "{1A246EDB-1F39-4776-A9C0-C81AC67D1924}"
ProjectSection(ProjectDependencies) = postProject
{A0601C1A-BC0F-45D0-BDB1-C5056BD69958} = {A0601C1A-BC0F-45D0-BDB1-C5056BD69958}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ZERO_CHECK", "ZERO_CHECK.vcxproj", "{A0601C1A-BC0F-45D0-BDB1-C5056BD69958}"
ProjectSection(ProjectDependencies) = postProject
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32
Release|Win32 = Release|Win32
MinSizeRel|Win32 = MinSizeRel|Win32
RelWithDebInfo|Win32 = RelWithDebInfo|Win32
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{66E5A2EB-A802-44A1-AC9C-906752330405}.Debug|Win32.ActiveCfg = Debug|Win32
{66E5A2EB-A802-44A1-AC9C-906752330405}.Release|Win32.ActiveCfg = Release|Win32
{66E5A2EB-A802-44A1-AC9C-906752330405}.MinSizeRel|Win32.ActiveCfg = MinSizeRel|Win32
{66E5A2EB-A802-44A1-AC9C-906752330405}.RelWithDebInfo|Win32.ActiveCfg = RelWithDebInfo|Win32
{1A246EDB-1F39-4776-A9C0-C81AC67D1924}.Debug|Win32.ActiveCfg = Debug|Win32
{1A246EDB-1F39-4776-A9C0-C81AC67D1924}.Debug|Win32.Build.0 = Debug|Win32
{1A246EDB-1F39-4776-A9C0-C81AC67D1924}.Release|Win32.ActiveCfg = Release|Win32
{1A246EDB-1F39-4776-A9C0-C81AC67D1924}.Release|Win32.Build.0 = Release|Win32
{1A246EDB-1F39-4776-A9C0-C81AC67D1924}.MinSizeRel|Win32.ActiveCfg = MinSizeRel|Win32
{1A246EDB-1F39-4776-A9C0-C81AC67D1924}.MinSizeRel|Win32.Build.0 = MinSizeRel|Win32
{1A246EDB-1F39-4776-A9C0-C81AC67D1924}.RelWithDebInfo|Win32.ActiveCfg = RelWithDebInfo|Win32
{1A246EDB-1F39-4776-A9C0-C81AC67D1924}.RelWithDebInfo|Win32.Build.0 = RelWithDebInfo|Win32
{A0601C1A-BC0F-45D0-BDB1-C5056BD69958}.Debug|Win32.ActiveCfg = Debug|Win32
{A0601C1A-BC0F-45D0-BDB1-C5056BD69958}.Debug|Win32.Build.0 = Debug|Win32
{A0601C1A-BC0F-45D0-BDB1-C5056BD69958}.Release|Win32.ActiveCfg = Release|Win32
{A0601C1A-BC0F-45D0-BDB1-C5056BD69958}.Release|Win32.Build.0 = Release|Win32
{A0601C1A-BC0F-45D0-BDB1-C5056BD69958}.MinSizeRel|Win32.ActiveCfg = MinSizeRel|Win32
{A0601C1A-BC0F-45D0-BDB1-C5056BD69958}.MinSizeRel|Win32.Build.0 = MinSizeRel|Win32
{A0601C1A-BC0F-45D0-BDB1-C5056BD69958}.RelWithDebInfo|Win32.ActiveCfg = RelWithDebInfo|Win32
{A0601C1A-BC0F-45D0-BDB1-C5056BD69958}.RelWithDebInfo|Win32.Build.0 = RelWithDebInfo|Win32
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
EndGlobalSection
GlobalSection(ExtensibilityAddIns) = postSolution
EndGlobalSection
EndGlobal
The Project file is similarly ugly and 294 lines long.
Adding dependencies is pretty simple too, here's how you add boost:
find_package(Boost REQUIRED)
include_directories(${Boost_INCLUDE_DIRS})
set(LIBS ${LIBS} ${Boost_LIBRARIES})