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);
// This class is exported from the MathCore.dll
class MATHCORE_API MathEngine {
public:
MathEngine(void);
// TODO: add your methods here.
};
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 as following
#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 was not help me to solve this problem.
PLEASE ANYONE KNOW EXACT COMMANDLINE ARGUEMENTS TO COMPILE A VISUAL C++ SOURCE FILE WITH NEEDED LIBS and Header FILES please refer http://msdn.microsoft.com/en-us/library/610ecb4h.aspx
Without khowing actual error It will be difficult to say.
I created one sample lib and tried to link it. To make it work, I changed line below.
to
Would be nice if you run *.bat (run.bat, in your case) and paste the error here.
[PS: I am not able to add comment hence adding reply]