Solved

_endthread' undefined

Posted on 2001-08-25
6
843 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
Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

 

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

Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

Question has a verified solution.

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

Summary: This tutorial covers some basics of pointer, pointer arithmetic and function pointer. What is a pointer: A pointer is a variable which holds an address. This address might be address of another variable/address of devices/address of fu…
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 for-loops in the C programming language.

914 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

15 Experts available now in Live!

Get 1:1 Help Now