Solved

Unresolved external symbols

Posted on 2001-08-07
12
450 Views
Last Modified: 2012-05-04
Hi guys,
think you can tell me which libs these are coming from (running Win NT VC++)

Linking...
directory.obj : error LNK2001: unresolved external symbol _closedir
directory.obj : error LNK2001: unresolved external symbol _readdir
directory.obj : error LNK2001: unresolved external symbol _opendir
LIBCD.LIB(crt0.obj) : error LNK2001: unresolved external symbol _main
Debug/mytron2.exe : fatal error LNK1120: 4 unresolved externals
Error executing link.exe.

Thanks!
0
Comment
Question by:amozes
  • 6
  • 6
12 Comments
 
LVL 30

Expert Comment

by:Axter
ID: 6361790
closedir is not part of VC++, that is a unix function.
0
 
LVL 30

Expert Comment

by:Axter
ID: 6361793
_closedir, _readdir, and _opendir are all Unix functions.
Some other compilers use these functions as well, but VC++ does not.

Use findfirst and findnext
0
 
LVL 30

Accepted Solution

by:
Axter earned 50 total points
ID: 6361798
_findfirst, _findfirsti64, _wfindfirst, _wfindfirsti64
Provides information about the first instance of a filename that matches the file specified in the filespec argument.
long _findfirst( char *filespec, struct _finddata_t *fileinfo );
__int64 _findfirsti64( char *filespec, struct _finddata_t *fileinfo );
long _wfindfirst( wchar_t *filespec, struct _wfinddata_t *fileinfo );
__int64 _wfindfirsti64( wchar_t *filespec, struct _wfinddata_t *fileinfo );

_findnext, _findnexti64, _wfindnext, _wfindnexti64
Find the next name, if any, that matches the filespec argument in a previous call to _findfirst, and then alters the fileinfo structure contents accordingly.
int _findnext( long handle, struct _finddata_t *fileinfo );
__int64 _findnexti64( long handle, struct _finddata_t *fileinfo );
int _wfindnext( long handle, struct _wfinddata_t *fileinfo );
__int64 _wfindnexti64( long handle, struct _wfinddata_t *fileinfo );

0
 

Author Comment

by:amozes
ID: 6361883
Thanks for the info on the dirs question.  Still stuck on the _main one.
0
 
LVL 30

Expert Comment

by:Axter
ID: 6361896
Do you have a main() function in your code?
0
 

Author Comment

by:amozes
ID: 6361936
Yes.  I'm not sure how to tell the compiler that this file (call it main.c) is the one that contains the main function.
0
Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

 

Author Comment

by:amozes
ID: 6361946
That made me realize that I am working with C files and not C++ files (does this make a difference)?  I remember hearing about using console vs. win32 apps.  Which one should I be using?  Right now I'm using console.
0
 

Author Comment

by:amozes
ID: 6361989
That made me realize that I am working with C files and not C++ files (does this make a difference)?  I remember hearing about using console vs. win32 apps.  Which one should I be using?  Right now I'm using console.
0
 
LVL 30

Expert Comment

by:Axter
ID: 6362030
>>That made me realize that I am working with C files and
>>not C++ files (does this make a difference)?
It makes a different with VC++.  By default VC++ will compile *.c files as C code, and *.cpp files as C++ code.

You must include your main.c file to the project.
To do this, click on Project on the main menu, and then click Add-To-Project
Then click FILES, and select the file you want to add to your project.

You need to do this for all the project files.

>>Right now I'm using console.
I'm sure this is what you want to use.
0
 

Author Comment

by:amozes
ID: 6362048
I already did that.  Do I have to call the file that contains the main function by the same name as the project?
For example if my project was called testapp, do I have to have a testapp.c?
0
 

Author Comment

by:amozes
ID: 6362076
Well, I renamed it to the project name, but to no avail... I'm opening up a new question based on it.
0
 
LVL 30

Expert Comment

by:Axter
ID: 6362110
>>Do I have to call the file that contains the main
>>function by the same name as
>>the project?
No.
0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

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. …
Many modern programming languages support the concept of a property -- a class member that combines characteristics of both a data member and a method.  These are sometimes called "smart fields" because you can add logic that is applied automaticall…
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

757 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

21 Experts available now in Live!

Get 1:1 Help Now