Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 357
  • Last Modified:

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)
0
qbawler311
Asked:
qbawler311
  • 3
  • 2
  • 2
1 Solution
 
missionImpossibleCommented:
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.
0
 
qbawler311Author Commented:
I did add the lib file.
0
 
agriggsCommented:
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.
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
qbawler311Author Commented:
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.


0
 
agriggsCommented:
You are getting those warnings because you have declared them as variables, but you aren't using them anywhere.

Either delete the declarations, or use the variables.  It looks to me like you don't need any of them.

0
 
missionImpossibleCommented:
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.
0
 
qbawler311Author Commented:
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.
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

  • 3
  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now