Solved

_endthread' undefined

Posted on 2001-08-25
6
851 Views
Last Modified: 2012-05-04
When I compile my program, I receive the following error. I searched for these functions, and found them in process.h. However, I still receive the error when I include this header file; also, I receive the same error for _main?

1) Compiler error
Compiling...
dn.c
F:\Program Files\Microsoft Visual Studio\MyProjects\Dn_files\dn.c(1897) : warning C4013: '_endthread' undefined; assuming extern returning int
F:\Program Files\Microsoft Visual Studio\MyProjects\Dn_files\dn.c(1931) : warning C4013: '_beginthread' undefined; assuming extern returning int

dn.obj - 0 error(s), 2 warning(s)


2) Header section of pgm:

#include <stdio.h>
#include <stdlib.h>
#include <signal.h>
#include <string.h>
#include <ctype.h>
#include <process.h>


#include "nntp.h"
#include "dnwin.h"
0
Comment
Question by:ronandersen
  • 3
  • 3
6 Comments
 
LVL 3

Accepted Solution

by:
kulina earned 100 total points
ID: 6425350
By default compiler links with C runtime that doesn't support multihreading.  You have to link explicitly with multithreaded version of C runtime which is (in case of MS VS 6):
LIBCMT.LIB if you are linking staticaly, or
MSVCRT.LIB if you are linking dynamicaly

You can do this as follows (on file by file basis):
1. From the file menu open Project-.Project Settings
2. In "Setting For" box click on the file you wish to link with MT version of CRT
3. Click on th "C/C++" dialog tab.
4. Under "Category" drop-down list select "Code Generation"
5. Under "Use runtime library" select "Multithreaded" for static linking or "Multithreaded DLL" for dynamic linking.

Hope this helps.

0
 

Author Comment

by:ronandersen
ID: 6425528
kulina,

This resolved the _end* and _begin warnings, but I still receive the following error:


Linking...
LIBCD.LIB(crt0.obj) : error LNK2001: unresolved external symbol _main
Debug/dnwin.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.

dnwin.exe - 2 error(s), 0 warning(s)
0
 
LVL 3

Expert Comment

by:kulina
ID: 6425586
This is because the linker can't find the entry point of your application (which is main() for EXE files). Is the file which contains function int main(){...} included in your project? There can be many other reasons for this, so I believe the best thing would be to send your project to me at kulina@home.com . It's easier for me to check it out, find the cause, and fix it rather than guesing your configuration...
Rgds.
0
Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

 

Author Comment

by:ronandersen
ID: 6426457
Kulina,

I will zip up the project and send it to kulina@home.com
0
 

Author Comment

by:ronandersen
ID: 6427286
Thank you - it compiled and linked perfectly!
0
 
LVL 3

Expert Comment

by:kulina
ID: 6427514
Thanks. Here is the problem report for anybody who may purchase this Q:
Since this is a Win32 application, you have to indicate that in the project settings; otherwise the compiler will think that this is a regular C/C++ app, and linker will look for main() instead of WinMain(). The easiest way to do that is to start "clean" Win32 Application project...
0

Featured Post

Does Powershell have you tied up in knots?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

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

Suggested Solutions

This tutorial is posted by Aaron Wojnowski, administrator at SDKExpert.net.  To view more iPhone tutorials, visit www.sdkexpert.net. This is a very simple tutorial on finding the user's current location easily. In this tutorial, you will learn ho…
This is a short and sweet, but (hopefully) to the point article. There seems to be some fundamental misunderstanding about the function prototype for the "main" function in C and C++, more specifically what type this function should return. I see so…
The goal of this video is to provide viewers with basic examples to understand how to use strings and some functions related to them in the C programming language.
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use while-loops in the C programming language.

813 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

16 Experts available now in Live!

Get 1:1 Help Now