Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Staticly linking MFC in VS2008 app produces compiling errors

Staticly linking MFC in VS2008 app produces compiling errors

Scheduled Pinned Locked Moved C / C++ / MFC
helpc++
9 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    josip cagalj
    wrote on last edited by
    #1

    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___getpid

    if 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!

    CPalliniC K A 3 Replies Last reply
    0
    • J josip cagalj

      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___getpid

      if 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!

      CPalliniC Offline
      CPalliniC Offline
      CPallini
      wrote on last edited by
      #2

      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]

      In testa che avete, signor di Ceprano?

      J 1 Reply Last reply
      0
      • CPalliniC CPallini

        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]

        J Offline
        J Offline
        josip cagalj
        wrote on last edited by
        #3

        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!

        CPalliniC 1 Reply Last reply
        0
        • J josip cagalj

          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!

          CPalliniC Offline
          CPalliniC Offline
          CPallini
          wrote on last edited by
          #4

          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]

          In testa che avete, signor di Ceprano?

          J 1 Reply Last reply
          0
          • CPalliniC CPallini

            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]

            J Offline
            J Offline
            josip cagalj
            wrote on last edited by
            #5

            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

            1 Reply Last reply
            0
            • J josip cagalj

              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___getpid

              if 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!

              K Offline
              K Offline
              KarstenK
              wrote on last edited by
              #6

              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

              J 1 Reply Last reply
              0
              • K KarstenK

                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

                J Offline
                J Offline
                josip cagalj
                wrote on last edited by
                #7

                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

                1 Reply Last reply
                0
                • J josip cagalj

                  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___getpid

                  if 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!

                  A Offline
                  A Offline
                  Avi Berger
                  wrote on last edited by
                  #8

                  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.

                  J 1 Reply Last reply
                  0
                  • A Avi Berger

                    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.

                    J Offline
                    J Offline
                    josip cagalj
                    wrote on last edited by
                    #9

                    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).

                    1 Reply Last reply
                    0
                    Reply
                    • Reply as topic
                    Log in to reply
                    • Oldest to Newest
                    • Newest to Oldest
                    • Most Votes


                    • Login

                    • Don't have an account? Register

                    • Login or register to search.
                    • First post
                      Last post
                    0
                    • Categories
                    • Recent
                    • Tags
                    • Popular
                    • World
                    • Users
                    • Groups