Solved

Linker Error 2001 and warnings

Posted on 2001-06-19
7
332 Views
Last Modified: 2012-06-21
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
Comment
Question by:qbawler311
  • 3
  • 2
  • 2
7 Comments
 
LVL 2

Expert Comment

by:missionImpossible
Comment Utility
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
 

Author Comment

by:qbawler311
Comment Utility
I did add the lib file.
0
 
LVL 2

Expert Comment

by:agriggs
Comment Utility
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
Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

 

Author Comment

by:qbawler311
Comment Utility
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
 
LVL 2

Accepted Solution

by:
agriggs earned 50 total points
Comment Utility
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
 
LVL 2

Expert Comment

by:missionImpossible
Comment Utility
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
 

Author Comment

by:qbawler311
Comment Utility
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

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Templates For Beginners Or How To Encourage The Compiler To Work For You Introduction This tutorial is targeted at the reader who is, perhaps, familiar with the basics of C++ but would prefer a little slower introduction to the more ad…
Introduction This article is a continuation of the C/C++ Visual Studio Express debugger series. Part 1 provided a quick start guide in using the debugger. Part 2 focused on additional topics in breakpoints. As your assignments become a little more …
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now