Navigacija
Lista poslednjih: 16, 32, 64, 128 poruka.

MFC pocetnik u Visual Studiu .NET

[es] :: C/C++ programiranje :: C/C++ za početnike :: MFC pocetnik u Visual Studiu .NET

[ Pregleda: 3122 | Odgovora: 4 ] > FB > Twit

Postavi temu Odgovori

Autor

Pretraga teme: Traži
Markiranje Štampanje RSS

mrzli777
Hrvatska

Član broj: 50641
Poruke: 18
*.adsl.net.t-com.hr.



Profil

icon MFC pocetnik u Visual Studiu .NET26.12.2005. u 10:01 - pre 222 meseci
Pozdrav.

Pocinjem se uciti raditi aplikacije pomocu MFC-a u Visual Studiu .NET i naisao sam na prvu prepreku. Ne koristim nikakav wizard nego kopiram kod kod sa stranica tutorijala. Javlja mi dvije greske i ne znam kako ih otkloniti:

01_HelloWorld error LNK2019: unresolved external symbol __endthreadex referenced in function "void __stdcall AfxEndThread(unsigned int,int)" (?AfxEndThread@@YGXIH@Z)

01_HelloWorld error LNK2019: unresolved external symbol __beginthreadex referenced in function "public: int __thiscall CWinThread::CreateThread(unsigned long,unsigned int,struct _SECURITY_ATTRIBUTES *)" (?CreateThread@CWinThread@@QAEHKIPAU_SECURITY_ATTRIBUTES@@@Z)

Uglavnom, mislim da nije problem u izvornom kodu (moze se naci na http://devcentral.iticentral.com/articles/MFC/vc6_mfc/2.php, ali je potrebno registriranje na http://devcentral.iticentral.com/register.php) nego (pretpostavljam) u nekim postavkama kompajlera ili projekta ili eventualno nekom #include. Naime, tutorijal je za VC++ dok ja koristim .NET.

Ako netko zna u cemo je tocno problem, unaprijed hvala.
 
Odgovor na temu

NrmMyth
Ivan Maček
Split

Član broj: 63456
Poruke: 849
*.cmu.carnet.hr.

Sajt: www.dump.hr


Profil

icon Re: MFC pocetnik u Visual Studiu .NET26.12.2005. u 14:32 - pre 222 meseci
Pogleadajmo sta ti kaze MSDN.
Citat:
unresolved external symbol 'symbol' referenced in function 'function'

An undefined external symbol (symbol) was found in function. To resolve this error, provide a definition for symbol or remove the code that references it.

In Visual C++ .NET 2003, this error will be generated when /clr is used and the CRT is not linked into your executable. Any object code generated by the compiler that is not built with /clr:initialAppDomain contains a reference to the _check_commonlanguageruntime_version function, which is defined in the C Runtime Library (CRT). This function provides for an error message if your application is run on version 1 of the runtime. Code generated by the current compiler is not compatible with version 1 of the common language runtime. So, if you compile without the CRT in Visual C++ .NET 2003, you should include a definition of the _check_commonlanguageruntime_version function in your code. As an alternative to using the _check_commonlanguageruntime_version function, you can link with nochkclr.obj, which contains an empty version of the function and does not provide for an error message if you run your application on version 1 of the runtime. To build an application with the current compiler version to run on the previous version of the runtime, use /clr:InitialAppDomain.

To build a pure MSIL executable (does not link with the CRT), you must define the function in your project; you cannot use nochkclr.obj (the .obj is native code). See Producing Verifiable Components with Managed Extensions for C++ for more information about verifiable code. For more information on creating a pure MSIL output file from your Managed C++ project, see Converting Managed Extensions for C++ Projects from Mixed-Mode to Pure IL.

The rest of this topic discusses other causes of LNK2019.

Consider the following sample:

extern int i;
extern void g();
void f()
{
i++;
g();
}
int main()
{
}
If i and g are not defined in one of the files included in the build, the linker will generate LNK2019. These definitions can be added by including the source code file that contains the definitions as part of the compilation. Alternatively, you can pass .obj or .lib files that contain the definitions to the linker.

For C++ projects from previous releases that were upgraded to the current version, if __UNICODE was defined and the entry point was WinMain, you need to change the name of the entry point function to either _tWinMain or _tmain.

Common problems that cause LNK2019 include:

The declaration of the symbol contains a spelling mistake, such that, it is not the same name as the definition of the symbol.
A function was used but the type or number of the parameters did not match the function definition.
The calling convention (__cdecl, __stdcall, or __fastcall) differs on the use of the function declaration and the function definition.
Symbol definitions are in a file that was compiled as a C program and symbols are declared in a C++ file without an extern "C" modifier. In that case, modify the declaration, for example, instead of:
extern int i;
extern void g();
use:

extern "C" int i;
extern "C" void g();
Similarly, if you define a symbol in a C++ file that will be used by a C program, use extern "C" in the definition.

A symbol is defined as static and then later referenced outside the file.
A static member of a class is not defined. For example, member variable si in the class declaration below should be defined separately:
#include <stdio.h>
struct X {
static int si;
};

// int X::si = 0; // uncomment this line to resolve

void main()
{
X *px = new X[2];
printf("\n%d",px[0].si); // LNK2019
}
This error can also be generated as a result of conformance work that was done for Visual Studio .NET 2003: template friends and specialization. In Visual Studio .NET 2003, a friend declaration that declares a new non-template function must be defined.

For code that is valid in both the Visual Studio .NET 2003 and Visual Studio .NET versions of Visual C++, explicitly specify the friend function's template argument list.

// LNK2019.cpp
// LNK2019 expected
template<class T>
void f(T)
{
}

template<class T>
struct S
{
friend void f(T);
// Try the folowing line instead:
// friend void f<T>(T);
};

int main()
{
S<int> s;
f(1); // unresolved external
}
The /VERBOSE linker option will help you see which files the linker is referencing. The /EXPORT and /SYMBOLS options of the DUMPBIN utility can also help you see which symbols are defined in your dll and object/library files.

Mislim da ti nedostaju neke definicije/deklaracije.
 
Odgovor na temu

gosha
Zemun

Član broj: 2384
Poruke: 589
..njuel-bg.customer.sbb.co.yu.



+40 Profil

icon Re: MFC pocetnik u Visual Studiu .NET26.12.2005. u 15:11 - pre 222 meseci
Ova greska se javlja kada u opcijama linkera nisi ukljucio potrebne biblioteke.

Ne znam MFC pa ti ne mogu vise pomoci.

Potrazi u MSDN-u kojoj biblioteci pripadaju ove funkcije.

Obicno kod tutorijala stoji napomena kako treba podesiti linker.

Pozdrav Goran.

PS. Zaboravih. U VS imas vizarde za kreiranje projekata. Ako se dobro secam kada pravis projekat vizard te pita da li koristis MFC.


JokeJunky :)

Mrzim sublimirane marketinske poruke.
 
Odgovor na temu

Dragi Tata
Malo ispod Kanade

Član broj: 1958
Poruke: 3906
*.dyn.optonline.net.



+6 Profil

icon Re: MFC pocetnik u Visual Studiu .NET26.12.2005. u 15:37 - pre 222 meseci
Savetujem ti da koristiš wizard makar da ti napravi projekat i linkuje sve šta treba. Posle možeš da dodaješ klase i ručno ako baš voliš, mada ne vidim zašto bi to radio.
 
Odgovor na temu

mrzli777
Hrvatska

Član broj: 50641
Poruke: 18
*.adsl.net.t-com.hr.



Profil

icon Re: MFC pocetnik u Visual Studiu .NET27.12.2005. u 20:55 - pre 222 meseci
Evo, program mi je uspio proraditi. U Project->Properties u General dijelu ima opcija 'Use of MFC'. Po defaultu je 'Use Standard Windows Libraries', a kad sam promjenio na 'Use MFC in a Shared DLL' proradio je. Sto je cudno, radi i kad sam nakon toga vratio na onu prvotnu postavku.

Inace, pojma nisam imao sto trazim, samo sam vidio da pise MFC u imenu opcije pa sam pokusavao mjenjati i proradilo je. Kasnije sam probao s wizardom pokrenut i vidio da je odmah postavljena na shared dll.




Citat:
gosha:
PS. Zaboravih. U VS imas vizarde za kreiranje projekata. Ako se dobro secam kada pravis projekat vizard te pita da li koristis MFC.


Kao sto sam u naslovu napomenuo, ja sam pocetnik s MFC-om, a iz prijasnjih iskustva znam da kad pocinjem nesto ucit wizarde je najbolje ostavit na miru, jer te vise zbune nego pomognu.




Citat:
Dragi Tata: Savetujem ti da koristiš wizard makar da ti napravi projekat i linkuje sve šta treba. Posle možeš da dodaješ klase i ručno ako baš voliš, mada ne vidim zašto bi to radio.


Dobar savjet, moram priznat da mi takva primjena wizarda nije pala na pamet. Ipak, kad sam vec naletio na onu opciju brze je i elegantnije onako podesiti projekt.

U svakom slucaju, zahvaljujem vam se na pomoci.
 
Odgovor na temu

[es] :: C/C++ programiranje :: C/C++ za početnike :: MFC pocetnik u Visual Studiu .NET

[ Pregleda: 3122 | Odgovora: 4 ] > FB > Twit

Postavi temu Odgovori

Navigacija
Lista poslednjih: 16, 32, 64, 128 poruka.