I defined source & header -"MathCore.h" & "MathCore.cpp"
MathCore.h as below code :
#ifdef MATHCORE_EXPORTS
#define MATHCORE_API __declspec(dllexport)
#else
#define MATHCORE_API __declspec(dllimport)
#endif
MATHCORE_API bool isPowOf_Two(unsigned int n);
MATHCORE_API bool isFormOf_tpnmo(unsigned int n);
MATHCORE_API int isolate_LST( int x);
class MATHCORE_API MathEngine {
public:
MathEngine(void);
};
extern MATHCORE_API int nMathCore;
MATHCORE_API int fnMathCore(void);
and I generated lib - "MathCore.lib" and respective dll-"MathCore.dll" from visual studio 2008,then I created C++ source file-"t.cpp" in a different folder which uses functions defined in MathCore,for simplicity I put MathCore.lib and MathCore.dll within same folder.
t.cpp like this....
#pragma comment(lib, "MathCore.lib")
#include <iostream>
#include "MathCore.h"
using namespace std;
MATHCORE_API bool isPowOf_Two(unsigned int n);
MATHCORE_API bool isFormOf_tpnmo(unsigned int n);
int main()
{
while(1){
unsigned int x;
cin>>x;
cout<<isPowOf_Two(x)<<"\n";
cout<<x<<"\n";
}
system("Pause");
return 0;
}
My problem is.. without using Visual Studio I want to compile the t.cpp using batch file say -"run.bat"
so I included "vcvarsall.bat" and "vcvars32.bat" to same source folder,my "run.bat" commands like this ....
@echo off
call "vcvarsall.bat"
call "vcvars32.bat"
echo off
cl /O2 t.cpp /link MathCore.lib
@if ERRORLEVEL == 0 (
goto good
)
@if ERRORLEVEL != 0 (
goto bad
)
:good
echo "clean compile"
echo %ERRORLEVEL%
goto end
:bad
echo "error or warning"
echo %ERRORLEVEL%
goto end
:end
when I run "run.bat" it creates "t.obj" without "t.exe" I think it does not link MathCore.lib,I want to know how to compile visual C++ source with additional libraries and includes in commandline I chekc visual studio commandline arguements It not helped me to solve this problem.
Please anyone know exact commandline arguements to compile a visual c++ source file with needed libs files.