• Advertisement
Sign in to follow this  

Visual Studio C++ building from command line

This topic is 1192 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi Guys,

 

I have built a basic editor that I want to use to compile a fairly complex C++ program in (written in VC.net 2010).

 

I am wondering if there is somewhere I can find the actual parameters sent to the compiler and linker so I can replicate that from my own IDE.

 

Any advice would be greatly appreciated :)

Share this post


Link to post
Share on other sites
Advertisement
Compiler settings are under Project menu -> ProjectName Properties -> Configuration Properties -> C/C++ -> Command Line.
Linker settings are in the same window under Configuration Properties -> Linker -> Command Line.

Share this post


Link to post
Share on other sites

Awesome Apoch, thanks for that! :)

 

So, I have this now (in a bat file for testing purposes).

 

cl.exe main.cpp /c /EHsc /I D:\Users\Jason\Desktop\OgreSDK_vc10_v1-8-1\include\OGRE /I D:\Users\Jason\Desktop\OgreSDK_vc10_v1-8-1\boost /I D:
\Users\Jason\Desktop\Hydrax\include /Zi /nologo /W3 /WX- /O2 /Oi /Oy- /GL /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /Gm- /EHsc /MD /GS /Gy /fp:precise
/Zc:wchar_t /Zc:forScope /Fp"Release\E3_Ogre_Edition.pch" /Fa"Release\" /Fo"Release\" /Fd"Release\vc100.pdb" /Gd /analyze- /errorReport:queue
 
link.exe /OUT:"D:\Users\Jason\Desktop\E3_Ogre_Edition (Dynamic)\Release\E3_Ogre_Edition.exe" /INCREMENTAL:NO /NOLOGO "kernel32.lib" "user32.lib"
"gdi32.lib" "winspool.lib" "comdlg32.lib" "advapi32.lib" "shell32.lib" "ole32.lib" "oleaut32.lib" "uuid.lib" "odbc32.lib" "odbccp32.lib" /MANIFEST
/ManifestFile:"Release\E3_Ogre_Edition.exe.intermediate.manifest" /ALLOWISOLATION /MANIFESTUAC:"level='asInvoker' uiAccess='false'" /DEBUG
/PDB:"D:\Users\Jason\Desktop\E3_Ogre_Edition (Dynamic)\Release\E3_Ogre_Edition.pdb" /SUBSYSTEM:CONSOLE /OPT:REF /OPT:ICF /PGD:"D:\Users\Jason
\Desktop\E3_Ogre_Edition (Dynamic)\Release\E3_Ogre_Edition.pgd" /LTCG /TLBID:1 /DYNAMICBASE /NXCOMPAT /MACHINE:X86 /ERRORREPORT:QUEUE

 

cl.exe seems to work properly, but I get a single error in the linker

 


LINK : error LNK2001: unresolved external symbol _mainCRTStartup
D:\Users\Jason\Desktop\E3_Ogre_Edition (Dynamic)\Release\E3_Ogre_Edition.exe : fatal error LNK1120: 1 unresolved externals

 

Any ideas what this may be? The program compiles fine within the VS.net 2010 IDE.

Share this post


Link to post
Share on other sites

Actually, I think the cl.exe part may be failing but there is too much data in the console window so I don't get all of the window contents if I paste into a text editor (so missing the error messages)

 

Is there a way to specify a log file to output to with cl.exe?

Share this post


Link to post
Share on other sites

Is there a way to specify a log file to output to with cl.exe?

Maybe there's an explicit option for it, but you can always just pipe the output to a file instead of to the console.

 

cl ... > log.txt

Share this post


Link to post
Share on other sites

Cool thanks for that! :)

 

Turns out the program is compiling happily. But, the problem is in the linker.

 

I added main.obj to the linker command and the path to the boost libs.

 

Now I get the error

 


LINK : warning LNK4256: Profile Guided Optimization is not available in this edi
tion of the product; ignoring related options
LINK : fatal error LNK1181: cannot open input file 'D:\Users\Jason\Desktop\OgreS
DK_vc10_v1-8-1\boost\lib.obj'

 

There is no lib.obj file in this folder.

 

This is my new linker command

 

link.exe /OUT:"D:\Users\Jason\Desktop\E3_Ogre_Edition (Dynamic)\Release\E3_Ogre_Edition.exe" /INCREMENTAL:NO /NOLOGO "kernel32.lib" "user32.lib" "gdi32.lib" "winspool.lib" "comdlg32.lib" "advapi32.lib" "shell32.lib" "ole32.lib" "oleaut32.lib" "uuid.lib" "odbc32.lib" "odbccp32.lib" /MANIFEST /ManifestFile:"Release\E3_Ogre_Edition.exe.intermediate.manifest" /ALLOWISOLATION /MANIFESTUAC:"level='asInvoker' uiAccess='false'" /DEBUG /PDB:"D:\Users\Jason\Desktop\E3_Ogre_Edition (Dynamic)\Release\E3_Ogre_Edition.pdb" /SUBSYSTEM:CONSOLE /OPT:REF /OPT:ICF /PGD:"D:\Users\Jason\Desktop\E3_Ogre_Edition (Dynamic)\Release\E3_Ogre_Edition.pgd" /LTCG /TLBID:1 /DYNAMICBASE /NXCOMPAT /MACHINE:X86 /ERRORREPORT:QUEUE main.obj /LIBPATH D:\Users\Jason\Desktop\OgreSDK_vc10_v1-8-1\boost\lib

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement