Re: Adding Win 32 to a MFC program

Tech-Archive recommends: Fix windows errors by optimizing your registry



On May 19, 4:48 pm, Joseph M. Newcomer <newco...@xxxxxxxxxxxx> wrote:
See below...



On Mon, 19 May 2008 04:54:13 -0700 (PDT), Peter <pvreq...@xxxxxxxxx> wrote:
Hi,

Sorry if I didn’t give more details about my problem,

The win32 application I have taken from Derek from
http://forums.mysql.com/read.php?45,49606,49606
(I did modify it to make it do other function but it remind basically
the same, so better let refer to this Win32 application to read a
MySQL data base) my other program is one that can read the serial port
using a DLL and some include-file.h this application works fine now I
want to be able to use the win32 into my MFC application but it give
me this error

mysqlclient.lib(client.obj) : error LNK2001: unresolved external
symbol _connect@12

****
THis looks like the api for the WinSock 'connect' call
****>mysqlclient.lib(client.obj) : error LNK2001: unresolved external
symbol _WSAGetLastError@0

****
WinSock
***>mysqlclient.lib(viosocket.obj) : error LNK2001: unresolved external
symbol _WSAGetLastError@0
mysqlclient.lib(my_gethostbyname.obj) : error LNK2001: unresolved
external symbol _WSAGetLastError@0
mysqlclient.lib(client.obj) : error LNK2001: unresolved external
symbol _htons@4

***
WinSock
***

mysqlclient.lib(client.obj) : error LNK2001: unresolved external
symbol _inet_addr@4
mysqlclient.lib(client.obj) : error LNK2001: unresolved external
symbol _socket@12
mysqlclient.lib(libmysql.obj) : error LNK2001: unresolved external
symbol _ntohs@4
mysqlclient.lib(viosocket.obj) : error LNK2001: unresolved external
symbol _ntohs@4
mysqlclient.lib(libmysql.obj) : error LNK2001: unresolved external
symbol _getservbyname@8
mysqlclient.lib(vio.obj) : error LNK2001: unresolved external symbol
_ioctlsocket@12
mysqlclient.lib(viosocket.obj) : error LNK2001: unresolved external
symbol _ioctlsocket@12
mysqlclient.lib(viosocket.obj) : error LNK2001: unresolved external
symbol _recv@16
mysqlclient.lib(viosocket.obj) : error LNK2001: unresolved external
symbol _send@16
mysqlclient.lib(viosocket.obj) : error LNK2001: unresolved external
symbol _setsockopt@20
mysqlclient.lib(viosocket.obj) : error LNK2001: unresolved external
symbol _closesocket@4
mysqlclient.lib(viosocket.obj) : error LNK2001: unresolved external
symbol _shutdown@8
mysqlclient.lib(viosocket.obj) : error LNK2001: unresolved external
symbol _getpeername@12
mysqlclient.lib(my_gethostbyname.obj) : error LNK2001: unresolved
external symbol _gethostbyname@4
mysqlclient.lib(my_init.obj) : error LNK2001: unresolved external
symbol _WSACleanup@0
mysqlclient.lib(my_init.obj) : error LNK2001: unresolved external
symbol _WSAStartup@8
mysqlclient.lib(my_net.obj) : error LNK2001: unresolved external
symbol _inet_ntoa@4
mysqlclient.lib(mf_pack.obj) : error LNK2001: unresolved external

****
These are all WinSock calls

Now here's what you do: RTFM. Look up one of these functions in the MSDN, like 'connect'.
What does the documentation of 'connect' tell you about it? For example, look at the end
of the documentation for 'connect':

Requirements:
Client:...
Server: ...
Header: ...
Library: Use Ws2_32.lib

Did you use WS2_32.lib? If you are getting link errors, you obviously did NOT include
WS2_32.lib in the linker specifications, so you are getting the correct errors. Operator
error.

You are confused: it has NOTHING to do with "using Win32" and EVERYTHING to do with "I
didn't look up the function to see if I included the library in my linker input
specifications", which is easily deduced simply by reading the documentation.
****>symbol __pctype
mysqlclient.lib(mf_pack.obj) : error LNK2001: unresolved external
symbol ___mb_cur_max

****
I do not know what these are, but until you have fixed the above errors, it is hard to
tell if these are the result of another module you forgot to link in, or are part of
WInSock. They are not documented interfaces, which leads me to suspect they are functions
in some OTHER library that you did not include, possibly a library expected by that other
"program" (you don't include "programs", by the way, since "programs" start with main or
WinMain, and you can't include one in another; what you included was "libraries"). I
would suggest then trying to find out what these functions are because they are not part
of the documented Win32 API; consequently, again, your program is not with the "Win32 API"
but a failure to include libraries that are expected and used by the other "program".
joe
****

Release/TetraDiag.exe : fatal error LNK1120: 20 unresolved externals
Error executing link.exe.

TetraDiag.exe - 25 error(s), 0 warning(s)

I am not sure what is going on to be honest, I have try to combine the
win32 into my MFC but I must be missing something.
Thanks for any help
Peter

On May 19, 5:51 am, Joseph M. Newcomer <newco...@xxxxxxxxxxxx> wrote:
What do you mean "add thewin32"? What do you mean "programs"? What in the world are you
talking about?

What is a "hell of error"? Compile time errors? Link time errors? Run time errors?
Assert failures? Access faults?

Come on, you really need to give us some useful information about what you are talking
about here!

Do you have .c files involved? Or just .cpp? What aspects of "Win32" are you talking
about (theWin32API is always available inMFC). Are you using a DLL?

I've got a similar problem. I'm having trouble getting my program working. Please tell
me what I'm doing wrong.

[that's all you've said, by the way!]
joe

On Sun, 18 May 2008 18:41:12 -0700 (PDT), Peter <pvreq...@xxxxxxxxx> wrote:
Hi,

I need some help fusion a Win 32 program with aMFCprogram.

I have done/modified a read seal portMFCprogram and Win 32 save in
MySQL database.

But it give me a hell of error went I am trying to add the win 32 to
myMFC.

Could you please give me some help/guide of what/where do I need to
know to fusion these two programs.

Regards,

Peter

Joseph M. Newcomer [MVP]
email: newco...@xxxxxxxxxxxx
Web:http://www.flounder.com
MVP Tips:http://www.flounder.com/mvp_tips.htm

Joseph M. Newcomer [MVP]
email: newco...@xxxxxxxxxxxx
Web:http://www.flounder.com
MVP Tips:http://www.flounder.com/mvp_tips.htm

Hi Joe,

You were quick right I forgot to add the winsock library, it was not
the one you said, but it was wsock32.lib, it was a silly mistake to
miss that out.

By way I should clarify when I said Win32 I am referring a Windows 32
console application (the one that handle the MySQL)

Could you please look this code again because what I have done now is
make a new fresh MFC from the wizaerd (MFC exe)
and add the libraries, and the only different from (http://
forums.mysql.com/read.php?45,49606,49606) I have changed
[ Category: Code Generation ]
Use run-time library:
Multithreaded

to Multithreaded DLL (because if not give a MD switch error)

the error now is

Compiling resources...
Compiling...
StdAfx.cpp
Compiling...
WritingMySQL.cpp
MainFrm.cpp
ChildFrm.cpp
WritingMySQLDoc.cpp
WritingMySQLView.cpp
Generating Code...
Linking...
mysqlclient.lib(mf_pack.obj) : LNK2001:
mysqlclient.lib(mf_pack.obj) : LNK2001:
Debug/WritingMySQL.exe : LNK1120:
Error executing link.exe.

WritingMySQL.exe - 1 error(s), 0 warning(s)

Any Ideas?,

Thanks in advance for you help
.



Relevant Pages

  • Re: Adding Win 32 to a MFC program
    ... The win32 application I have taken from Derek from ... What does the documentation of 'connect' tell you about it? ... but a failure to include libraries that are expected and used by the other "program". ... MVP Tips:http://www.flounder.com/mvp_tips.htm ...
    (microsoft.public.vc.mfc)
  • Re: Adding Win 32 to a MFC program
    ... You were quick right I forgot to add the winsock library, ... By way I should clarify when I said Win32 I am referring a Windows 32 ... What does the documentation of 'connect' tell you about it? ... but a failure to include libraries that are expected and used by the other "program". ...
    (microsoft.public.vc.mfc)
  • Re: Best Lisp/Scheme for Windows development?
    ... Decent GUI and graphics libraries or easy access to them. ... As much as I would like to stay in the "pure" Common Lisp environment ... fantastic but not for Win32). ... PLT is brilliant for development environment, community, docs, ...
    (comp.lang.lisp)
  • Re: C runtime library for Win32
    ... I now wish to port it to Win32, so that I can create executables ... to run under Windows 98 command prompt where every byte ... If I just use gcc normally it will automatically ... link in GNU libraries. ...
    (comp.lang.c)
  • Re: About speed
    ... But I mean - new platform must simplify ... available to .NET applications (and keep in mind coming libraries, ... writing a critical piece of architecture or a library that will be under ... .NET show BIG difference in architecture from Win32 so my ...
    (borland.public.delphi.non-technical)