Link to home
Start Free TrialLog in
Avatar of qbawler311
qbawler311

asked on

Linker Error 2001 and warnings

I'm using a function called NetScheduleJobAdd() and when I build it I get Linker Error 2001 and 4 warnings.  The code is :

#include <string.h>
#include <stdio.h>
#include <windows.h>
#include <stdlib.h>
#include <lm.h>
#include <lmat.h>

     int main(void)
     {
          char server[256];
          long JobTime;
          int DaysOfMonth, DayOfWeek;
          DWORD rc, jobId;
 

          char ascOther[80];
          AT_INFO myATINFO;
          myATINFO.JobTime = 36000000 ; //Time from midnight in ms
          myATINFO.DaysOfMonth = 0;
          myATINFO.DaysOfWeek = 1;        // 0 = mon, 1=tues, etc.
          myATINFO.Flags = JOB_RUN_PERIODICALLY;
          myATINFO.Command = L"c:\\LaunchJob.exe";
         
            strcmp(server,  "barbaccija");

          rc = NetScheduleJobAdd((LPWSTR) &server , (byte *)&myATINFO, &jobId  );    
          return 0;
     }
 

The Errors and warnings are:

Netschedule.cpp
c:\rocklobsterj\ptest1\netschedule.cpp(20) : warning C4101: 'ascOther' : unreferenced local variable
c:\rocklobsterj\ptest1\netschedule.cpp(13) : warning C4101: 'JobTime' : unreferenced local variable
c:\rocklobsterj\ptest1\netschedule.cpp(14) : warning C4101: 'DayOfWeek' : unreferenced local variable
c:\rocklobsterj\ptest1\netschedule.cpp(14) : warning C4101: 'DaysOfMonth' : unreferenced local variable
Linking...
Netschedule.obj : error LNK2001: unresolved external symbol _NetScheduleJobAdd@12
Debug/Netschedule.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.

Netschedule.exe - 2 error(s), 4 warning(s)
Avatar of missionImpossible
missionImpossible

you call the method "NetScheduleJobAdd" which is not implemented. I guess, you've included the header-file but not added the lib-file to your project.
Avatar of qbawler311

ASKER

I did add the lib file.
I hope to save you more points when you get this program linked and it still doesn't work.  

I think you wanted strcpy instead of strcmp.  

Strcpy will copy the string that you specified into the string variable that you pass to the function.  Strcmp will only return a value telling you if the two strings are equal or not, and you have not even checked the return value.

Just to make sure, in order to link with the correct lib file, you need to go to the Project Menu, Settings Option, which brings up a tabbed dialog box.  Click on the link tab, and add the correct lib file to the Object/Library modules field.
Sorry, I thought I added the lib file but as it turns out I didn't.  Anyway since you both suggested it I'll give an 'A' to whom ever answers the rest of the question which is:

Netschedule.cpp
c:\rocklobsterj\ptest1\netschedule.cpp(20) : warning C4101: 'ascOther' : unreferenced local variable
c:\rocklobsterj\ptest1\netschedule.cpp(13) : warning C4101: 'JobTime' : unreferenced local variable
c:\rocklobsterj\ptest1\netschedule.cpp(14) : warning C4101: 'DayOfWeek' : unreferenced local variable
c:\rocklobsterj\ptest1\netschedule.cpp(14) : warning C4101: 'DaysOfMonth' : unreferenced local variable


I need these warnings gone.


ASKER CERTIFIED SOLUTION
Avatar of agriggs
agriggs

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
this is clear 'unreferenced local variable' says nothing else.

in my opinion the problem was the lib-file and I answered first. but its your decision.
I messed up it was my fault and I said I would give the points to the person who told what to do with the 4 warnings.  Since agriggs responded I had to give them to him.