CFileDialog and linker errors

Started by
7 comments, last by Damocles 21 years, 9 months ago
Okay, while trying to make a simple editor to create a map file for my simple game, I tried to use CFileDialog to create a file open dialog. I followed a little tutorial on it, and while the code seems fine, and the appropriate header is included, I get these linker errors: nafxcwd.lib(thrdcore.obj) : error LNK2001: unresolved external symbol __endthreadex nafxcwd.lib(thrdcore.obj) : error LNK2001: unresolved external symbol __beginthreadex At a guess I''d say my code is missing threading ability, so how do I sort this problem out? PS - goddam I hate windows programming.
------------------------------------------[New Delta Games] | [Sliders]
Advertisement
In your project C/C++ Code Generation settings. There change the run-time library to the multithreaded variants.

Helpful links:
How To Ask Questions The Smart Way | Google can help with your question | Search MSDN for help with standard C or Windows functions
Well, I''m running multithreaded now, danke. However, at the moment in the code it tries to instantiate the CFileDialog object, it hits an assertion failed error Here''s the line in question:

CFileDialog fileDlg( TRUE, NULL, NULL, OFN_HIDEREADONLY,
"Map Files (*.*)|*.map||", NULL);


I''m pretty sure that''s ok, but maybe I''m missing something?
------------------------------------------[New Delta Games] | [Sliders]
Anybody?
------------------------------------------[New Delta Games] | [Sliders]
What is the assert expression?

Helpful links:
How To Ask Questions The Smart Way | Google can help with your question | Search MSDN for help with standard C or Windows functions
The program comes up with the error box saying:

Debug Assertion Failed!

Program yadda yadda
File:afxwin1.inl
Line: 22

Abort, Retry Ignore

and the only thing that seems relevant in the debug window is:

The thread 0x2D0 has exited with code 0 (0x0).
The thread 0x5D8 has exited with code -2147483645 (0x80000003).
The program ''D:\SHOOTER\mapper\Debug\mapper.exe'' has exited with code -2147483645 (0x80000003).

If I hit ignore, the file dialog will open, but if I select a file and click open, the progam stops responding
------------------------------------------[New Delta Games] | [Sliders]
you didn't say what the assert expression was. hit retry and you'll be put on afxwin1.inl, the expression inside assert is the 'assert expression'. you can post the contents of the expression and a couple of lines above and below it for reference.


if your mfc sources are the same as mine, and the problem is what i think it is, which is you aren't using an mfc app template but are using just CFileDialog, add this line in WinMain:

AfxSetResourceHandle(hInstance);

somewhere in the beginning.


and take some time to understand the errors you're getting. did you, for example, opened msdn to find information on assert failed dialog box?


you should be using multithreaded dll crt library if you're using mfc in a dll, keep that in mind. i'm not sure what requirements are for static linking with mfc, as i've never used it that way.


quote:Original post by Damocles
PS - goddam I hate windows programming.

maybe you should visit your local MSDN and start paying attention to the docs instead of, or at least in addition to, cluelessly copying/pasting the code.

---
Come to #directxdev IRC channel on AfterNET

[edited by - niyaw on July 18, 2002 6:32:08 PM]
Thanks, that sorted it (the AfxSetResourceHandle(hInstance); line). I couldn''t find what the assert was because when I clicked retry, it hung. All I could do was end the task, and VC++ wouldn''t change.

All I could find on MSDN was what an assertion failure was, no common errors or anything (at least not that I could find, trying to decipher the heirarchy of MSDN is something best left to NASA).

As this is the first time I''ve ever had an assertion error, I wasn''t familiar with the debugging of them
------------------------------------------[New Delta Games] | [Sliders]
Often when you click Retry to Debug a failed assertion you''ll be placed in assert.c. You can backtrack up the call stack to see which function of yours is causing the problem.

Helpful links:
How To Ask Questions The Smart Way | Google can help with your question | Search MSDN for help with standard C or Windows functions

This topic is closed to new replies.

Advertisement