473,699 Members | 2,254 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Unresolved External Help.

I'm currently working on a class "Course" and I'm getting an unresolved
external error when trying to compile.

I understand that unresolved externals are caused by declaration of methods
that are not defined, but I think I defined all my methods so this one has
got me stumped. Any help would be much appreciated.

Thank you for your time,

Kyle

course.h
--------
#ifndef COURSE_H
#define COURSE_H

#include <string>
using namespace std;

class Course
{
private:
string id;
int credithours;
string instructor;
string days;
string time;
string room;
int capacity;
string roster[50];
int size;
public:
Course();// Default Constructor
void ReadCourse(istr eam & fin);// Reads course information from file.
void WriteCourse(ost ream & fout);// Writes course information to file.
void PrintData();// Prints's all data except roster to screen with labels.
void PrintRoster(ost ream & out);// Prints Roster to any output stream.
void AddStudent(ostr eam & out, string newstudent);// Adds student to
roster.
};

#endif
Course.cpp
----------
#include "course.h"
#include <iostream>
using namespace std;

Course::Course( )
{
id="0";
}

void Course::ReadCou rse(istream & fin)// Reads course information from file.
{
fin >> id;
fin >> credithours;
getline(fin, instructor);
fin >> days;
getline(fin, time);
getline(fin, room);
fin >> capacity;
fin >> size;
for (int i=0; i<=size; i++)
{
getline(fin, roster[i]);
}
}

void Course::WriteCo urse(ostream & fout)// Writes course information to
file.
{
fout << id << " " << credithours << "\n";
fout << instructor << "\n";
fout << days << " " << time << "\n";
fout << room << "\n";
fout << capacity << " " << size << "\n";
for (int i=0; i<=size; i++)
{
fout << roster[i] << "\n";
}
}

void Course::PrintDa ta()// Prints's all data except roster to screen with
labels.
{
cout << "Course ID: " << id << endl;
cout << "Credits: " << credithours << endl;
cout << "Instructor : " << instructor << endl;
cout << "Days and Time: " << days << " " << time << endl;
cout << "Capacity: " << capacity << endl;
cout << "Enrolled: " << size << endl;
}

void Course::PrintRo ster(ostream & out)// Prints Roster to any output
stream.
{
for (int i=0; i<=size; i++)
{
out << roster[i] << endl;
}
}

void Course::AddStud ent(ostream & out, string newstudent)// Adds student to
roster.
{
size+=1;
roster[size]=newstudent;
}

ERROR:
LIBCD.lib(crt0. obj) : error LNK2019: unresolved external symbol _main
referenced in function _mainCRTStartup
Debug/Project 1.exe : fatal error LNK1120: 1 unresolved externals
Jul 22 '05 #1
4 2942
On Fri, 16 Jan 2004 09:52:25 -0600, Kyle Sheldon wrote:
I'm currently working on a class "Course" and I'm getting an unresolved
external error when trying to compile.

I understand that unresolved externals are caused by declaration of
methods that are not defined, but I think I defined all my methods so
this one has got me stumped. Any help would be much appreciated.

ERROR:
LIBCD.lib(crt0. obj) : error LNK2019: unresolved external symbol _main
referenced in function _mainCRTStartup Debug/Project 1.exe : fatal error
LNK1120: 1 unresolved externals


Every C++ program needs a "main" function, either written by you or
provided implicitly by some library. I guess you need to write one.

Jul 22 '05 #2
"Kyle Sheldon" <ks*****@ilstu. edu> wrote...
I'm currently working on a class "Course" and I'm getting an unresolved
external error when trying to compile.
Actually, you get this error when trying to _link_, not compile.
I understand that unresolved externals are caused by declaration of methods that are not defined, but I think I defined all my methods so this one has
got me stumped. Any help would be much appreciated.
[...]

ERROR:
LIBCD.lib(crt0. obj) : error LNK2019: unresolved external symbol _main
referenced in function _mainCRTStartup
Debug/Project 1.exe : fatal error LNK1120: 1 unresolved externals


Every C++ program has to contain a function called 'main'. Execution
starts with it. When you try to link your [incomplete] program, your
compiler is trying to resolve a reference to 'main'. Two solutions:
either stop trying to link an incomplete program, or add 'main' function.

Victor
Jul 22 '05 #3
"Kyle Sheldon" <ks*****@ilstu. edu> wrote in message news:<bu******* ***@malachite.i lstu.edu>...
I'm currently working on a class "Course" and I'm getting an unresolved
external error when trying to compile.

I understand that unresolved externals are caused by declaration of methods
that are not defined, but I think I defined all my methods so this one has
got me stumped. Any help would be much appreciated.

Thank you for your time,

Kyle

course.h
--------
#ifndef COURSE_H
#define COURSE_H

#include <string>
using namespace std;

class Course
{
private:
string id;
int credithours;
string instructor;
string days;
string time;
string room;
int capacity;
string roster[50];
int size;
public:
Course();// Default Constructor
void ReadCourse(istr eam & fin);// Reads course information from file.
void WriteCourse(ost ream & fout);// Writes course information to file.
void PrintData();// Prints's all data except roster to screen with labels.
void PrintRoster(ost ream & out);// Prints Roster to any output stream.
void AddStudent(ostr eam & out, string newstudent);// Adds student to
roster.
};

#endif
Course.cpp
----------
#include "course.h"
#include <iostream>
using namespace std;

Course::Course( )
{
id="0";
}

void Course::ReadCou rse(istream & fin)// Reads course information from file.
{
fin >> id;
fin >> credithours;
getline(fin, instructor);
fin >> days;
getline(fin, time);
getline(fin, room);
fin >> capacity;
fin >> size;
for (int i=0; i<=size; i++)
{
getline(fin, roster[i]);
}
}

void Course::WriteCo urse(ostream & fout)// Writes course information to
file.
{
fout << id << " " << credithours << "\n";
fout << instructor << "\n";
fout << days << " " << time << "\n";
fout << room << "\n";
fout << capacity << " " << size << "\n";
for (int i=0; i<=size; i++)
{
fout << roster[i] << "\n";
}
}

void Course::PrintDa ta()// Prints's all data except roster to screen with
labels.
{
cout << "Course ID: " << id << endl;
cout << "Credits: " << credithours << endl;
cout << "Instructor : " << instructor << endl;
cout << "Days and Time: " << days << " " << time << endl;
cout << "Capacity: " << capacity << endl;
cout << "Enrolled: " << size << endl;
}

void Course::PrintRo ster(ostream & out)// Prints Roster to any output
stream.
{
for (int i=0; i<=size; i++)
{
out << roster[i] << endl;
}
}

void Course::AddStud ent(ostream & out, string newstudent)// Adds student to
roster.
{
size+=1;
roster[size]=newstudent;
}

ERROR:
LIBCD.lib(crt0. obj) : error LNK2019: unresolved external symbol _main
referenced in function _mainCRTStartup
Debug/Project 1.exe : fatal error LNK1120: 1 unresolved externals

It looks like the problem is your project actually is missing a "main"
function for running. The code above defines a Class, but a Class by
itself doesn't do much. You need a program which instantiates the
Class as an Object, then you would utilize the Methods declared above
on the Object:

int main (void)
{
.....
Course Mathmatics = new Course;
Mathmatics->PrintRoster(pS tdOut);
.....
}

If you create a program with a main function and link it with the
compiled OBJect file of your Class, you should not get that linkage
error.

-JH
Jul 22 '05 #4
"Kyle Sheldon" <ks*****@ilstu. edu> wrote in message news:<bu******* ***@malachite.i lstu.edu>...
[snip]
ERROR:
LIBCD.lib(crt0. obj) : error LNK2019: unresolved external symbol _main
referenced in function _mainCRTStartup
Debug/Project 1.exe : fatal error LNK1120: 1 unresolved externals


Good thing you included the error message.

You've not defined the symbol main. Probably you are using one of
Microsoft's compilers and have screwed up the type of project so
as to have it want a main when you've provided it something like
WinMain, or the other way around. It's nothing to do with the
code, so you need help from a windows coding group to solve it.
Socks
Jul 22 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
10076
by: Rodolphe | last post by:
Hello, I'm French so sorry for my approximate English. When I try to compile a project under Visual C++ 6.0, I've got the following errors : applicap.obj : error LNK2001: unresolved external symbol _IID_ISampleGrabber applicap.obj : error LNK2001: unresolved external symbol _CLSID_NullRenderer applicap.obj : error LNK2001: unresolved external symbol
2
5603
by: Freddy | last post by:
I am not an experienced programmer, but I had a VC++ program I am trying to eliminate all the VC++ commands from it...and keeping it as a normal C/C++ program......I guess I have succeeded so far, but I am getting the unresolved external symbol errors, this is what I am getting: Linking... Test.obj : error LNK2001: unresolved external symbol "void __cdecl free_vector(double *)" (?free_vector@@YAXPAN@Z)
1
8410
by: Aravind | last post by:
we have two files: 1. rc4.c (defines one function "create_pin()") 2. MyImpl.c(calling the function "create_pin()"),This implements JNI method. 1.When I am trying to create .dll file with one file rc4.obj(rc4.c),it is creating the .dll file without any error. Command : ILINK32 rc4.obj 2.But,when we are trying to create .dll file with two .obj files with following errors.
5
17717
by: cschettle | last post by:
I think you need to link with msvcrt.lib ----== Posted via Newsfeed.Com - Unlimited-Uncensored-Secure Usenet News==---- http://www.newsfeed.com The #1 Newsgroup Service in the World! >100,000 Newsgroups ---= 19 East/West-Coast Specialized Servers - Total Privacy via Encryption =---
2
5324
by: f rom | last post by:
----- Forwarded Message ---- From: Josiah Carlson <jcarlson@uci.edu> To: f rom <etaoinbe@yahoo.com>; wxpython-users@lists.wxwidgets.org Sent: Monday, December 4, 2006 10:03:28 PM Subject: Re: 1>make_buildinfo.obj : error LNK2019: unresolved external symbol __imp__RegQueryValueExA@24 referenced in function _make_buildinfo2 Ask on python-list@python.org . - Josiah
6
121908
by: sadegh | last post by:
Hi I have a problem with my program in VC++6 When I compile it, the following errors are listed. I spend a lot of time on the groups.google.com to find its reason, but none of comments could not help me. Does any body know what is the problem?. Thanks. OtherFunctions.obj : error LNK2001: unresolved external symbol "int
5
4792
by: bonnielym84 | last post by:
Im new here..didnt noe whether is this the rite way to post my problem..Really need help here..i've been stucked in this error from last wk..My problem is like this..Im using VC++ 6.0 to compile my C codes so that i could generate a dll file out of it and used in my C# program.. When I compile, got no error and no warning. But when i build it, i have these errors.. *beginning* sendrcv.obj : error LNK2001: unresolved external symbol "int...
0
1894
by: bonnielym84 | last post by:
Im new here and im not sure whether is this the right place for me to post my question..anyway..hope that you can help me..i have been stucked in this problem since last wk..My problem is..I'm using VC++6.0 to compile my C code in order to get a DLL file for my C# program..but then..when i compile and build..i get 9 errors..n here they are... *beginning* sendrcv.obj : error LNK2001: unresolved external symbol "int __cdecl CS2_RECEIVE(struct...
0
2703
by: Ryan Gaffuri | last post by:
hlink72@hotmail.com (Eric) wrote in message news:<ab8d8b14.0308220550.54fb5f22@posting.google.com>... LNK1120 is a standard C++ error. you using Visual C++? Means your references a class that doesnt exist or something similiar to that. explanation on microsoft.com its not an oracle specific problem.
2
2716
by: =?Utf-8?B?YmFzaA==?= | last post by:
Hello, I am compiling a CPP code using Visual studion .net 2003. I get the following error, despite having windldap.h and wldap32.dll in my include and lib paths. Here is the error. uuid.lib rpcrt4.lib ole32.lib oleaut32.lib uuid.lib Creating library libsq00.lib and object libsq00.exp libq00.lib(ootb.obj) : error LNK2019: unresolved external symbol _ldap_unbind@4
0
8613
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9172
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9032
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
7745
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6532
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5869
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4374
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
2344
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2008
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.