7 Replies - 215852 Views - Last Post: 04 June 2010 - 06:24 AM Rate Topic: -----

#1 amatorrr  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 11
  • Joined: 19-November 06

fatal error LNK1120: 1 unresolved externals

Post icon  Posted 07 January 2007 - 09:25 AM

hello :)
I write a code like that

#include<assert.h>
#include<IOSTREAM>
#include<BST.H>


using namespace std;


template<class T>

void arrayfunction(int A[],int n)
{   BST Q; 
	for(int i=0;i<n;i++)
	Q.InsertValue(A[i]);
}
template<class T>
int main(void)
{

FILE * pFile;
  char string[100];
  pFile = fopen ("file.txt","wt");  
  if(pFile!=NULL)
	 
	fputs ("fopen example",pFile);  
		fgets (string , 100 , pFile);
		puts (string);
	
	fclose (pFile); 
  
  return 0;


}



compile gives no error but link

Linking...
LIBCD.lib(crt0.obj) : error LNK2001: unresolved external symbol _main
Debug/file.exe : fatal error LNK1120: 1 unresolved externals


What can cause that mistake are there anyone has any idea??

This post has been edited by amatorrr: 07 January 2007 - 09:29 AM


Is This A Good Question/Topic? 0
  • +

Replies To: fatal error LNK1120: 1 unresolved externals

#2 cipherence  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 1
  • View blog
  • Posts: 260
  • Joined: 01-April 06

Re: fatal error LNK1120: 1 unresolved externals

Posted 07 January 2007 - 09:32 AM

LIBCD.lib(crt0.obj) -- prollly because it can't find that library, check your spelling or your linking command. or if both of those are good, find a download of that library
Was This Post Helpful? 1

#6 ByteWyse  Icon User is offline

  • New D.I.C Head

Reputation: 6
  • View blog
  • Posts: 41
  • Joined: 02-January 07

Re: fatal error LNK1120: 1 unresolved externals

Posted 07 January 2007 - 10:21 AM

You didn't provide a main() function. You only provided a definition for a template function named main.


template<class T>
int main(void)


Was This Post Helpful? 1

#7 amatorrr  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 11
  • Joined: 19-November 06

Re: fatal error LNK1120: 1 unresolved externals

Post icon  Posted 09 January 2007 - 10:46 AM

View PostByteWyse, on 7 Jan, 2007 - 10:21 AM, said:

You didn't provide a main() function. You only provided a definition for a template function named main.

You were right my problem was that thanks a lot :D
Was This Post Helpful? 0
  • +
  • -

#11 lahja  Icon User is offline

  • New D.I.C Head

Reputation: 2
  • View blog
  • Posts: 1
  • Joined: 25-June 08

Re: fatal error LNK1120: 1 unresolved externals

Posted 25 June 2008 - 06:40 AM

Hi
If your problem is fixed well.
If not I hope it is something to do with Linker and libraries.
So in the project properties -> linker ->additional dependencies ->
add the necessary libraries such as:
kernel32.lib, user32.lib, gdi32.lib, winspool.lib, comdlg32.lib, advapi32.lib, shell32.lib, ole32.lib, oleaut32.lib, and
uuid32.32

hope it helps(ofcourse windows environment)
:crazy:


View Postamatorrr, on 9 Jan, 2007 - 10:46 AM, said:

View PostByteWyse, on 7 Jan, 2007 - 10:21 AM, said:

You didn't provide a main() function. You only provided a definition for a template function named main.

You were right my problem was that thanks a lot :D

Was This Post Helpful? 1

#12 polymath  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 52
  • View blog
  • Posts: 670
  • Joined: 04-April 08

Re: fatal error LNK1120: 1 unresolved externals

Posted 25 June 2008 - 09:38 AM

Did you notice this topic is a year old?
Was This Post Helpful? 1

#13 Guest_crazy_mapple*


Reputation:

Re: fatal error LNK1120: 1 unresolved externals

Posted 04 June 2010 - 06:13 AM

MSVCRTD.lib(crtexe.obj) : error LNK2019: reference to the unresolved external symbol _main in the function ___tmainCRTStartup
C:\Users\username\Documents\Visual Studio 2008\Projects\Crazy_Mapple_Reader\Debug\Crazy_Mapple_Reader.exe : fatal error LNK1120: An unresolved external elements

Could somebody help me?
Was This Post Helpful? 0

#14 JackOfAllTrades  Icon User is offline

  • Saucy!
  • member icon

Reputation: 6066
  • View blog
  • Posts: 23,526
  • Joined: 23-August 08

Re: fatal error LNK1120: 1 unresolved externals

Posted 04 June 2010 - 06:24 AM

Did you read the topic? It looks like you didn't create a main function, or created one in the wrong format for your project.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1