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

Problem_With_MSVC6_Linker

Scheduled Pinned Locked Moved C / C++ / MFC
c++visual-studiocomhelpannouncement
10 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.
  • K Offline
    K Offline
    KEL3
    wrote on last edited by
    #1

    Hello, I have written a mathematical matrix class for VS C++ 6 and I would like to publish it in your site in the form of a library (*.lib). Maybe later I release the code too. However I am facing serious problems with my linker an I 'm not sure if I will ever manage to publish it (at least in a reasonable amount of time) without your help. So, I would like to ask you if you could help me a bit. I am willing to refer your name in my article. Although, it may take me some time to write it. As far as I have understood, it is the MFC (used by my class) that conflicts when I try to use my compiled *.lib file. I tried to change the settings of my linker (/NODEFAULTLIB) but I do not find the process familiar! I have uploaded the *.lib file and the header file so that you can test it on your own. It is at: http://rapidshare.com/files/41398859/LIB.zip[^] The process of compiling it into a LIB file seems to be OK. I will sum it up if you want: I added my header file and my cpp file into the project (Win32 Static Library) and I just built the lib files with no errors. Then I created a new MFC app (Dialog, MFC statically linked - I don't know if that matters), I added the header file and the lib files into the project, I added the #ifdef _DEBUG #pragma comment(lib, "mat_lib_DEBUG.lib") #else #pragma comment(lib, "mat_lib_RELEASE.lib") #endif in the code file using my class. But it just does't work. If you manage to compile a project while using an object please upload the project, so that I can see what I was doing wrong. If you wan't you may write sth here too. To use an object of the class write: CKelLib::CKelMatrix m,n(2,1); double p[4][4]={{1,2,3,4},{3,6,9.2,12.9},{7,14,21,27},{3,4,9,12.3}}; m.Initialize((double*)p,4,4); Any kind of help would be appreciated. Thank you.

    kostas KEL

    C 1 Reply Last reply
    0
    • K KEL3

      Hello, I have written a mathematical matrix class for VS C++ 6 and I would like to publish it in your site in the form of a library (*.lib). Maybe later I release the code too. However I am facing serious problems with my linker an I 'm not sure if I will ever manage to publish it (at least in a reasonable amount of time) without your help. So, I would like to ask you if you could help me a bit. I am willing to refer your name in my article. Although, it may take me some time to write it. As far as I have understood, it is the MFC (used by my class) that conflicts when I try to use my compiled *.lib file. I tried to change the settings of my linker (/NODEFAULTLIB) but I do not find the process familiar! I have uploaded the *.lib file and the header file so that you can test it on your own. It is at: http://rapidshare.com/files/41398859/LIB.zip[^] The process of compiling it into a LIB file seems to be OK. I will sum it up if you want: I added my header file and my cpp file into the project (Win32 Static Library) and I just built the lib files with no errors. Then I created a new MFC app (Dialog, MFC statically linked - I don't know if that matters), I added the header file and the lib files into the project, I added the #ifdef _DEBUG #pragma comment(lib, "mat_lib_DEBUG.lib") #else #pragma comment(lib, "mat_lib_RELEASE.lib") #endif in the code file using my class. But it just does't work. If you manage to compile a project while using an object please upload the project, so that I can see what I was doing wrong. If you wan't you may write sth here too. To use an object of the class write: CKelLib::CKelMatrix m,n(2,1); double p[4][4]={{1,2,3,4},{3,6,9.2,12.9},{7,14,21,27},{3,4,9,12.3}}; m.Initialize((double*)p,4,4); Any kind of help would be appreciated. Thank you.

      kostas KEL

      C Offline
      C Offline
      Chris Losinger
      wrote on last edited by
      #2

      KEL3 wrote:

      But it just does't work.

      what makes you think it doesn't work?

      image processing toolkits | batch image processing | blogging

      K 1 Reply Last reply
      0
      • C Chris Losinger

        KEL3 wrote:

        But it just does't work.

        what makes you think it doesn't work?

        image processing toolkits | batch image processing | blogging

        K Offline
        K Offline
        KEL3
        wrote on last edited by
        #3

        The dozens of linker errors I get.

        kostas KEL

        D 1 Reply Last reply
        0
        • K KEL3

          The dozens of linker errors I get.

          kostas KEL

          D Offline
          D Offline
          David Crow
          wrote on last edited by
          #4

          KEL3 wrote:

          The dozens of linker errors I get.

          And those would be?


          "A good athlete is the result of a good and worthy opponent." - David Crow

          "To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne

          K 1 Reply Last reply
          0
          • D David Crow

            KEL3 wrote:

            The dozens of linker errors I get.

            And those would be?


            "A good athlete is the result of a good and worthy opponent." - David Crow

            "To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne

            K Offline
            K Offline
            KEL3
            wrote on last edited by
            #5

            --------------------Configuration: mat_lib_test - Win32 Release-------------------- Normally I get: --------------------Configuration: mat_lib_test - Win32 Release-------------------- Linking... msvcrt.lib(MSVCRT.dll) : error LNK2005: _malloc already defined in libcmt.lib(malloc.obj) msvcrt.lib(MSVCRT.dll) : error LNK2005: _free already defined in libcmt.lib(free.obj) msvcrt.lib(MSVCRT.dll) : error LNK2005: _time already defined in libcmt.lib(time.obj) msvcrt.lib(MSVCRT.dll) : error LNK2005: __mbscmp already defined in libcmt.lib(mbscmp.obj) msvcrt.lib(MSVCRT.dll) : error LNK2005: __setmbcp already defined in libcmt.lib(mbctype.obj) LINK : warning LNK4098: defaultlib "mfc42.lib" conflicts with use of other libs; use /NODEFAULTLIB:library LINK : warning LNK4098: defaultlib "mfcs42.lib" conflicts with use of other libs; use /NODEFAULTLIB:library LINK : warning LNK4098: defaultlib "msvcrt.lib" conflicts with use of other libs; use /NODEFAULTLIB:library Release/mat_lib_test.exe : fatal error LNK1169: one or more multiply defined symbols found Error executing link.exe. mat_lib_test.exe - 6 error(s), 3 warning(s) --------------------------------------------------------------------------- After a few /nodefaultlib:*** mat_lib_RELEASE.lib /nologo /subsystem:windows /incremental:no /pdb:"Release/mat_lib_test.pdb" /machine:I386 /nodefaultlib:"mfc42.lib" /nodefaultlib:"mfcs42.lib" /nodefaultlib:"msvcrt.lib" /out:"Release/mat_lib_test.exe" /defaultlib:mat_lib_RELEASE.lib I get: Linking... LINK : warning LNK4049: locally defined symbol "_malloc" imported LINK : warning LNK4049: locally defined symbol "_free" imported LINK : warning LNK4049: locally defined symbol "_time" imported LINK : warning LNK4049: locally defined symbol "__mbscmp" imported mat_lib_RELEASE.lib(CKelMatrix.obj) : error LNK2001: unresolved external symbol __afxForceSTDAFX mat_lib_RELEASE.lib(CKelMatrix.obj) : error LNK2001: unresolved external symbol __imp__srand mat_lib_RELEASE.lib(CKelMatrix.obj) : error LNK2001: unresolved external symbol __imp__rand mat_lib_RELEASE.lib(CKelMatrix.obj) : error LNK2001: unresolved external symbol __imp__ceil mat_lib_RELEASE.lib(CKelMatrix.obj) : error LNK2001: unresolved external symbol __imp__floor mat_lib_RELEASE.lib(CKelMatrix.obj) : error LNK2001: unresolved external symbol __imp__atof Release/mat_lib_test.exe : fatal error LNK1120: 6 unresolved externals Error executing link.exe. mat_lib_test.exe - 7 error(s), 4 warning(s) --------------------------------

            D K B 3 Replies Last reply
            0
            • K KEL3

              --------------------Configuration: mat_lib_test - Win32 Release-------------------- Normally I get: --------------------Configuration: mat_lib_test - Win32 Release-------------------- Linking... msvcrt.lib(MSVCRT.dll) : error LNK2005: _malloc already defined in libcmt.lib(malloc.obj) msvcrt.lib(MSVCRT.dll) : error LNK2005: _free already defined in libcmt.lib(free.obj) msvcrt.lib(MSVCRT.dll) : error LNK2005: _time already defined in libcmt.lib(time.obj) msvcrt.lib(MSVCRT.dll) : error LNK2005: __mbscmp already defined in libcmt.lib(mbscmp.obj) msvcrt.lib(MSVCRT.dll) : error LNK2005: __setmbcp already defined in libcmt.lib(mbctype.obj) LINK : warning LNK4098: defaultlib "mfc42.lib" conflicts with use of other libs; use /NODEFAULTLIB:library LINK : warning LNK4098: defaultlib "mfcs42.lib" conflicts with use of other libs; use /NODEFAULTLIB:library LINK : warning LNK4098: defaultlib "msvcrt.lib" conflicts with use of other libs; use /NODEFAULTLIB:library Release/mat_lib_test.exe : fatal error LNK1169: one or more multiply defined symbols found Error executing link.exe. mat_lib_test.exe - 6 error(s), 3 warning(s) --------------------------------------------------------------------------- After a few /nodefaultlib:*** mat_lib_RELEASE.lib /nologo /subsystem:windows /incremental:no /pdb:"Release/mat_lib_test.pdb" /machine:I386 /nodefaultlib:"mfc42.lib" /nodefaultlib:"mfcs42.lib" /nodefaultlib:"msvcrt.lib" /out:"Release/mat_lib_test.exe" /defaultlib:mat_lib_RELEASE.lib I get: Linking... LINK : warning LNK4049: locally defined symbol "_malloc" imported LINK : warning LNK4049: locally defined symbol "_free" imported LINK : warning LNK4049: locally defined symbol "_time" imported LINK : warning LNK4049: locally defined symbol "__mbscmp" imported mat_lib_RELEASE.lib(CKelMatrix.obj) : error LNK2001: unresolved external symbol __afxForceSTDAFX mat_lib_RELEASE.lib(CKelMatrix.obj) : error LNK2001: unresolved external symbol __imp__srand mat_lib_RELEASE.lib(CKelMatrix.obj) : error LNK2001: unresolved external symbol __imp__rand mat_lib_RELEASE.lib(CKelMatrix.obj) : error LNK2001: unresolved external symbol __imp__ceil mat_lib_RELEASE.lib(CKelMatrix.obj) : error LNK2001: unresolved external symbol __imp__floor mat_lib_RELEASE.lib(CKelMatrix.obj) : error LNK2001: unresolved external symbol __imp__atof Release/mat_lib_test.exe : fatal error LNK1120: 6 unresolved externals Error executing link.exe. mat_lib_test.exe - 7 error(s), 4 warning(s) --------------------------------

              D Offline
              D Offline
              David Crow
              wrote on last edited by
              #6

              KEL3 wrote:

              Any ideas?

              Have you seen this, that, and the other?


              "A good athlete is the result of a good and worthy opponent." - David Crow

              "To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne

              1 Reply Last reply
              0
              • K KEL3

                --------------------Configuration: mat_lib_test - Win32 Release-------------------- Normally I get: --------------------Configuration: mat_lib_test - Win32 Release-------------------- Linking... msvcrt.lib(MSVCRT.dll) : error LNK2005: _malloc already defined in libcmt.lib(malloc.obj) msvcrt.lib(MSVCRT.dll) : error LNK2005: _free already defined in libcmt.lib(free.obj) msvcrt.lib(MSVCRT.dll) : error LNK2005: _time already defined in libcmt.lib(time.obj) msvcrt.lib(MSVCRT.dll) : error LNK2005: __mbscmp already defined in libcmt.lib(mbscmp.obj) msvcrt.lib(MSVCRT.dll) : error LNK2005: __setmbcp already defined in libcmt.lib(mbctype.obj) LINK : warning LNK4098: defaultlib "mfc42.lib" conflicts with use of other libs; use /NODEFAULTLIB:library LINK : warning LNK4098: defaultlib "mfcs42.lib" conflicts with use of other libs; use /NODEFAULTLIB:library LINK : warning LNK4098: defaultlib "msvcrt.lib" conflicts with use of other libs; use /NODEFAULTLIB:library Release/mat_lib_test.exe : fatal error LNK1169: one or more multiply defined symbols found Error executing link.exe. mat_lib_test.exe - 6 error(s), 3 warning(s) --------------------------------------------------------------------------- After a few /nodefaultlib:*** mat_lib_RELEASE.lib /nologo /subsystem:windows /incremental:no /pdb:"Release/mat_lib_test.pdb" /machine:I386 /nodefaultlib:"mfc42.lib" /nodefaultlib:"mfcs42.lib" /nodefaultlib:"msvcrt.lib" /out:"Release/mat_lib_test.exe" /defaultlib:mat_lib_RELEASE.lib I get: Linking... LINK : warning LNK4049: locally defined symbol "_malloc" imported LINK : warning LNK4049: locally defined symbol "_free" imported LINK : warning LNK4049: locally defined symbol "_time" imported LINK : warning LNK4049: locally defined symbol "__mbscmp" imported mat_lib_RELEASE.lib(CKelMatrix.obj) : error LNK2001: unresolved external symbol __afxForceSTDAFX mat_lib_RELEASE.lib(CKelMatrix.obj) : error LNK2001: unresolved external symbol __imp__srand mat_lib_RELEASE.lib(CKelMatrix.obj) : error LNK2001: unresolved external symbol __imp__rand mat_lib_RELEASE.lib(CKelMatrix.obj) : error LNK2001: unresolved external symbol __imp__ceil mat_lib_RELEASE.lib(CKelMatrix.obj) : error LNK2001: unresolved external symbol __imp__floor mat_lib_RELEASE.lib(CKelMatrix.obj) : error LNK2001: unresolved external symbol __imp__atof Release/mat_lib_test.exe : fatal error LNK1120: 6 unresolved externals Error executing link.exe. mat_lib_test.exe - 7 error(s), 4 warning(s) --------------------------------

                K Offline
                K Offline
                KEL3
                wrote on last edited by
                #7

                Generally, I looked up the error codes but this is the first library I build and the whole linker-directives thing causes me a headache! I 'll try again though...

                kostas KEL

                1 Reply Last reply
                0
                • K KEL3

                  --------------------Configuration: mat_lib_test - Win32 Release-------------------- Normally I get: --------------------Configuration: mat_lib_test - Win32 Release-------------------- Linking... msvcrt.lib(MSVCRT.dll) : error LNK2005: _malloc already defined in libcmt.lib(malloc.obj) msvcrt.lib(MSVCRT.dll) : error LNK2005: _free already defined in libcmt.lib(free.obj) msvcrt.lib(MSVCRT.dll) : error LNK2005: _time already defined in libcmt.lib(time.obj) msvcrt.lib(MSVCRT.dll) : error LNK2005: __mbscmp already defined in libcmt.lib(mbscmp.obj) msvcrt.lib(MSVCRT.dll) : error LNK2005: __setmbcp already defined in libcmt.lib(mbctype.obj) LINK : warning LNK4098: defaultlib "mfc42.lib" conflicts with use of other libs; use /NODEFAULTLIB:library LINK : warning LNK4098: defaultlib "mfcs42.lib" conflicts with use of other libs; use /NODEFAULTLIB:library LINK : warning LNK4098: defaultlib "msvcrt.lib" conflicts with use of other libs; use /NODEFAULTLIB:library Release/mat_lib_test.exe : fatal error LNK1169: one or more multiply defined symbols found Error executing link.exe. mat_lib_test.exe - 6 error(s), 3 warning(s) --------------------------------------------------------------------------- After a few /nodefaultlib:*** mat_lib_RELEASE.lib /nologo /subsystem:windows /incremental:no /pdb:"Release/mat_lib_test.pdb" /machine:I386 /nodefaultlib:"mfc42.lib" /nodefaultlib:"mfcs42.lib" /nodefaultlib:"msvcrt.lib" /out:"Release/mat_lib_test.exe" /defaultlib:mat_lib_RELEASE.lib I get: Linking... LINK : warning LNK4049: locally defined symbol "_malloc" imported LINK : warning LNK4049: locally defined symbol "_free" imported LINK : warning LNK4049: locally defined symbol "_time" imported LINK : warning LNK4049: locally defined symbol "__mbscmp" imported mat_lib_RELEASE.lib(CKelMatrix.obj) : error LNK2001: unresolved external symbol __afxForceSTDAFX mat_lib_RELEASE.lib(CKelMatrix.obj) : error LNK2001: unresolved external symbol __imp__srand mat_lib_RELEASE.lib(CKelMatrix.obj) : error LNK2001: unresolved external symbol __imp__rand mat_lib_RELEASE.lib(CKelMatrix.obj) : error LNK2001: unresolved external symbol __imp__ceil mat_lib_RELEASE.lib(CKelMatrix.obj) : error LNK2001: unresolved external symbol __imp__floor mat_lib_RELEASE.lib(CKelMatrix.obj) : error LNK2001: unresolved external symbol __imp__atof Release/mat_lib_test.exe : fatal error LNK1120: 6 unresolved externals Error executing link.exe. mat_lib_test.exe - 7 error(s), 4 warning(s) --------------------------------

                  B Offline
                  B Offline
                  Bogdan Apostol
                  wrote on last edited by
                  #8

                  MFC applications cannot include ! Why don't you compile your matrix library with the same dependency as the MFC project that needs to use it? Anyway, the conflict occurs between libcmt.lib and msvcrt.lib, thus you can try removing one of them and keep the other... see which one (we can't 'cause don't have the source code). Regards,

                  Bornish ESRI Developer Network Compilers demystified - Function pointers in Visual Basic 6.0 Enables the use of function pointers in VB6 and shows how to embed native code in a VB application.

                  K 1 Reply Last reply
                  0
                  • B Bogdan Apostol

                    MFC applications cannot include ! Why don't you compile your matrix library with the same dependency as the MFC project that needs to use it? Anyway, the conflict occurs between libcmt.lib and msvcrt.lib, thus you can try removing one of them and keep the other... see which one (we can't 'cause don't have the source code). Regards,

                    Bornish ESRI Developer Network Compilers demystified - Function pointers in Visual Basic 6.0 Enables the use of function pointers in VB6 and shows how to embed native code in a VB application.

                    K Offline
                    K Offline
                    KEL3
                    wrote on last edited by
                    #9

                    Ok! My problem was solved! All I had to do was to use MFC in a shared DLL in my application, as I did in my class. No linker directives at all! I guess that for apps using MFC in a static library you use MFC in a static library for your class... I 'll try this later. Thank you Borish. Thank you all, I 'll thank all of you, more, in my future article. BUT, Borish, what do you mean by "MFC applications cannot include !"? :doh: I include headers all the time in my MFC apps. Is there sth you can not include?

                    kostas KEL

                    B 1 Reply Last reply
                    0
                    • K KEL3

                      Ok! My problem was solved! All I had to do was to use MFC in a shared DLL in my application, as I did in my class. No linker directives at all! I guess that for apps using MFC in a static library you use MFC in a static library for your class... I 'll try this later. Thank you Borish. Thank you all, I 'll thank all of you, more, in my future article. BUT, Borish, what do you mean by "MFC applications cannot include !"? :doh: I include headers all the time in my MFC apps. Is there sth you can not include?

                      kostas KEL

                      B Offline
                      B Offline
                      Bogdan Apostol
                      wrote on last edited by
                      #10

                      Sorry... that must be a typo, or a glitch when submitting a post (maybe interpreted as html code, 'cause I've used the xml kinda brackets)! :confused: I meant MFC applications cannot include windows.h... Very glad to hear that you solved your compilation issues. Congrats!

                      Bornish ESRI Developer Network Compilers demystified - Function pointers in Visual Basic 6.0 Enables the use of function pointers in VB6 and shows how to embed native code in a VB application.

                      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