Solved

_endthread' undefined

Posted on 2001-08-25
6
831 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

 

Author Comment

by:ronandersen
Comment Utility
Kulina,

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

Author Comment

by:ronandersen
Comment Utility
Thank you - it compiled and linked perfectly!
0
 
LVL 3

Expert Comment

by:kulina
Comment Utility
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

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Windows programmers of the C/C++ variety, how many of you realise that since Window 9x Microsoft has been lying to you about what constitutes Unicode (http://en.wikipedia.org/wiki/Unicode)? They will have you believe that Unicode requires you to use…
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.
The goal of this video is to provide viewers with basic examples to understand and use switch statements in the C programming language.

763 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

11 Experts available now in Live!

Get 1:1 Help Now