Staticly linking MFC in VS2008 app produces compiling errors
-
Hi, I made an app in MFC VS2008 which works ok, but there are some PC's where my app just wont work (you allready know this story right..) so I decide it would be for the best to staticly link MFC. This produced some errors while compiling:
1>mysys.lib(my_messnc.obj) : error LNK2001: unresolved external symbol __imp____p__iob
1>libmysql.lib(dbug.obj) : error LNK2019: unresolved external symbol __imp____p__iob referenced in function __db_push_
1>libmysql.lib(net.obj) : error LNK2001: unresolved external symbol __imp____p__iob
1>mysys.lib(safemalloc.obj) : error LNK2001: unresolved external symbol __imp____p__iob
1>mysys.lib(my_init.obj) : error LNK2001: unresolved external symbol __imp____p__iob
1>libmysql.lib(dbug.obj) : error LNK2019: unresolved external symbol __imp__fprintf referenced in function __db_enter_
1>libmysql.lib(net.obj) : error LNK2001: unresolved external symbol __imp__fprintf
1>mysys.lib(safemalloc.obj) : error LNK2001: unresolved external symbol __imp__fprintf
1>mysys.lib(my_init.obj) : error LNK2001: unresolved external symbol __imp__fprintf
1>libmysql.lib(dbug.obj) : error LNK2019: unresolved external symbol __imp__vfprintf referenced in function __db_doprnt_
1>libmysql.lib(dbug.obj) : error LNK2019: unresolved external symbol __imp__getpid referenced in function _DoPrefix
1>OLDNAMES.lib(getpid.obi) : error LNK2001: unresolved external symbol __imp__getpid
1>libmysql.lib(dbug.obj) : error LNK2019: unresolved external symbol __imp__perror referenced in function _DBUGOpenFile
1>libmysql.lib(dbug.obj) : error LNK2019: unresolved external symbol __imp__freopen referenced in function _dbug_flush
1>mysys.lib(my_error.obj) : error LNK2019: unresolved external symbol __imp____p__pctype referenced in function _my_error
1>mysys.lib(my_error.obj) : error LNK2019: unresolved external symbol __imp____p___mb_cur_max referenced in function _my_error
1>strings.lib(Int2str.obj) : error LNK2019: unresolved external symbol __imp__ldiv referenced in function _int2str
1>OLDNAMES.lib(getpid.obi) : error LNK2001: unresolved external symbol __imp___getpidif anyone can Help please do so. I've been googling and still couldn't find the right way. Thanks in advance, and sorry for my bad language!
-
Hi, I made an app in MFC VS2008 which works ok, but there are some PC's where my app just wont work (you allready know this story right..) so I decide it would be for the best to staticly link MFC. This produced some errors while compiling:
1>mysys.lib(my_messnc.obj) : error LNK2001: unresolved external symbol __imp____p__iob
1>libmysql.lib(dbug.obj) : error LNK2019: unresolved external symbol __imp____p__iob referenced in function __db_push_
1>libmysql.lib(net.obj) : error LNK2001: unresolved external symbol __imp____p__iob
1>mysys.lib(safemalloc.obj) : error LNK2001: unresolved external symbol __imp____p__iob
1>mysys.lib(my_init.obj) : error LNK2001: unresolved external symbol __imp____p__iob
1>libmysql.lib(dbug.obj) : error LNK2019: unresolved external symbol __imp__fprintf referenced in function __db_enter_
1>libmysql.lib(net.obj) : error LNK2001: unresolved external symbol __imp__fprintf
1>mysys.lib(safemalloc.obj) : error LNK2001: unresolved external symbol __imp__fprintf
1>mysys.lib(my_init.obj) : error LNK2001: unresolved external symbol __imp__fprintf
1>libmysql.lib(dbug.obj) : error LNK2019: unresolved external symbol __imp__vfprintf referenced in function __db_doprnt_
1>libmysql.lib(dbug.obj) : error LNK2019: unresolved external symbol __imp__getpid referenced in function _DoPrefix
1>OLDNAMES.lib(getpid.obi) : error LNK2001: unresolved external symbol __imp__getpid
1>libmysql.lib(dbug.obj) : error LNK2019: unresolved external symbol __imp__perror referenced in function _DBUGOpenFile
1>libmysql.lib(dbug.obj) : error LNK2019: unresolved external symbol __imp__freopen referenced in function _dbug_flush
1>mysys.lib(my_error.obj) : error LNK2019: unresolved external symbol __imp____p__pctype referenced in function _my_error
1>mysys.lib(my_error.obj) : error LNK2019: unresolved external symbol __imp____p___mb_cur_max referenced in function _my_error
1>strings.lib(Int2str.obj) : error LNK2019: unresolved external symbol __imp__ldiv referenced in function _int2str
1>OLDNAMES.lib(getpid.obi) : error LNK2001: unresolved external symbol __imp___getpidif anyone can Help please do so. I've been googling and still couldn't find the right way. Thanks in advance, and sorry for my bad language!
I guess the libraries you're using link dynamically with the runtime. Why don't you deploy the required DLL's instead of linking the project statically? :)
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
[My articles] -
I guess the libraries you're using link dynamically with the runtime. Why don't you deploy the required DLL's instead of linking the project statically? :)
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
[My articles]First let me thank you for replaying. I have following requirements I need to keep. I need to distribute my exe to multiple machines with no knowledge about OS installed. I've tried on several local computers and where app didn't work I've get different error messages. So by static linking MFC I hope I'll be able to get it to work!
-
First let me thank you for replaying. I have following requirements I need to keep. I need to distribute my exe to multiple machines with no knowledge about OS installed. I've tried on several local computers and where app didn't work I've get different error messages. So by static linking MFC I hope I'll be able to get it to work!
However, if my previous guess was correct, you have to either get new (statically linked with the runtime) binaries of the libraries you use or compile yourself such libraries. :)
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
[My articles] -
However, if my previous guess was correct, you have to either get new (statically linked with the runtime) binaries of the libraries you use or compile yourself such libraries. :)
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
[My articles]My app works with mysql db and only lib's I'm linking are: libmysql.lib, mysys.lib and strings.lib. And trough my code I have
#pragma comment(lib, "Netapi32.lib")
#pragma comment(lib, "mpr.lib")
#pragma comment(lib, "shlwapi.lib")This is an simple sdi app created with vs2008. Sure I have some CMFC controls (like toolbars and so) which are from feature pack. I didn't try to install re-distributable file on target machines.
modified on Tuesday, March 23, 2010 8:28 AM
added additional libs from my code
-
Hi, I made an app in MFC VS2008 which works ok, but there are some PC's where my app just wont work (you allready know this story right..) so I decide it would be for the best to staticly link MFC. This produced some errors while compiling:
1>mysys.lib(my_messnc.obj) : error LNK2001: unresolved external symbol __imp____p__iob
1>libmysql.lib(dbug.obj) : error LNK2019: unresolved external symbol __imp____p__iob referenced in function __db_push_
1>libmysql.lib(net.obj) : error LNK2001: unresolved external symbol __imp____p__iob
1>mysys.lib(safemalloc.obj) : error LNK2001: unresolved external symbol __imp____p__iob
1>mysys.lib(my_init.obj) : error LNK2001: unresolved external symbol __imp____p__iob
1>libmysql.lib(dbug.obj) : error LNK2019: unresolved external symbol __imp__fprintf referenced in function __db_enter_
1>libmysql.lib(net.obj) : error LNK2001: unresolved external symbol __imp__fprintf
1>mysys.lib(safemalloc.obj) : error LNK2001: unresolved external symbol __imp__fprintf
1>mysys.lib(my_init.obj) : error LNK2001: unresolved external symbol __imp__fprintf
1>libmysql.lib(dbug.obj) : error LNK2019: unresolved external symbol __imp__vfprintf referenced in function __db_doprnt_
1>libmysql.lib(dbug.obj) : error LNK2019: unresolved external symbol __imp__getpid referenced in function _DoPrefix
1>OLDNAMES.lib(getpid.obi) : error LNK2001: unresolved external symbol __imp__getpid
1>libmysql.lib(dbug.obj) : error LNK2019: unresolved external symbol __imp__perror referenced in function _DBUGOpenFile
1>libmysql.lib(dbug.obj) : error LNK2019: unresolved external symbol __imp__freopen referenced in function _dbug_flush
1>mysys.lib(my_error.obj) : error LNK2019: unresolved external symbol __imp____p__pctype referenced in function _my_error
1>mysys.lib(my_error.obj) : error LNK2019: unresolved external symbol __imp____p___mb_cur_max referenced in function _my_error
1>strings.lib(Int2str.obj) : error LNK2019: unresolved external symbol __imp__ldiv referenced in function _int2str
1>OLDNAMES.lib(getpid.obi) : error LNK2001: unresolved external symbol __imp___getpidif anyone can Help please do so. I've been googling and still couldn't find the right way. Thanks in advance, and sorry for my bad language!
to link staticly is one solution. For that you need the static libs of mysys.lib etc. :thumbsup: or you build a setup which will include the dlls which you will need. Test it on virtual machines. :cool:
Press F1 for help or google it. Greetings from Germany
-
to link staticly is one solution. For that you need the static libs of mysys.lib etc. :thumbsup: or you build a setup which will include the dlls which you will need. Test it on virtual machines. :cool:
Press F1 for help or google it. Greetings from Germany
With Release version errors are:
1>FileVersion.obj : error LNK2001: unresolved external symbol __pgmptr
1>nafxcw.lib(appcore.obj) : error LNK2001: unresolved external symbol ___argv
1>nafxcw.lib(appcore.obj) : error LNK2001: unresolved external symbol ___argc -
Hi, I made an app in MFC VS2008 which works ok, but there are some PC's where my app just wont work (you allready know this story right..) so I decide it would be for the best to staticly link MFC. This produced some errors while compiling:
1>mysys.lib(my_messnc.obj) : error LNK2001: unresolved external symbol __imp____p__iob
1>libmysql.lib(dbug.obj) : error LNK2019: unresolved external symbol __imp____p__iob referenced in function __db_push_
1>libmysql.lib(net.obj) : error LNK2001: unresolved external symbol __imp____p__iob
1>mysys.lib(safemalloc.obj) : error LNK2001: unresolved external symbol __imp____p__iob
1>mysys.lib(my_init.obj) : error LNK2001: unresolved external symbol __imp____p__iob
1>libmysql.lib(dbug.obj) : error LNK2019: unresolved external symbol __imp__fprintf referenced in function __db_enter_
1>libmysql.lib(net.obj) : error LNK2001: unresolved external symbol __imp__fprintf
1>mysys.lib(safemalloc.obj) : error LNK2001: unresolved external symbol __imp__fprintf
1>mysys.lib(my_init.obj) : error LNK2001: unresolved external symbol __imp__fprintf
1>libmysql.lib(dbug.obj) : error LNK2019: unresolved external symbol __imp__vfprintf referenced in function __db_doprnt_
1>libmysql.lib(dbug.obj) : error LNK2019: unresolved external symbol __imp__getpid referenced in function _DoPrefix
1>OLDNAMES.lib(getpid.obi) : error LNK2001: unresolved external symbol __imp__getpid
1>libmysql.lib(dbug.obj) : error LNK2019: unresolved external symbol __imp__perror referenced in function _DBUGOpenFile
1>libmysql.lib(dbug.obj) : error LNK2019: unresolved external symbol __imp__freopen referenced in function _dbug_flush
1>mysys.lib(my_error.obj) : error LNK2019: unresolved external symbol __imp____p__pctype referenced in function _my_error
1>mysys.lib(my_error.obj) : error LNK2019: unresolved external symbol __imp____p___mb_cur_max referenced in function _my_error
1>strings.lib(Int2str.obj) : error LNK2019: unresolved external symbol __imp__ldiv referenced in function _int2str
1>OLDNAMES.lib(getpid.obi) : error LNK2001: unresolved external symbol __imp___getpidif anyone can Help please do so. I've been googling and still couldn't find the right way. Thanks in advance, and sorry for my bad language!
There are both MFC runtime libraries and the C++ runtime library. The linker error messages appear to relate to the runtime library, not MFC. They look to me like the libs referenced expect the runtime library to be dynamically linked. At least some of them appear to be specific to debugging, which would explain why your later post indicates that these errors go away in your release build. Note that there are problems if a DLL and and exe are linked to different versions of the runtime library and one tries to release dynamic memory allocated by the other.
josip cagalj wrote:
I didn't try to install re-distributable file on target machines.
Any dependencies of your program need to be included in your installation. The target machine may or may not have the appropriate versions of the MFC and runtime library dlls installed. This depends on the Windows version. It can also be impacted by service packs and other software installed on that machine.
josip cagalj wrote:
1>With Release version errors are: 1>FileVersion.obj : error LNK2001: unresolved external symbol __pgmptr 1>nafxcw.lib(appcore.obj) : error LNK2001: unresolved external symbol ___argv 1>nafxcw.lib(appcore.obj) : error LNK2001: unresolved external symbol ___argc
This sounds like an issue with the start-up code. Perhaps some sort of confusion between whether you are producing a console app or a GUI app?
Please do not read this signature.
-
There are both MFC runtime libraries and the C++ runtime library. The linker error messages appear to relate to the runtime library, not MFC. They look to me like the libs referenced expect the runtime library to be dynamically linked. At least some of them appear to be specific to debugging, which would explain why your later post indicates that these errors go away in your release build. Note that there are problems if a DLL and and exe are linked to different versions of the runtime library and one tries to release dynamic memory allocated by the other.
josip cagalj wrote:
I didn't try to install re-distributable file on target machines.
Any dependencies of your program need to be included in your installation. The target machine may or may not have the appropriate versions of the MFC and runtime library dlls installed. This depends on the Windows version. It can also be impacted by service packs and other software installed on that machine.
josip cagalj wrote:
1>With Release version errors are: 1>FileVersion.obj : error LNK2001: unresolved external symbol __pgmptr 1>nafxcw.lib(appcore.obj) : error LNK2001: unresolved external symbol ___argv 1>nafxcw.lib(appcore.obj) : error LNK2001: unresolved external symbol ___argc
This sounds like an issue with the start-up code. Perhaps some sort of confusion between whether you are producing a console app or a GUI app?
Please do not read this signature.
Thanks for contributing, my app is SDI MFC. One question just to make my self clear, when I use 'Project > Properties > Linker > Input > Additional Dependencies' entering libmysql.lib mysys.lib strings.lib is this dynamically linking or static. Same question for
#pragma comment(lib, "Netapi32.lib")
#pragma comment(lib, "mpr.lib")
#pragma comment(lib, "shlwapi.lib")entries. When compiled will exe contain those lib's or do I need to make sure that those lib's exist on target machine by building msi file? My gold is to have the exe which will contain all necessary stuff to work on win target machine (Win2000, XP, Vista, Win7).