Re: unresolved external symbol
- From: "AK" <AK@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Tue, 8 Nov 2005 09:34:09 -0800
Yes - that does it !
Thank you for the help - this will remind me to protype functions within
the namespace of their use.
Regards,
ak
"Nishant Sivakumar" wrote:
> In labtest2.h, the function should be declared as :-
>
> namespace K1
> {
> int ReadLn(FILE *ifile, char line[]);
> }
>
> --
> Regards,
> Nish [VC++ MVP]
>
>
> "AK" <AK@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
> news:387E6E8D-3BB0-45CC-AD86-088E74CAE5EB@xxxxxxxxxxxxxxxx
> > In the scaled down version, I only have 3 files : Form1.cpp, Lab Test 2.h,
> > &
> > Form2.h . The contents of Form1.cpp are :
> >
> > #include "stdafx.h"
> > #include "Form2.h"
> > #include <windows.h>
> >
> > using namespace K1;
> >
> > int APIENTRY _tWinMain(HINSTANCE hInstance,
> > HINSTANCE hPrevInstance,
> > LPTSTR lpCmdLine,
> > int nCmdShow)
> > {
> > System::Threading::Thread::CurrentThread->ApartmentState =
> > System::Threading::ApartmentState::STA;
> > Application::Run(new Form2());
> > return 0;
> > }
> >
> > The contents of LabTest 2.h are :
> >
> > #define MAX_DWELL_SAMPLES 1000
> >
> > typedef unsigned short ushort;
> >
> > #pragma pack(1)
> >
> >
> >
> > #pragma pack()
> >
> > /*
> > ***********************
> > ** Function prototypes
> > ***********************
> > */
> >
> >
> > int ReadLn(FILE *ifile, char line[]);
> >
> >
> > & the contents of Form2.h are :
> >
> > #pragma once
> > #include <stdio.h>
> > #include <windows.h>
> > #include <math.h>
> > #include <sys/timeb.h>
> > #include <time.h>
> > #include "LabTest 2.h"
> >
> >
> > namespace K1
> > {
> >
> > using namespace System;
> > using namespace System::ComponentModel;
> > using namespace System::Collections;
> > using namespace System::Windows::Forms;
> > using namespace System::Data;
> > using namespace System::Drawing;
> >
> >
> > int point_cnt = 0, dwell_samples = 0;
> > char ifname[80];
> > FILE *sfile;
> > char *timeline;
> > int i, retries;
> > struct _timeb timebuffer;
> > BOOL bStatus;
> >
> >
> > /// <summary>
> > /// Summary for Form2
> > ///
> > /// WARNING: If you change the name of this class, you will need to change
> > the
> > /// 'Resource File Name' property for the managed resource
> > compiler tool
> > /// associated with all .resx files this class depends on.
> > Otherwise,
> > /// the designers will not be able to interact properly with
> > localized
> > /// resources associated with this form.
> > /// </summary>
> > public __gc class Form2 : public System::Windows::Forms::Form
> > {
> > public:
> > Form2(void)
> > {
> > InitializeComponent();
> > }
> >
> > protected:
> > void Dispose(Boolean disposing)
> > {
> > if (disposing && components)
> > {
> > components->Dispose();
> > }
> > __super::Dispose(disposing);
> > }
> > private: System::Windows::Forms::Button * button1;
> >
> >
> >
> >
> >
> > private:
> > /// <summary>
> > /// Required designer variable.
> > /// </summary>
> > System::ComponentModel::Container* components;
> >
> > /// <summary>
> > /// Required method for Designer support - do not modify
> > /// the contents of this method with the code editor.
> > /// </summary>
> > void InitializeComponent(void)
> > {
> > this->button1 = new System::Windows::Forms::Button();
> > this->SuspendLayout();
> > //
> > // button1
> > //
> > this->button1->Location = System::Drawing::Point(112, 112);
> > this->button1->Name = S"button1";
> > this->button1->Size = System::Drawing::Size(144, 48);
> > this->button1->TabIndex = 0;
> > this->button1->Text = S"test button";
> > this->button1->Click += new System::EventHandler(this, button1_Click);
> > //
> > // Form2
> > //
> > this->AutoScaleBaseSize = System::Drawing::Size(5, 13);
> > this->ClientSize = System::Drawing::Size(400, 254);
> > this->Controls->Add(this->button1);
> > this->Name = S"Form2";
> > this->Text = S"Form2";
> > this->ResumeLayout(false);
> >
> > }
> >
> >
> > private: System::Void button1_Click(System::Object * sender,
> > System::EventArgs * e)
> > {
> >
> > FILE *ifile;
> > int ret = FALSE, i, status;
> > char line[80];
> >
> > ifile = fopen(ifname, "rt");
> > if (ifile == NULL) printf("Unable to open %s\n", ifname);
> > else
> > {
> > status = ReadLn(ifile, line);
> > if (status) sscanf(line, "%d", &dwell_samples);
> > if (dwell_samples > MAX_DWELL_SAMPLES) dwell_samples =
> > MAX_DWELL_SAMPLES;
> >
> >
> > i = 0;
> > status = ReadLn(ifile, line);
> > while (status)
> > {
> > status = ReadLn(ifile, line);
> > i++;
> > }
> > point_cnt = i;
> > ret = TRUE;
> > }
> > fclose(ifile);
> >
> > }
> >
> >
> > };
> >
> >
> >
> >
> > int ReadLn(FILE *ifile, char line[])
> > {
> > int status, i = 0;
> > char buffer;
> >
> > status = fread(&buffer, 1, 1, ifile);
> > while ((status) && (buffer != '\n') && (i < 80))
> > {
> > line[i++] = buffer;
> > status = fread(&buffer, 1, 1, ifile);
> > }
> > line[i] = 0;
> >
> > return status;
> > }
> >
> > }
> >
> > Regards,
> > ak
> >
> >
> > "Nishant Sivakumar" wrote:
> >
> >> Have you added the corresponding cpp file to the project?
> >>
> >> --
> >> Regards,
> >> Nish [VC++ MVP]
> >>
> >>
> >> "AK" <AK@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
> >> news:1A937CBA-CD9C-4AE9-9DA0-217F296111C4@xxxxxxxxxxxxxxxx
> >> >I have a .NET application that compiles but has a problem during linking
> >> >:
> >> >
> >> > error LNK2001: unresolved external symbol "int __cdecl ReadLn(struct
> >> > _iobuf
> >> > *,char * const)" (?ReadLn@@$$FYAHPAU_iobuf@@QAD@Z)
> >> >
> >> > The ReadLn function prototype is defined in a header file
> >> > & is called in another header file.
> >> > My compiler options are set to /Gd & /Tp.
> >> >
> >> > If I do not call the function (& just have it's prototype declared),
> >> > then the program links fine.
> >> >
> >> > When I try to resolve the ambiguity by explicitly calling the function
> >> > like namespace::function, I get an error saying that function is not a
> >> > member of namespace. This puzzles me since everywhere I look
> >> > (Classe View, Intellisense, Context Help) recognizes ReadLn as
> >> > a member of the my namespace.
> >> >
> >> > Why is the linker confused on this function ?
> >> >
> >> > Regards,
> >> > ak
> >>
> >>
> >>
>
>
>
.
- References:
- Re: unresolved external symbol
- From: Nishant Sivakumar
- Re: unresolved external symbol
- From: AK
- Re: unresolved external symbol
- From: Nishant Sivakumar
- Re: unresolved external symbol
- Prev by Date: Re: CComboBoxEx
- Next by Date: VS Launch
- Previous by thread: Re: unresolved external symbol
- Next by thread: Re: CComboBoxEx
- Index(es):