Solved

Linker Error 2001 and warnings

Posted on 2001-06-19
7
348 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
  • 2
7 Comments
 
LVL 2

Expert Comment

by:missionImpossible
ID: 6206238
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
ID: 6206275
I did add the lib file.
0
 
LVL 2

Expert Comment

by:agriggs
ID: 6206527
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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:qbawler311
ID: 6206604
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
ID: 6206659
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
ID: 6206720
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
ID: 6206753
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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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…
What is C++ STL?: STL stands for Standard Template Library and is a part of standard C++ libraries. It contains many useful data structures (containers) and algorithms, which can spare you a lot of the time. Today we will look at the STL Vector. …
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

734 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