Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Linker Error 2001 and warnings

Posted on 2001-06-19
7
Medium Priority
?
355 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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 

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 200 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

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

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

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. …
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.

721 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