Link to home
Start Free TrialLog in
Avatar of amozes
amozes

asked on

Unresolved external symbols

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!
Avatar of Axter
Axter
Flag of United States of America image

closedir is not part of VC++, that is a unix function.
_closedir, _readdir, and _opendir are all Unix functions.
Some other compilers use these functions as well, but VC++ does not.

Use findfirst and findnext
ASKER CERTIFIED SOLUTION
Avatar of Axter
Axter
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of amozes
amozes

ASKER

Thanks for the info on the dirs question.  Still stuck on the _main one.
Do you have a main() function in your code?
Avatar of amozes

ASKER

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.
Avatar of amozes

ASKER

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.
Avatar of amozes

ASKER

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.
>>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.
Avatar of amozes

ASKER

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?
Avatar of amozes

ASKER

Well, I renamed it to the project name, but to no avail... I'm opening up a new question based on it.
>>Do I have to call the file that contains the main
>>function by the same name as
>>the project?
No.