|
An alternative to Tomasz' suggestion is using <a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vcmfc98/html/_mfc_crecttracker.asp">CRectTracker</a> .
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
I am very close to losing my sanity trying to build some code with visual c++. I am sure the problem will have a very simple solution but i could do with some help none the less.
I have a program with six source code files and six associated header files, they all compile fine but when trying to link i get the following error.
test.obj : error LNK2001: unresolved external symbol "void __cdecl mht_associate(struct tracker_struct * *,struct measurements_struct * *,struct parameter_struct *,int,double * * *,int,int,int,int)" (?mht_associate@@YAXPAPAUtracker_struct@@PAPAUmeas
urements_struct@@PAUparameter_struct@@HPAPAPANHHHH@Z)
Debug/mht.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.
The funcion being called in a file test.c and is defined in a file mhtwrapper.h, the code is contained in mhtwrapper.c.I have checked for all the simple mistakes that i can think of, such a spelling errors and i have tried declaring the function as external with no joy. When i run dumpbin on the mhtwrapper.obj file the function symbol does seem to be defined.
Symbol index: 10 Base line number: 14
Symbol name = _mht_associate
0000001B( 15) 00000022( 16) 00000029( 17) 00000030( 20)
00000037( 22) 0000003E( 23) 00000058( 25) 00000072( 27)
00000091( 28) 00000093( 29) 00000095( 30) 000000A6( 32)
000000B5( 34) 000000C4( 35) 000000D5( 37) 000000E8( 38)
000000FB( 39) 0000010E( 41) 0000012A( 43) 00000146( 45)
00000175( 46) 000001A4( 47) 000001D3( 48) 000001D8( 49)
000001DD( 50) 000001ED( 51) 000001FF( 52) 00000211( 53)
0000021D( 54) 00000229( 55) 00000235( 58) 0000023C( 59)
0000025A( 61) 00000278( 63) 00000297( 64) 000002CB( 67)
000002DB( 69) 000002F3( 70) 0000030D( 73) 00000316( 74)
00000326( 76) 00000342( 78) 00000387( 79) 0000039F( 81)
000003EE( 82) 000003F0( 83) 000003F5( 84) 000003FA( 85)
000003FF( 86) 00000404( 87) 0000041B( 89) 00000445( 91)
0000044E( 92) 0000046C( 94) 0000047C( 95) 00000498( 98)
000004D8( 101) 00000518( 103) 00000534( 106) 0000057F( 109)
000005CA( 110) 000005CF( 111) 000005D4( 113) 000005FB( 114)
00000624( 115) 00000639( 118) 0000063E( 120) 0000064A( 123)
and
010 00000000 SECT3 notype () External | _mht_associate
tag index 0000001A size 0000066E lines 00000DA8 next function 00000000
Any advice would be gratly appriciated.
Thanks
Scott Sims
|
|
|
|
|
Well, I had a similar problem the other day when compiling some c code with the settings (calling convention) set for __cdecl when it should have been __stdcall...
(Don't laugh folks - someday one of these pitifully lame suggestions will actually help someone, and _then_ I'll be cool... )
|
|
|
|
|
Thanks but i have allready tried and it has no effect
Scott Sims
|
|
|
|
|
Excuse my insistence, but that name mangling thing caught my eye... is your test program file actually called test.c and not test.cpp ? The compiler seems to be producing C++ code, not C. Also, the mhtwrapper.obj dump suggests that mht_associate is being compiled with extern "C" (not to be confounded with __cdecl ) name decoration.
If this is all obvious to you please feel free to ignore my post --but I thought it might be worth pointing out, just in case.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
I think you might be on the right track but i am a little lost, the test file was called test.cpp and not test.c which i have now changed. The change in file type seems to make no ovious difference, i still get the same error. But when i try to add the extern "C" to the decloraction of the unresolved function i get the following error,
extern "C" void mht_associate(struct s1 **a,
struct s2 **b,
struct s3 *c,
int d,
double ***e,
int f,
int g,
int h,
int i);
g:\work\qunetiq mht\mhtwrapper.h(11) : error C2059: syntax error : 'string'
Thanks
Scott
|
|
|
|
|
OK... So you have to anwer yourself a question: Do you want the wrapper thing to work in C++ or in C? If it's the former, change everything to .cpp , forget about extern "C" , and everything should be right. If it's the latter, then you might be in trouble, cause that string seems to be C++ std::string , which of course cannot be included in a C program. Anyway, this is like walking in the dark a little code would go a long way.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
I assume from what you are saying is that some code appears to be compiling as C++ and other code as C(I need platform independent pure C code) and the linker is struggling with this. So is there a compiler switch to force the compiler into pure C. Im sorry about the lack of code but unfortunatly that is unavoidable.
Thanks for your time
Scott
|
|
|
|
|
OK, pure C. Then, rename everything to .c , drop every extern "C" out and do a fresh rebuild (Project -> Rebuild All.) What's the result now?
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Doing as you said had no effect but by adding \Tc to the compiler options forces pure C and i now have got the program running, thank you very much for your help it is greatly appriciated.
Scott
|
|
|
|
|
Well, you are welcome. Anyway, please note that you don't have to do anything special in VC++ to have .c files compiled as C. It is as if someone altered your VC++ settings to get the compiler to evilly treat .c files as C++.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
...but we think you're cool anyway Tim. Don't we guys.
guys?
cheers,
Chris Maunder
|
|
|
|
|
Sure... rub it in why doncha...
|
|
|
|
|
(Wild guess) Traces suggest C++ name mangling is in effect. Could it be you have to fix some extern "C" declarations somewhere?
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
I have tried allready this with no effect, thanks anyway.
Scott Sims
|
|
|
|
|
You don't say if you're using MFC or WTL. If WTL, the LNK2001 error is caused when you try to do a Release build of a program that requires MSVCRT. Remove the compiler directive _ATL_MIN_CRT or remove the function call that requires the C RunTime library (malloc, printf, etc.).
|
|
|
|
|
I am using neither, it is just a C console application and im using a debug build, i also need to use the stadard C librays throughout the program.
Thanks Anyway
Scott Sims
|
|
|
|
|
Have you left the default setting of precompiled headers in the compile options? If so, turn it off and delete everything in your debug folder before rebuilding.
|
|
|
|
|
Have you look at this link at all?
http://support.microsoft.com/default.aspx?scid=kb;EN-US;q148652
does it help?
|
|
|
|
|
I am using the follwing code to get the current system time and put it in HH:MM:SS format.
CTime launch_event_time = CTime::GetCurrentTime();
// decompose the current time into hours minutes and seconds
hours = launch_event_time.GetHour();
minutes = launch_event_time.GetMinute();
seconds = launch_event_time.GetSecond();
// format the time for display in both the track report
// and geolocation tables and store in a global variable
sprintf(launch_event_time_txt, "%02d:%02d:%02d",
hours, minutes, seconds);
What I also need is tenths of seconds. Can anyone lend a hand with this?
|
|
|
|
|
If I remember correctly, CTime is based on C's time_t type which doesn't support tenths of seconds. Which is just one of the many problems with time_t.
Try using SYSTEMTIME or FILETIME.
Tim Smith
I know what you're thinking punk, you're thinking did he spell check this document? Well, to tell you the truth I kinda forgot myself in all this excitement. But being this here's CodeProject, the most powerful forums in the world and would blow your head clean off, you've got to ask yourself one question, Do I feel lucky? Well do ya punk?
|
|
|
|
|
Use getSystemTime() instead and use the wMilliseconds field of the SYSTEMTIME struct to get tenths of a second.
/ravi
"There is always one more bug..."
http://www.ravib.com
ravib@ravib.com
|
|
|
|
|
I have a lot of problem (especially on windows 2000) to set focus input to the window I want in a multithread context (several threads manage windows)
I have found this remark in an MSDN article concerning SetForegroundWindow function :
Windows NT 5.0 and later: An application cannot force a window to the foreground while the user is working with another window. Instead, SetForegroundWindow will activate the window (see SetActiveWindow) and call theFlashWindowEx function to notify the user.
Is somebody can explain me what "while the user is working with another window" means exactly or where I can find it
|
|
|
|
|
This is a new GUI feature aimed at relieving the user from those apps that unsolicitedly put themselves on the foreground making the user lose the focus (which is annoying if one is for instance typing some text.) SetForegroundWindow will just show the associated taskbar button flashing to indicate the app requested attention.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Tanks for your response,
Do you know microsoft articles which deal with this purpose.
What you say is quite logical, but it seems to apply to multiapplication management but I have the sam effect in a single application. That is to say I try to give focus to a special window of my application but in another thread but I don't succed in changing focus and the taskbar is flashing
Gwenaël Dourmap
|
|
|
|