Solved

Unresolved external symbols

Posted on 2001-08-07
12
458 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
Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

 

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
 

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

Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

Question has a verified solution.

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

Introduction This article is the first in a series of articles about the C/C++ Visual Studio Express debugger.  It provides a quick start guide in using the debugger. Part 2 focuses on additional topics in breakpoints.  Lastly, Part 3 focuses on th…
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 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 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.

773 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