By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,395 Members | 2,537 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,395 IT Pros & Developers. It's quick & easy.

Error LNK2005, Warning LNK4006, Error LNK2001

P: 8
Dear All,

I am trying to compile a C code using Visual C++. Can anyone explain how to solve it?

Thank You.

#include <math.h>
#include <string.h>
#include "RV2AJFRONT_NEW.h"
#include "RV2AJFRONT_NEW_private.h"
#include "ext_work.h"

#include "RV2AJFRONT_NEW_dt.h"

/* Block signals (auto storage) */
BlockIO rtB;

/* Block states (auto storage) */
D_Work rtDWork;

/* Parent Simstruct */
static rtModel_RV2AJFRONT_NEW model_S;
rtModel_RV2AJFRONT_NEW *const rtM_RV2AJFRONT_NEW = &model_S;

/* Start for root system: '<Root>' */
void MdlStart(void)
{
}

/* Outputs for root system: '<Root>' */
void MdlOutputs(int_T tid)
{
/* local block i/o variables */
real_T rtb_temp6;

/* tid is required for a uniform function interface. This system
* is single rate, and in this case, tid is not accessed. */
UNUSED_PARAMETER(tid);

/* Gain: '<Root>/Gain6' incorporates:
* Gain: '<Root>/Theta1'
* Constant: '<Root>/k1'
*
* Regarding '<Root>/Gain6':
* Gain value: rtP.Gain6_Gain
*
* Regarding '<Root>/Theta1':
* Gain value: rtP.Theta1_Gain
*/
rtb_temp6 = (rtP.k1_Value * rtP.Theta1_Gain) * rtP.Gain6_Gain;

/* Assignment: '<S1>/Assignment' incorporates:
* Constant: '<S4>/Constant'
*/
{
(void)memcpy(&rtB.Assignment_a[0],&rtP.Constant_a_Value[0],4*sizeof(real_T));

rtB.Assignment_a[3] = rtb_temp6;
}

/* Gain: '<Root>/Gain4' incorporates:
* Gain: '<Root>/Theta2'
* Constant: '<Root>/k2'
*
* Regarding '<Root>/Gain4':
* Gain value: rtP.Gain4_Gain
*
* Regarding '<Root>/Theta2':
* Gain value: rtP.Theta2_Gain
*/
rtb_temp6 = (rtP.k2_Value * rtP.Theta2_Gain) * rtP.Gain4_Gain;

/* Assignment: '<S2>/Assignment' incorporates:
* Constant: '<S5>/Constant'
*/
{
(void)memcpy(&rtB.Assignment_b[0],&rtP.Constant_b_Value[0],4*sizeof(real_T));

rtB.Assignment_b[3] = rtb_temp6;
}

/* Gain: '<Root>/Gain5' incorporates:
* Gain: '<Root>/Theta3'
* Constant: '<Root>/k3'
*
* Regarding '<Root>/Gain5':
* Gain value: rtP.Gain5_Gain
*
* Regarding '<Root>/Theta3':
* Gain value: rtP.Theta3_Gain
*/
rtb_temp6 = (rtP.k3_Value * rtP.Theta3_Gain) * rtP.Gain5_Gain;

/* Assignment: '<S3>/Assignment' incorporates:
* Constant: '<S6>/Constant'
*/
{
(void)memcpy(&rtB.Assignment_c[0],&rtP.Constant_c_Value[0],4*sizeof(real_T));

rtB.Assignment_c[3] = rtb_temp6;
}
}

/* Update for root system: '<Root>' */
void MdlUpdate(int_T tid)
{

/* tid is required for a uniform function interface. This system
* is single rate, and in this case, tid is not accessed. */
UNUSED_PARAMETER(tid);
}

/* Terminate for root system: '<Root>' */
void MdlTerminate(void)
{
if(rtM_RV2AJFRONT_NEW != NULL) {
}
}

/* Function to initialize sizes */
void MdlInitializeSizes(void)
{
rtM_RV2AJFRONT_NEW->Sizes.numContStates = (0); /* Number of continuous states */
rtM_RV2AJFRONT_NEW->Sizes.numY = (0); /* Number of model outputs */
rtM_RV2AJFRONT_NEW->Sizes.numU = (0); /* Number of model inputs */
rtM_RV2AJFRONT_NEW->Sizes.sysDirFeedThru = (0); /* The model is not direct feedthrough */
rtM_RV2AJFRONT_NEW->Sizes.numSampTimes = (1); /* Number of sample times */
rtM_RV2AJFRONT_NEW->Sizes.numBlocks = (19); /* Number of blocks */
rtM_RV2AJFRONT_NEW->Sizes.numBlockIO = (3); /* Number of block outputs */
rtM_RV2AJFRONT_NEW->Sizes.numBlockPrms = (21); /* Sum of parameter "widths" */
}

/* Function to initialize sample times */
void MdlInitializeSampleTimes(void)
{
/* task periods */
rtM_RV2AJFRONT_NEW->Timing.sampleTimes[0] = (0.1);

/* task offsets */
rtM_RV2AJFRONT_NEW->Timing.offsetTimes[0] = (0.0);
}

/* Function to register the model */
rtModel_RV2AJFRONT_NEW *RV2AJFRONT_NEW(void)
{
(void)memset((char *)rtM_RV2AJFRONT_NEW, 0, sizeof(rtModel_RV2AJFRONT_NEW));

{
/* Setup solver object */
static RTWSolverInfo rt_SolverInfo;
rtM_RV2AJFRONT_NEW->solverInfo = (&rt_SolverInfo);

rtsiSetSimTimeStepPtr(rtM_RV2AJFRONT_NEW->solverInfo,
&rtM_RV2AJFRONT_NEW->Timing.simTimeStep);
rtsiSetTPtr(rtM_RV2AJFRONT_NEW->solverInfo, &rtmGetTPtr(rtM_RV2AJFRONT_NEW));
rtsiSetStepSizePtr(rtM_RV2AJFRONT_NEW->solverInfo,
&rtM_RV2AJFRONT_NEW->Timing.stepSize);
rtsiSetdXPtr(rtM_RV2AJFRONT_NEW->solverInfo,
&rtM_RV2AJFRONT_NEW->ModelData.derivs);
rtsiSetContStatesPtr(rtM_RV2AJFRONT_NEW->solverInfo,
&rtM_RV2AJFRONT_NEW->ModelData.contStates);
rtsiSetNumContStatesPtr(rtM_RV2AJFRONT_NEW->solverInfo,
&rtM_RV2AJFRONT_NEW->Sizes.numContStates);
rtsiSetErrorStatusPtr(rtM_RV2AJFRONT_NEW->solverInfo,
&rtmGetErrorStatus(rtM_RV2AJFRONT_NEW));

rtsiSetRTModelPtr(rtM_RV2AJFRONT_NEW->solverInfo, rtM_RV2AJFRONT_NEW);
}

/* timing info */
{
static time_T mdlPeriod[NSAMPLE_TIMES];
static time_T mdlOffset[NSAMPLE_TIMES];
static time_T mdlTaskTimes[NSAMPLE_TIMES];
static int_T mdlTsMap[NSAMPLE_TIMES];
static int_T mdlSampleHits[NSAMPLE_TIMES];

{
int_T i;

for(i = 0; i < NSAMPLE_TIMES; i++) {
mdlPeriod[i] = 0.0;
mdlOffset[i] = 0.0;
mdlTaskTimes[i] = 0.0;
}
}
(void)memset((char_T *)&mdlTsMap[0], 0, 1 * sizeof(int_T));
(void)memset((char_T *)&mdlSampleHits[0], 0, 1 * sizeof(int_T));

rtM_RV2AJFRONT_NEW->Timing.sampleTimes = (&mdlPeriod[0]);
rtM_RV2AJFRONT_NEW->Timing.offsetTimes = (&mdlOffset[0]);
rtM_RV2AJFRONT_NEW->Timing.sampleTimeTaskIDPtr = (&mdlTsMap[0]);
rtmSetTPtr(rtM_RV2AJFRONT_NEW, &mdlTaskTimes[0]);
rtM_RV2AJFRONT_NEW->Timing.sampleHits = (&mdlSampleHits[0]);
}
rtsiSetSolverMode(rtM_RV2AJFRONT_NEW->solverInfo, SOLVER_MODE_SINGLETASKING);

/*
* initialize model vectors and cache them in SimStruct
*/

/* block I/O */
{
void *b = (void *) &rtB;
rtM_RV2AJFRONT_NEW->ModelData.blockIO = (b);

{
int_T i;

b =&rtB.Assignment_a[0];
for (i = 0; i < 12; i++) {
((real_T*)b)[i] = 0.0;
}
}
}

/* parameters */
rtM_RV2AJFRONT_NEW->ModelData.defaultParam = ((real_T *) &rtP);

/* data type work */
{
void *dwork = (void *) &rtDWork;
rtM_RV2AJFRONT_NEW->Work.dwork = (dwork);
(void)memset((char_T *) dwork, 0, sizeof(D_Work));
}

/* data type transition information (for external mode) */
{
static DataTypeTransInfo dtInfo;

(void)memset((char_T *) &dtInfo, 0, sizeof(dtInfo));
rtM_RV2AJFRONT_NEW->SpecialInfo.mappingInfo = (&dtInfo);

dtInfo.numDataTypes = 13;
dtInfo.dataTypeSizes = &rtDataTypeSizes[0];
dtInfo.dataTypeNames = &rtDataTypeNames[0];

/* Block I/O transition table */
dtInfo.B = &rtBTransTable;

/* Parameters transition table */
dtInfo.P = &rtPTransTable;
}

/* Model specific registration */

rtM_RV2AJFRONT_NEW->modelName = ("RV2AJFRONT_NEW");
rtM_RV2AJFRONT_NEW->path = ("RV2AJFRONT_NEW");

rtmSetTStart(rtM_RV2AJFRONT_NEW, 0.0);
rtM_RV2AJFRONT_NEW->Timing.tFinal = (10.0);
rtM_RV2AJFRONT_NEW->Timing.stepSize = (0.1);
rtsiSetFixedStepSize(rtM_RV2AJFRONT_NEW->solverInfo, 0.1);
/* Setup for data logging */
{
static RTWLogInfo rt_DataLoggingInfo;

rtM_RV2AJFRONT_NEW->rtwLogInfo = (&rt_DataLoggingInfo);

rtliSetLogFormat(rtM_RV2AJFRONT_NEW->rtwLogInfo, 0);

rtliSetLogMaxRows(rtM_RV2AJFRONT_NEW->rtwLogInfo, 1000);

rtliSetLogDecimation(rtM_RV2AJFRONT_NEW->rtwLogInfo, 1);

rtliSetLogVarNameModifier(rtM_RV2AJFRONT_NEW->rtwLogInfo, "rt_");

rtliSetLogT(rtM_RV2AJFRONT_NEW->rtwLogInfo, "tout");

rtliSetLogX(rtM_RV2AJFRONT_NEW->rtwLogInfo, "");

rtliSetLogXFinal(rtM_RV2AJFRONT_NEW->rtwLogInfo, "");

rtliSetLogXSignalInfo(rtM_RV2AJFRONT_NEW->rtwLogInfo, NULL);

rtliSetLogXSignalPtrs(rtM_RV2AJFRONT_NEW->rtwLogInfo, NULL);

rtliSetLogY(rtM_RV2AJFRONT_NEW->rtwLogInfo, "");

rtliSetLogYSignalInfo(rtM_RV2AJFRONT_NEW->rtwLogInfo, NULL);

rtliSetLogYSignalPtrs(rtM_RV2AJFRONT_NEW->rtwLogInfo, NULL);
}

rtM_RV2AJFRONT_NEW->Sizes.checksums[0] = (2407264236U);
rtM_RV2AJFRONT_NEW->Sizes.checksums[1] = (442019629U);
rtM_RV2AJFRONT_NEW->Sizes.checksums[2] = (1531348761U);
rtM_RV2AJFRONT_NEW->Sizes.checksums[3] = (2098873909U);

{
static const EnableStates rtAlwaysEnabled = SUBSYS_ENABLED;

static RTWExtModeInfo rt_ExtModeInfo;
static const void *sysModes[1];

rtM_RV2AJFRONT_NEW->extModeInfo = (&rt_ExtModeInfo);
rteiSetSubSystemModeVectorAddresses(&rt_ExtModeInf o, sysModes);

sysModes[0] = &rtAlwaysEnabled;

rteiSetModelMappingInfoPtr(&rt_ExtModeInfo,
&rtM_RV2AJFRONT_NEW->SpecialInfo.mappingInfo);

rteiSetChecksumsPtr(&rt_ExtModeInfo, rtM_RV2AJFRONT_NEW->Sizes.checksums);

rteiSetTPtr(&rt_ExtModeInfo, rtmGetTPtr(rtM_RV2AJFRONT_NEW));
}

/* Non-finite (run-time) assignments */
{

rtP.Constant_a_Value[0] = rtNaN;
rtP.Constant_a_Value[1] = rtNaN;
rtP.Constant_a_Value[2] = rtNaN;
rtP.Constant_a_Value[3] = rtNaN;
rtP.Constant_b_Value[0] = rtNaN;
rtP.Constant_b_Value[1] = rtNaN;
rtP.Constant_b_Value[2] = rtNaN;
rtP.Constant_b_Value[3] = rtNaN;
rtP.Constant_c_Value[0] = rtNaN;
rtP.Constant_c_Value[1] = rtNaN;
rtP.Constant_c_Value[2] = rtNaN;
rtP.Constant_c_Value[3] = rtNaN;
}

return rtM_RV2AJFRONT_NEW;
}


--------------------Configuration: PROJECT2 - Win32 Debug--------------------
Linking...
RV2AJFRONT_NEW.obj : error LNK2005: _rtM_RV2AJFRONT_NEW already defined in RV2AJFRONT_NEW.obj
RV2AJFRONT_NEW.obj : error LNK2005: _MdlStart already defined in RV2AJFRONT_NEW.obj
RV2AJFRONT_NEW.obj : error LNK2005: _MdlOutputs already defined in RV2AJFRONT_NEW.obj
RV2AJFRONT_NEW.obj : error LNK2005: _MdlUpdate already defined in RV2AJFRONT_NEW.obj
RV2AJFRONT_NEW.obj : error LNK2005: _MdlTerminate already defined in RV2AJFRONT_NEW.obj
RV2AJFRONT_NEW.obj : error LNK2005: _MdlInitializeSizes already defined in RV2AJFRONT_NEW.obj
RV2AJFRONT_NEW.obj : error LNK2005: _MdlInitializeSampleTimes already defined in RV2AJFRONT_NEW.obj
RV2AJFRONT_NEW.obj : error LNK2005: _RV2AJFRONT_NEW already defined in RV2AJFRONT_NEW.obj
RV2AJFRONT_NEW.obj : warning LNK4006: _rtM_RV2AJFRONT_NEW already defined in RV2AJFRONT_NEW.obj; second definition ignored
RV2AJFRONT_NEW.obj : warning LNK4006: _MdlStart already defined in RV2AJFRONT_NEW.obj; second definition ignored
RV2AJFRONT_NEW.obj : warning LNK4006: _MdlOutputs already defined in RV2AJFRONT_NEW.obj; second definition ignored
RV2AJFRONT_NEW.obj : warning LNK4006: _MdlUpdate already defined in RV2AJFRONT_NEW.obj; second definition ignored
RV2AJFRONT_NEW.obj : warning LNK4006: _MdlTerminate already defined in RV2AJFRONT_NEW.obj; second definition ignored
RV2AJFRONT_NEW.obj : warning LNK4006: _MdlInitializeSizes already defined in RV2AJFRONT_NEW.obj; second definition ignored
RV2AJFRONT_NEW.obj : warning LNK4006: _MdlInitializeSampleTimes already defined in RV2AJFRONT_NEW.obj; second definition ignored
RV2AJFRONT_NEW.obj : warning LNK4006: _RV2AJFRONT_NEW already defined in RV2AJFRONT_NEW.obj; second definition ignored
Creating library Debug/PROJECT2.lib and object Debug/PROJECT2.exp
RV2AJFRONT_NEW.obj : error LNK2001: unresolved external symbol _rtP
RV2AJFRONT_NEW.obj : error LNK2001: unresolved external symbol _rtP
RV2AJFRONT_NEW.obj : error LNK2001: unresolved external symbol _rtNaN
RV2AJFRONT_NEW.obj : error LNK2001: unresolved external symbol _rtNaN
Debug/PROJECT2.dll : fatal error LNK1120: 2 unresolved externals
Error executing link.exe.

PROJECT2.dll - 13 error(s), 8 warning(s)
Jan 2 '08 #1
Share this Question
Share on Google+
1 Reply


Meetee
Expert Mod 100+
P: 931
Before someone try to solve, kindly have a look to the following links. They would provide the reasons for these errors!

LNK2005
LNK4006
LNK2001

Regards
Jan 2 '08 #2

Post your reply

Sign in to post your reply or Sign up for a free account.